MCPcopy Create free account
hub / github.com/OAID/Tengine / main

Function main

internal/tests/core/test/test_obj_attr.cpp:117–165  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

115using BaseObject = Attribute;
116
117int main(int argc, char* argv[])
118{
119 B b("class b");
120 A a;
121 BaseObject obj = {{"name", "Tom"}, {"Age", 13}};
122
123 a = 200;
124 b = "new value";
125
126 obj["my0"] = b;
127 obj["my1"] = a;
128 a = 100;
129
130 obj["my3"] = a;
131 obj["my2"] = b;
132 obj.RemoveAttr("my0");
133
134 A* p_a = new A(1000);
135
136 obj["ptr"] = std::shared_ptr<A>(p_a);
137
138 obj["int"] = 101;
139
140 std::vector<std::string> attr = obj.ListAttr();
141
142 std::vector<std::string>::iterator ir = attr.begin();
143
144 std::cout << "List attr names: " << std::endl;
145 while(ir != attr.end())
146 {
147 std::cout << *ir << "::type<" << GetTypeName(obj[*ir].type().name()) << ">" << std::endl;
148 ++ir;
149 }
150 std::cout << "name: " << any_cast<char const*>(obj["name"]) << std::endl;
151 std::cout << "Age: " << any_cast<int>(obj["Age"]) << std::endl;
152 std::cout << "my1: " << (any_cast<A>(obj["my1"])).Get() << std::endl;
153 std::cout << "my3: " << (any_cast<A>(obj["my3"])).Get() << std::endl;
154
155 OutputTypeName(typeid(T_TEST::Add).name());
156
157 std::cout << std::endl;
158 OutputTypeName("_ZN2A2C1Ei");
159 std::cout << std::endl;
160 OutputTypeName("_ZZN7TEngine12ClassFactory12RegisterTypeI2A2IEEEvRKNSt7__cxx1112basic_stringIcSt11char_"
161 "traitsIcESaIcEEEENKUlvE_clEv");
162 std::cout << std::endl;
163
164 return 0;
165}

Callers

nothing calls this directly

Calls 7

OutputTypeNameFunction · 0.85
RemoveAttrMethod · 0.80
beginMethod · 0.80
endMethod · 0.80
GetTypeNameFunction · 0.50
ListAttrMethod · 0.45
GetMethod · 0.45

Tested by

no test coverage detected