cgma
FileOptions.hpp
Go to the documentation of this file.
00001 
00006 #ifndef FILE_OPTIONS_HPP
00007 #define FILE_OPTIONS_HPP
00008 
00009 #include <string>
00010 #include <vector>
00011 #include "CubitDefines.h"
00012 
00013 /* file option type */
00014 enum FOErrorCode
00015 {
00016   FO_SUCCESS = 0,
00017   FO_TYPE_OUT_OF_RANGE,
00018   FO_ENTITY_NOT_FOUND,
00019   FO_FAILURE
00020 };
00021 
00027 class FileOptions {
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   FileOptions( const char* option_string );
00037   
00038   FileOptions( const FileOptions& copy );
00039   FileOptions& operator=( const FileOptions& copy );
00040   
00041   ~FileOptions();
00042   
00051   FOErrorCode get_null_option( const char* name ) const;
00052   
00062   FOErrorCode get_int_option( const char* name, int& value ) const;
00063   
00073   FOErrorCode get_real_option( const char* name, double& value ) const;
00074   
00084   FOErrorCode get_str_option( const char* name, std::string& value ) const;
00085   
00093   FOErrorCode get_option( const char* name, std::string& value ) const;
00094   
00107   FOErrorCode match_option( const char* name, const char* const* values, int& index ) const;
00108   
00118   FOErrorCode match_option( const char* name, const char* value ) const;
00119   
00133   FOErrorCode 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   FOErrorCode 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 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines