Skip to content
Snippets Groups Projects
cfg-cmd.h 2.5 KiB
Newer Older
  • Learn to ignore specific revisions
  • 数学の武士's avatar
    数学の武士 committed
    #pragma once
    
    // [cfg-cmd.h]: configurable variable class 'cfgCommand'
    //
    // -------------------------------------------------------------------------------------------- //
    
    #include "cfg-vec.h"
    
    namespace scm
    {
    	class cfgCommand {
    	public:
    
    		// add argument
    		// -------------------------------------------------------------------------------------------- //
    		bool add_arg(const cfgVector& _arg);
    		// -------------------------------------------------------------------------------------------- //
    
    		// change command name
    		// -------------------------------------------------------------------------------------------- //
    		void set_name(const char* _name);
    		// -------------------------------------------------------------------------------------------- //
    		
    		// reset command, narg == 0
    		// -------------------------------------------------------------------------------------------- //
    		void reset();
    		// -------------------------------------------------------------------------------------------- //
    
    		// get & check calls
    		// -------------------------------------------------------------------------------------------- //
    		int get_narg() const;
    		cfgVector get_arg(const int idx) const;
    		
    		bool is_name_eq(const char* ex_name) const;
    
    		const char* get_name() const;
    		// -------------------------------------------------------------------------------------------- //
    
    		// print
    		// -------------------------------------------------------------------------------------------- //
    		void print() const;
    		// -------------------------------------------------------------------------------------------- //
    
    		// swap & assignment
    		// -------------------------------------------------------------------------------------------- //
    		const cfgCommand& operator=(cfgCommand cmd);
    		void swap(cfgCommand& cmd);
    		// -------------------------------------------------------------------------------------------- //
    
    		// -------------------------------------------------------------------------------------------- //
    		cfgCommand();
    		cfgCommand(const cfgCommand& cmd);
    		~cfgCommand();
    		// -------------------------------------------------------------------------------------------- //
    
    	private:
    		// data (private):
    		// -------------------------------------------------------------------------------------------- //
    
    		cfgVector *arg;
    		int narg;
    
    		int nalloc;
    		static const int c_nalloc_inc = 2;
    
    		char* name;
    		size_t name_memsize;
    	};
    }
    // -------------------------------------------------------------------------------------------- //