00001 // -------------------------------------------------- 00002 // 00003 // File: GeneratorModule/StringParse.h 00004 // Description: 00005 // This code is used to parse a string. 00006 // It breaks it into components which are seperated by spaces 00007 // in the original. 00008 // Three methods can then be called to 00009 // Return the nth component as a string (piece method) 00010 // Return the nth component as an integer (intpiece method) if conversion is possible, returns -1 if it is off the end and 0 if it cannot be converted 00011 // Return the nth component as a double (numpiece method) if conversion is possible, returns -1.1 if it is off the end and 0 if it cannot be converted 00012 // AuthorList: 00013 // Ian Hinchliffe April 2000 00014 00015 #ifndef STRINGPARSE_H 00016 #define STRINGPARSE_H 00017 #include <string> 00018 #include <vector> 00019 class StringParse { 00020 public: 00021 StringParse(std::string input); //constructor 00022 StringParse(); //constructor 00023 ~StringParse(); //constructor 00024 std::string piece(const int & num); 00025 int intpiece(const int & num); 00026 long longpiece(const int & num); 00027 float numpiece(const int & num); 00028 unsigned string_size(void) const; 00029 00030 private: 00031 std::string m_lstring; 00032 std::vector<std::string> m_lsubstring; 00033 int m_nword; 00034 std::string m_past_end; 00035 }; 00036 00037 00038 inline unsigned 00039 StringParse::string_size(void) const 00040 { return m_nword; } 00041 00042 #endif