23 #include <interfaces/generator/checker.h>
24 #include <interfaces/generator/exceptions.h>
25 #include <interfaces/generator/field.h>
40 this->enum_constants = enum_constants;
79 if (type ==
"string") {
85 }
else if (type ==
"float" || type ==
"double" || type ==
"bool" || is_enum_type) {
93 }
else if (type ==
"float" || type ==
"double" || type ==
"bool" || is_enum_type) {
108 if (type ==
"string") {
110 }
else if (type ==
"byte") {
112 }
else if (type ==
"float" || type ==
"double" || type ==
"bool" || is_enum_type) {
125 if (type ==
"string") {
127 }
else if (type ==
"byte") {
129 }
else if (type ==
"float" || type ==
"double" || type ==
"bool") {
131 }
else if (is_enum_type) {
192 return default_value;
198 const std::vector<InterfaceEnumConstant> *
201 return enum_constants;
216 std::vector<InterfaceEnumConstant>::const_iterator i;
217 for (i = enum_constants->begin(); i != enum_constants->end(); ++i) {
218 if (type == i->get_name()) {
229 std::vector<std::string>
241 is_enum_type =
false;
242 if (enum_constants != NULL) {
243 std::vector<InterfaceEnumConstant>::iterator i;
244 for (i = enum_constants->begin(); i != enum_constants->end(); ++i) {
245 if (type == (*i).get_name()) {
268 this->comment = comment;
277 this->length_value = (
unsigned int)atoi(length.c_str());
278 this->length = length;
279 this->max_idx = std::to_string(length_value - 1);
288 this->validfor = validfor;
297 this->default_value = default_value;
315 InterfaceField::tokenize(
const std::string & str,
316 std::vector<std::string> &tokens,
317 const std::string & delimiters)
320 std::string::size_type last_pos = str.find_first_not_of(delimiters, 0);
322 std::string::size_type pos = str.find_first_of(delimiters, last_pos);
324 while (std::string::npos != pos || std::string::npos != last_pos) {
326 tokens.push_back(str.substr(last_pos, pos - last_pos));
328 last_pos = str.find_first_not_of(delimiters, pos);
330 pos = str.find_first_of(delimiters, last_pos);
341 if (attr_name ==
"name") {
343 }
else if (attr_name ==
"type") {
345 }
else if (attr_name ==
"length") {
347 }
else if (attr_name ==
"validfor") {
349 }
else if (attr_name ==
"default") {
351 }
else if (attr_name ==
"flags") {
352 tokenize(attr_value, flags,
",");
378 if ((name.length() == 0) || (name.find(
" ") != std::string::npos)) {
390 for (std::vector<std::string>::iterator i = flags.begin(); i != flags.end(); ++i) {
391 if (*i !=
"changed_indicator") {
419 if ((type ==
"unsigned int")) {
420 return (f.type !=
"unsigned int");
422 }
else if (type ==
"int") {
423 return ((f.type !=
"int") && (f.type !=
"unsigned int"));
425 }
else if (type ==
"unsigned long int") {
426 return ((f.type !=
"unsigned long int") && (f.type !=
"unsigned int") && (f.type !=
"int"));
428 }
else if (type ==
"long int") {
429 return ((f.type !=
"long int") && (f.type !=
"unsigned int") && (f.type !=
"int")
430 && (f.type !=
"unsigned long int"));
432 }
else if (type ==
"float") {
433 return ((f.type !=
"float") && (f.type !=
"unsigned int") && (f.type !=
"int"));
435 }
else if (type ==
"double") {
436 return ((f.type !=
"double") && (f.type !=
"unsigned int") && (f.type !=
"int")
437 && (f.type !=
"float"));
439 }
else if (type ==
"bool") {
440 return ((f.type !=
"bool") && (f.type !=
"double") && (f.type !=
"unsigned int")
441 && (f.type !=
"int") && (f.type !=
"float"));
443 }
else if (type ==
"byte") {
444 return ((f.type !=
"byte") && (f.type !=
"bool") && (f.type !=
"double")
445 && (f.type !=
"unsigned int") && (f.type !=
"int") && (f.type !=
"float"));