MCPcopy Create free account
hub / github.com/axmolengine/axmol / createNonRefCounted

Method createNonRefCounted

core/base/Properties.cpp:101–143  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

99}
100
101Properties* Properties::createNonRefCounted(std::string_view url)
102{
103 if (url.empty())
104 {
105 AXLOGE("Attempting to create a Properties object from an empty URL!");
106 return nullptr;
107 }
108
109 // Calculate the file and full namespace path from the specified url.
110 auto& urlString = url;
111 std::string fileString;
112 std::vector<std::string_view> namespacePath;
113 calculateNamespacePath(urlString, fileString, namespacePath);
114
115 // data will be released automatically when 'data' goes out of scope
116 // so we pass data as weak pointer
117 auto data = FileUtils::getInstance()->getDataFromFile(fileString);
118 ssize_t dataIdx = 0;
119 Properties* properties = new Properties(&data, &dataIdx);
120 properties->resolveInheritance();
121
122 // Get the specified properties object.
123 Properties* p = getPropertiesFromNamespacePath(properties, namespacePath);
124 if (!p)
125 {
126 AXLOGW("Failed to load properties from url '{}'.", url);
127 AX_SAFE_DELETE(properties);
128 return nullptr;
129 }
130
131 // If the loaded properties object is not the root namespace,
132 // then we have to clone it and delete the root namespace
133 // so that we don't leak memory.
134 if (p != properties)
135 {
136 p = p->clone();
137 AX_SAFE_DELETE(properties);
138 }
139 // XXX
140 // p->setDirectoryPath(FileSystem::getDirectoryName(fileString));
141 p->setDirectoryPath("");
142 return p;
143}
144
145static bool isVariable(const char* str, char* outName, size_t outSize)
146{

Callers

nothing calls this directly

Calls 8

calculateNamespacePathFunction · 0.85
getInstanceFunction · 0.85
getDataFromFileMethod · 0.80
resolveInheritanceMethod · 0.80
setDirectoryPathMethod · 0.80
emptyMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected