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;
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 != "unsigned int") && (__keytype != "int") &&
00113 (__keytype != "long unsigned int") && (__keytype != "long int") ) {
00114 throw InterfaceGeneratorInvalidValueException("keytype", "string", "Pseudo map keyes can only be of a numeric type");
00115 }
00116 if (__keytype.length() == 0) {
00117 throw InterfaceGeneratorInvalidValueException("keytype", "string", "key type must not be empty");
00118 }
00119 }
00120
00121
00122
00123
00124
00125
00126 void
00127 InterfacePseudoMap::addRef(std::string fieldname, std::string key)
00128 {
00129 __parefs.push_back(make_pair(fieldname, key));
00130 }
00131
00132
00133
00134
00135
00136 InterfacePseudoMap::RefList &
00137 InterfacePseudoMap::getRefList()
00138 {
00139 return __parefs;
00140 }