MCPcopy Create free account
hub / github.com/ClickHouse/ClickHouse / stripComments

Method stripComments

base/poco/JSON/src/ParserImpl.cpp:107–138  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

105
106
107void ParserImpl::stripComments(std::string& json)
108{
109 if (_allowComments)
110 {
111 bool inString = false;
112 bool inComment = false;
113 char prevChar = 0;
114 std::string::iterator it = json.begin();
115 for (; it != json.end();)
116 {
117 if (*it == '"' && !inString) inString = true;
118 else inString = false;
119 if (!inString)
120 {
121 if (*it == '/' && it + 1 != json.end() && *(it + 1) == '*')
122 inComment = true;
123 }
124 if (inComment)
125 {
126 char c = *it;
127 it = json.erase(it);
128 if (prevChar == '*' && c == '/')
129 {
130 inComment = false;
131 prevChar = 0;
132 }
133 else prevChar = c;
134 }
135 else ++it;
136 }
137 }
138}
139
140
141void ParserImpl::handleArray()

Callers

nothing calls this directly

Calls 3

beginMethod · 0.45
endMethod · 0.45
eraseMethod · 0.45

Tested by

no test coverage detected