parse group
authorJens Thiele <jens.thiele@intra2net.com>
Tue, 21 Nov 2006 10:59:18 +0000 (10:59 +0000)
committerJens Thiele <jens.thiele@intra2net.com>
Tue, 21 Nov 2006 10:59:18 +0000 (10:59 +0000)
codegen/main.cpp

index 1236b5c..0c60908 100644 (file)
@@ -31,6 +31,20 @@ strip(std::string s, std::string prefix)
      return std::string(s, prefix.length(), s.length()-prefix.length());
 }
 
+std::string
+extract_group(const std::string &attrs)
+{
+     // todo: improve this
+     std::string error;
+     std::string to_match("gccxml(libt2n-");
+     std::string::size_type p(attrs.find(to_match));
+     if (p==std::string::npos) return error;
+     std::string group(attrs, p+to_match.length(), attrs.length());
+     p=group.find_first_of(')');
+     assert(p!=std::string::npos);
+     return std::string(group,0,p);
+}
+
 //! get child element by id
 /*!
   \return pointer to element having id or null on error
@@ -187,12 +201,11 @@ protected:
 
          // check wether the procedure is marked (TODO: improve)
          // attributes are speparated by spaces?
-         if (attributes->get_value().find("gccxml(libt2n")==std::string::npos) return;
 
-         // TODO: extract command group
-         // something like: sed 's,gccxml(libt2n-\([a-z]*}),\1,'
          t2n_procedure f;
-         f.group=("default");
+         f.group=extract_group(attributes->get_value());
+         if (f.group.empty()) return;
+         // todo: handle default group
 
          // we need the return type
          f.ret_type=get_type(root, returns->get_value());