// // Created by ling on 24-2-4. // #ifndef ORDER_H #define ORDER_H #include #include namespace ling { class Options; class Order { public: enum Type { OPT, STRING, INT, DOUBLE, }; private: struct DataStruct { std::vector options; int id = 0; Type type; std::string memage; DataStruct(const std::vector &option, int id, Type type, const std::string &memage); DataStruct(); }; std::vector cmd; //选项 std::unordered_map options; //各种类型的参数 std::unordered_map opt_str; std::unordered_map opt_int; std::unordered_map opt_double; //参数类型索引 std::unordered_map type; //匿名参数 std::vector anonymity; //预定义参数规则 std::unordered_map data; //匿名参数数量 int anonymityNumber = 0; int nextID = 1; std::string errStr; protected: int64_t getInt64(int id) const; double getDouble(int id) const; const std::string &getString(int id) const; bool getOption(int id) const; bool isExistence(int id) const; public: explicit Order(const std::vector &temp); Options addOption(const std::vector &opt, const std::string &message = ""); Options addOption(const std::vector &opt, Type type, const std::string &message = ""); /// 添加匿名参数 void addAnonymity(int number); /// 获取匿名参数列表 const std::vector &getAnonymity() const; /// 解析 void analysis(); friend class Options; }; } // ling #endif //ORDER_H