X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/1b2ab8e6d556a8ed30d4feadc72263b3f4c86665..90ccd7fd541197d65ed795596ef79aa1eb4c69f6:/projects/sgconf/options.h

diff --git a/projects/sgconf/options.h b/projects/sgconf/options.h
index 3d4bdd64..c00707bf 100644
--- a/projects/sgconf/options.h
+++ b/projects/sgconf/options.h
@@ -24,6 +24,7 @@
 #include <string>
 #include <vector>
 #include <list>
+#include <utility>
 #include <stdexcept>
 #include <cstddef> // size_t
 
@@ -49,8 +50,10 @@ class OPTION
         OPTION & operator=(const OPTION & rhs);
 
         void Help(size_t level = 0) const;
-        PARSER_STATE Parse(int argc, char ** argv);
+        PARSER_STATE Parse(int argc, char ** argv, void * data);
+        void ParseValue(const std::string & value);
         bool Check(const char * arg) const;
+        const std::string & Name() const { return m_longName; }
 
         class ERROR : public std::runtime_error
         {
@@ -82,11 +85,21 @@ class OPTION_BLOCK
 
         void Help(size_t level) const;
 
-        PARSER_STATE Parse(int argc, char ** argv);
+        PARSER_STATE Parse(int argc, char ** argv, void * data = NULL);
+        void ParseFile(const std::string & filePath);
+
+        class ERROR : public std::runtime_error
+        {
+            public:
+                ERROR(const std::string & message)
+                    : std::runtime_error(message.c_str()) {}
+        };
 
     private:
         std::vector<OPTION> m_options;
         std::string m_description;
+
+        void OptionCallback(const std::string & key, const std::string & value);
 };
 
 class OPTION_BLOCKS
@@ -94,6 +107,7 @@ class OPTION_BLOCKS
     public:
         OPTION_BLOCK & Add(const std::string & description)
         { m_blocks.push_back(OPTION_BLOCK(description)); return m_blocks.back(); }
+        void Add(const OPTION_BLOCK & block) { m_blocks.push_back(block); }
         void Help(size_t level) const;
         PARSER_STATE Parse(int argc, char ** argv);