MCPcopy Create free account
hub / github.com/BZFlag-Dev/bzflag / writeBZDB

Function writeBZDB

src/common/ConfigFileManager.cpp:29–50  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

27
28
29void writeBZDB(const std::string& name, void* stream) {
30 std::ostream& s = *static_cast<std::ostream*>(stream);
31 std::string value = BZDB.get(name);
32 std::string defaultVal = BZDB.getDefault(name);
33 std::string newkey;
34 bool commentOut = (value == defaultVal);
35
36 // quotify anything with a space and empty strings
37 if ((value.find(' ') != value.npos) || (value.size() == 0)) {
38 value = std::string("\"") + value + "\"";
39 }
40
41 // quotify the key if there's a space
42 if (name.find(' ') != name.npos) {
43 newkey = std::string("\"") + name + "\"";
44 }
45 else {
46 newkey = name;
47 }
48
49 s << (commentOut ? "#set " : "set ") << newkey << ' ' << value << std::endl;
50}
51
52
53void writeKEYMGR(const std::string& name, bool press,

Callers

nothing calls this directly

Calls 4

getMethod · 0.45
getDefaultMethod · 0.45
findMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected