Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/.vscode
/build
/CMakeUserPresets.json
/CMakeUserPresets.json
/.vs
/out
22 changes: 21 additions & 1 deletion src/XmlParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,7 @@ void parseElement(Context& context, xsdcpp::ElementContext& parentElementContext
if (context.pos.pos != start)
{
std::string text = stripComments(start, context.pos.pos - start);
text = unescapeString(text.c_str(), text.size());
elementContext.info->addText(elementContext.element, context.pos, std::move(text));
}
}
Expand Down Expand Up @@ -629,6 +630,25 @@ std::string to_string(size_t val, size_t size, const char* const* values, const
return values[val];
}

bool parse_xs_bool(std::stringstream& ss, bool& val)
{
bool b;

std::streampos pos = ss.tellg();

if (!(ss >> std::boolalpha >> b))
{
ss.clear();
ss.seekg(pos);

if (!(ss >> std::noboolalpha >> b))
return false;
}

val = b;
return true;
}

void set_string(std::string* obj, const Position&, std::string&& val) { if (obj->empty()) *obj = std::move(val); else *obj += val; }
void set_uint64_t(uint64_t* obj, const Position& pos, std::string&& val) { std::stringstream ss(val); if (!(ss >> *obj)) throw VerificationException(pos, "Expected unsigned 64-bit integer value"); }
void set_int64_t(int64_t* obj, const Position& pos, std::string&& val) { std::stringstream ss(val); if (!(ss >> *obj)) throw VerificationException(pos, "Expected 64-bit integer value"); }
Expand All @@ -638,7 +658,7 @@ void set_uint16_t(uint16_t* obj, const Position& pos, std::string&& val) { std:
void set_int16_t(int16_t* obj, const Position& pos, std::string&& val) { std::stringstream ss(val); if (!(ss >> *obj)) throw VerificationException(pos, "Expected 16-bit integer value"); }
void set_float(float* obj, const Position& pos, std::string&& val) { std::stringstream ss(val); if (!(ss >> *obj)) throw VerificationException(pos, "Expected single precision floating point value"); }
void set_double(double* obj, const Position& pos, std::string&& val) { std::stringstream ss(val); if (!(ss >> *obj)) throw VerificationException(pos, "Expected double precision floating point value"); }
void set_bool(bool* obj, const Position& pos, std::string&& val) { std::stringstream ss(val); if (!(ss >> std::boolalpha >> *obj)) throw VerificationException(pos, "Expected boolean value"); }
void set_bool(bool* obj, const Position& pos, std::string&& val) { std::stringstream ss(val); if (!parse_xs_bool(ss, *obj)) throw VerificationException(pos, "Expected boolean value"); }

std::string read_file(const std::string& filePath)
{
Expand Down
Loading