cgma
|
00001 00006 #ifndef CGM_FILE_OPTIONS_HPP 00007 #define CGM_FILE_OPTIONS_HPP 00008 00009 #include <string> 00010 #include <vector> 00011 #include "CubitDefines.h" 00012 00013 /* file option type */ 00014 enum CGMFOErrorCode 00015 { 00016 FO_SUCCESS = 0, 00017 FO_TYPE_OUT_OF_RANGE, 00018 FO_ENTITY_NOT_FOUND, 00019 FO_FAILURE 00020 }; 00021 00027 class CGMFileOptions { 00028 public: 00029 00030 /*\param options_string The concatenation of a list of 00031 * options, separated either by the default separator 00032 * (semicolon) with a custom separator specified at 00033 * the beginning of the string (semicolon followed by 00034 * destired separator character.) 00035 */ 00036 CGMFileOptions( const char* option_string ); 00037 00038 CGMFileOptions( const CGMFileOptions& copy ); 00039 CGMFileOptions& operator=( const CGMFileOptions& copy ); 00040 00041 ~CGMFileOptions(); 00042 00051 CGMFOErrorCode get_null_option( const char* name ) const; 00052 00062 CGMFOErrorCode get_int_option( const char* name, int& value ) const; 00063 00073 CGMFOErrorCode get_real_option( const char* name, double& value ) const; 00074 00084 CGMFOErrorCode get_str_option( const char* name, std::string& value ) const; 00085 00093 CGMFOErrorCode get_option( const char* name, std::string& value ) const; 00094 00107 CGMFOErrorCode match_option( const char* name, const char* const* values, int& index ) const; 00108 00118 CGMFOErrorCode match_option( const char* name, const char* value ) const; 00119 00133 CGMFOErrorCode get_ints_option( const char* name, std::vector<int>& values) const; 00134 00136 inline unsigned size() const 00137 { return mOptions.size(); } 00138 00140 inline bool empty() const 00141 { return mOptions.empty(); } 00142 00144 void get_options( std::vector<std::string>& list ) const; 00145 00146 private: 00147 00155 CGMFOErrorCode get_option( const char* name, const char*& value) const; 00156 00157 char* mData; 00158 std::vector<const char*> mOptions; 00159 00161 static bool compare( const char* name, const char* option ); 00162 }; 00163 00164 #endif 00165