MCPcopy Create free account
hub / github.com/BohemiaInteractive/CWR / CollectStrings

Method CollectStrings

apps/tools/Tools/commands/ConfigCommand.cpp:130–168  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

128}
129
130void ConfigCommand::CollectStrings(const ParamClass& cls, const std::string& path, const std::string& prefix,
131 std::vector<std::pair<std::string, std::string>>& out)
132{
133 for (int i = 0; i < cls.GetEntryCount(); i++)
134 {
135 const ParamEntry& entry = cls.GetEntry(i);
136 std::string entryPath =
137 path.empty() ? std::string(entry.GetName().Data()) : path + "." + std::string(entry.GetName().Data());
138
139 if (entry.IsClass())
140 {
141 const ParamClass* sub = entry.GetClassInterface();
142 if (sub)
143 CollectStrings(*sub, entryPath, prefix, out);
144 }
145 else if (entry.IsArray())
146 {
147 for (int j = 0; j < entry.GetSize(); j++)
148 {
149 const IParamArrayValue& val = entry[j];
150 if (val.IsTextValue())
151 {
152 const char* v = val.GetValueRaw().Data();
153 if (v && v[0] == '$' && strncmp(v + 1, prefix.c_str(), prefix.size()) == 0)
154 {
155 std::string idx = entryPath + "[" + std::to_string(j) + "]";
156 out.emplace_back(idx, v);
157 }
158 }
159 }
160 }
161 else if (entry.IsTextValue())
162 {
163 const char* v = entry.GetValueRaw().Data();
164 if (v && v[0] == '$' && strncmp(v + 1, prefix.c_str(), prefix.size()) == 0)
165 out.emplace_back(entryPath, v);
166 }
167 }
168}
169
170static std::string Trim(std::string s)
171{

Callers

nothing calls this directly

Calls 11

GetClassInterfaceMethod · 0.80
sizeMethod · 0.80
GetEntryCountMethod · 0.45
emptyMethod · 0.45
DataMethod · 0.45
GetNameMethod · 0.45
IsClassMethod · 0.45
IsArrayMethod · 0.45
GetSizeMethod · 0.45
IsTextValueMethod · 0.45
GetValueRawMethod · 0.45

Tested by

no test coverage detected