MCPcopy Create free account
hub / github.com/codereader/DarkRadiant / replacePropertiesBlock

Function replacePropertiesBlock

test/LayerManipulation.cpp:1113–1144  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1111}
1112
1113inline void replacePropertiesBlock(const std::string& infoFilePath, const std::string& replacement)
1114{
1115 auto contents = algorithm::loadFileToString(infoFilePath);
1116
1117 std::list<std::string> lines;
1118 string::split(lines, contents, "\n\r");
1119
1120 contents.clear();
1121 for (auto line = lines.begin(); line != lines.end(); ++line)
1122 {
1123 if (string::trim_copy(*line) == "LayerProperties")
1124 {
1125 ++line; // skip LayerProperties
1126 ++line; // skip the opening brace
1127
1128 while (string::trim_copy(*line) != "}")
1129 {
1130 ++line;
1131 }
1132
1133 // Add the replacement block here
1134 contents.append(replacement);
1135 contents.append("\n");
1136 continue;
1137 }
1138
1139 contents.append(*line);
1140 contents.append("\n");
1141 }
1142
1143 algorithm::replaceFileContents(infoFilePath, contents);
1144}
1145
1146TEST_F(LayerTest, ParseEmptyLayerPropertiesBlock)
1147{

Callers 1

TEST_FFunction · 0.85

Calls 8

loadFileToStringFunction · 0.85
splitFunction · 0.85
trim_copyFunction · 0.85
replaceFileContentsFunction · 0.85
clearMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected