23 #include <interfaces/generator/field.h>
24 #include <interfaces/generator/type_checker.h>
25 #include <interfaces/generator/exceptions.h>
42 this->enum_constants = enum_constants;
85 if (type ==
"string") {
91 }
else if (type ==
"float" || type ==
"double" || type ==
"bool" || is_enum_type) {
99 }
else if (type ==
"float" || type ==
"double" || type ==
"bool" || is_enum_type) {
115 if (type ==
"string") {
117 }
else if (type ==
"byte") {
119 }
else if (type ==
"float" || type ==
"double" || type ==
"bool" || is_enum_type) {
133 if (type ==
"string") {
135 }
else if (type ==
"byte") {
137 }
else if (type ==
"float" || type ==
"double" || type ==
"bool") {
139 }
else if (is_enum_type) {
195 return default_value;
202 std::vector<std::string>
215 is_enum_type =
false;
216 if ( enum_constants != NULL ) {
217 std::vector<InterfaceEnumConstant>::iterator i;
218 for (i = enum_constants->begin(); i != enum_constants->end(); ++i) {
219 if ( type == (*i).get_name() ) {
244 this->comment = comment;
254 this->length_value = (
unsigned int)atoi(length.c_str());
255 this->length = length;
265 this->validfor = validfor;
275 this->default_value = default_value;
295 InterfaceField::tokenize(
const std::string& str,
296 std::vector<std::string>& tokens,
297 const std::string& delimiters)
300 std::string::size_type last_pos = str.find_first_not_of(delimiters, 0);
302 std::string::size_type pos = str.find_first_of(delimiters, last_pos);
304 while (std::string::npos != pos || std::string::npos != last_pos) {
306 tokens.push_back(str.substr(last_pos, pos - last_pos));
308 last_pos = str.find_first_not_of(delimiters, pos);
310 pos = str.find_first_of(delimiters, last_pos);
322 if ( attr_name ==
"name" ) {
324 }
else if ( attr_name ==
"type" ) {
326 }
else if ( attr_name ==
"length" ) {
328 }
else if ( attr_name ==
"validfor" ) {
330 }
else if ( attr_name ==
"default" ) {
332 }
else if ( attr_name ==
"flags" ) {
333 tokenize(attr_value, flags,
",");
353 if ( (name.length() == 0) || (name.find(
" ") != std::string::npos) ) {
362 if ( (default_value.length() > 0) &&
366 for (std::vector<std::string>::iterator i = flags.begin(); i != flags.end(); ++i) {
367 if ( *i !=
"changed_indicator" ) {
396 if ( (type ==
"unsigned int") ) {
397 return (f.type !=
"unsigned int");
399 }
else if ( type ==
"int" ) {
400 return ( (f.type !=
"int") &&
401 (f.type !=
"unsigned int") );
404 }
else if ( type ==
"unsigned long int" ) {
405 return ( (f.type !=
"unsigned long int") &&
406 (f.type !=
"unsigned int") &&
409 }
else if ( type ==
"long int" ) {
410 return ( (f.type !=
"long int") &&
411 (f.type !=
"unsigned int") &&
413 (f.type !=
"unsigned long int") );
415 }
else if ( type ==
"float" ) {
416 return ( (f.type !=
"float") &&
417 (f.type !=
"unsigned int") &&
420 }
else if ( type ==
"double" ) {
421 return ( (f.type !=
"double") &&
422 (f.type !=
"unsigned int") &&
424 (f.type !=
"float") );
426 }
else if ( type ==
"bool" ) {
427 return ( (f.type !=
"bool") &&
428 (f.type !=
"double") &&
429 (f.type !=
"unsigned int") &&
431 (f.type !=
"float") );
433 }
else if ( type ==
"byte" ) {
434 return ( (f.type !=
"byte") &&
435 (f.type !=
"bool") &&
436 (f.type !=
"double") &&
437 (f.type !=
"unsigned int") &&
439 (f.type !=
"float") );