pseudomap.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include <interfaces/generator/pseudomap.h>
00024 #include <interfaces/generator/type_checker.h>
00025 #include <interfaces/generator/exceptions.h>
00026
00027 #include <cstdlib>
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043 InterfacePseudoMap::InterfacePseudoMap(std::string name, std::string type,
00044 std::string keytype, std::string comment)
00045 {
00046 __name = name;
00047 __type = type;
00048 __keytype = keytype;
00049 __comment = comment;
00050 }
00051
00052
00053
00054
00055
00056 std::string
00057 InterfacePseudoMap::getName() const
00058 {
00059 return __name;
00060 }
00061
00062
00063
00064
00065
00066 std::string
00067 InterfacePseudoMap::getType() const
00068 {
00069 return __type;
00070 }
00071
00072
00073
00074
00075
00076 std::string
00077 InterfacePseudoMap::getComment() const
00078 {
00079 return __comment;
00080 }
00081
00082
00083
00084
00085
00086 std::string
00087 InterfacePseudoMap::getKeyType() const
00088 {
00089 return __keytype + "_t";
00090 }
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103 void
00104 InterfacePseudoMap::valid()
00105 {
00106 if ( (__name.length() == 0) || (__name.find(" ") != std::string::npos) ) {
00107 throw InterfaceGeneratorInvalidValueException("name", "string", "name must neither be empty nor contain spaces");
00108 }
00109 if (__type.length() == 0) {
00110 throw InterfaceGeneratorInvalidValueException("type", "string", "type must not be empty");
00111 }
00112 if ( (__keytype != "int8") && (__keytype != "int16") &&
00113 (__keytype != "int32") && (__keytype != "int64") &&
00114 (__keytype != "uint8") && (__keytype != "uint16") &&
00115 (__keytype != "uint32") && (__keytype != "uint64") ) {
00116 throw InterfaceGeneratorInvalidValueException("keytype", "string", "Pseudo map keys can only be of a numeric type");
00117 }
00118 if (__keytype.length() == 0) {
00119 throw InterfaceGeneratorInvalidValueException("keytype", "string", "key type must not be empty");
00120 }
00121 }
00122
00123
00124
00125
00126
00127
00128 void
00129 InterfacePseudoMap::addRef(std::string fieldname, std::string key)
00130 {
00131 __parefs.push_back(make_pair(fieldname, key));
00132 }
00133
00134
00135
00136
00137
00138 InterfacePseudoMap::RefList &
00139 InterfacePseudoMap::getRefList()
00140 {
00141 return __parefs;
00142 }