MCPcopy Create free account
hub / github.com/OpenFodder/openfodder / abstract_value

Class abstract_value

Source/Utils/cxxopts.hpp:1032–1160  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1030
1031 template <typename T>
1032 class abstract_value : public Value
1033 {
1034 using Self = abstract_value<T>;
1035
1036 public:
1037 abstract_value()
1038 : m_result(std::make_shared<T>())
1039 , m_store(m_result.get())
1040 {
1041 }
1042
1043 explicit abstract_value(T* t)
1044 : m_store(t)
1045 {
1046 }
1047
1048 ~abstract_value() override = default;
1049
1050 abstract_value& operator=(const abstract_value&) = default;
1051
1052 abstract_value(const abstract_value& rhs)
1053 {
1054 if (rhs.m_result)
1055 {
1056 m_result = std::make_shared<T>();
1057 m_store = m_result.get();
1058 }
1059 else
1060 {
1061 m_store = rhs.m_store;
1062 }
1063
1064 m_default = rhs.m_default;
1065 m_implicit = rhs.m_implicit;
1066 m_default_value = rhs.m_default_value;
1067 m_implicit_value = rhs.m_implicit_value;
1068 }
1069
1070 void
1071 parse(const std::string& text) const override
1072 {
1073 parse_value(text, *m_store);
1074 }
1075
1076 bool
1077 is_container() const override
1078 {
1079 return type_is_container<T>::value;
1080 }
1081
1082 void
1083 parse() const override
1084 {
1085 parse_value(m_default_value, *m_store);
1086 }
1087
1088 bool
1089 has_default() const override

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected