MCPcopy Create free account
hub / github.com/MyGUI/mygui / new_xpath_variable

Function new_xpath_variable

Tools/EditorFramework/pugixml.cpp:7398–7414  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7396
7397template<typename T>
7398PUGI__FN T* new_xpath_variable(const char_t* name)
7399{
7400 size_t length = strlength(name);
7401 if (length == 0)
7402 return 0; // empty variable names are invalid
7403
7404 // $$ we can't use offsetof(T, name) because T is non-POD, so we just allocate additional length characters
7405 void* memory = xml_memory::allocate(sizeof(T) + length * sizeof(char_t));
7406 if (!memory)
7407 return 0;
7408
7409 T* result = new (memory) T();
7410
7411 memcpy(result->name, name, (length + 1) * sizeof(char_t));
7412
7413 return result;
7414}
7415
7416PUGI__FN xpath_variable* new_xpath_variable(xpath_value_type type, const char_t* name)
7417{

Callers 1

addMethod · 0.70

Calls 1

strlengthFunction · 0.70

Tested by

no test coverage detected