Added custom allocator for subsonic responses
This commit is contained in:
@@ -44,7 +44,7 @@ namespace lms::api::subsonic
|
||||
void Response::Node::setValue(std::string_view value)
|
||||
{
|
||||
assert(_children.empty() && _childrenArrays.empty() && _childrenValues.empty());
|
||||
_value = std::string{ value };
|
||||
_value = string{ value };
|
||||
}
|
||||
|
||||
void Response::Node::setValue(long long value)
|
||||
@@ -55,13 +55,13 @@ namespace lms::api::subsonic
|
||||
|
||||
void Response::Node::setAttribute(Key key, std::string_view value)
|
||||
{
|
||||
_attributes[key] = std::string{ value };
|
||||
_attributes[key] = string{ value };
|
||||
}
|
||||
|
||||
void Response::Node::addChild(Key key, Node&& node)
|
||||
{
|
||||
assert(!_value);
|
||||
assert(_children.find(key) == std::cend(_children));
|
||||
assert(!_children.contains(key));
|
||||
_children[key] = std::move(node);
|
||||
}
|
||||
|
||||
@@ -69,29 +69,29 @@ namespace lms::api::subsonic
|
||||
{
|
||||
assert(!_value);
|
||||
assert(_children.find(key) == std::cend(_children));
|
||||
_childrenArrays.emplace(key, std::vector<Node>{});
|
||||
_childrenArrays.emplace(key, vector<Node>{});
|
||||
}
|
||||
|
||||
void Response::Node::addArrayChild(Key key, Node&& node)
|
||||
{
|
||||
assert(!_value);
|
||||
assert(_children.find(key) == std::cend(_children));
|
||||
assert(!_children.contains(key));
|
||||
_childrenArrays[key].emplace_back(std::move(node));
|
||||
}
|
||||
|
||||
void Response::Node::createEmptyArrayValue(Key key)
|
||||
{
|
||||
assert(!_value);
|
||||
assert(_children.find(key) == std::cend(_children));
|
||||
assert(!_children.contains(key));
|
||||
_childrenValues.emplace(key, ValuesType{});
|
||||
}
|
||||
|
||||
void Response::Node::addArrayValue(Key key, std::string_view value)
|
||||
{
|
||||
assert(!_value);
|
||||
assert(_children.find(key) == std::cend(_children));
|
||||
assert(!_children.contains(key));
|
||||
auto& values{ _childrenValues[key] };
|
||||
values.push_back(std::string{ value });
|
||||
values.emplace_back(string{ value });
|
||||
assert(std::all_of(std::cbegin(values) + 1, std::cend(values), [&](const ValueType& value) {return value.index() == values.front().index();}));
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ namespace lms::api::subsonic
|
||||
{
|
||||
assert(!_value);
|
||||
auto& values{ _childrenValues[key] };
|
||||
values.push_back(value);
|
||||
values.emplace_back(value);
|
||||
assert(std::all_of(std::cbegin(values) + 1, std::cend(values), [&](const ValueType& value) {return value.index() == values.front().index();}));
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@ namespace lms::api::subsonic
|
||||
Response::Node& Response::Node::createArrayChild(Key key)
|
||||
{
|
||||
assert(!_value);
|
||||
assert(_children.find(key) == std::cend(_children));
|
||||
assert(!_children.contains(key));
|
||||
_childrenArrays[key].emplace_back();
|
||||
return _childrenArrays[key].back();
|
||||
}
|
||||
@@ -192,8 +192,8 @@ namespace lms::api::subsonic
|
||||
|
||||
for (const auto& [key, value] : node._attributes)
|
||||
{
|
||||
if (std::holds_alternative<std::string>(value))
|
||||
res.put("<xmlattr>." + std::string{ key.str() }, std::get<std::string>(value));
|
||||
if (std::holds_alternative<Node::string>(value))
|
||||
res.put("<xmlattr>." + std::string{ key.str() }, std::get<Node::string>(value));
|
||||
else if (std::holds_alternative<bool>(value))
|
||||
res.put("<xmlattr>." + std::string{ key.str() }, std::get<bool>(value));
|
||||
else if (std::holds_alternative<float>(value))
|
||||
@@ -240,7 +240,7 @@ namespace lms::api::subsonic
|
||||
return res;
|
||||
};
|
||||
|
||||
boost::property_tree::ptree root{ nodeToPropertyTree(_root) };
|
||||
const boost::property_tree::ptree root{ nodeToPropertyTree(_root) };
|
||||
boost::property_tree::write_xml(os, root);
|
||||
}
|
||||
|
||||
@@ -337,9 +337,9 @@ namespace lms::api::subsonic
|
||||
|
||||
void Response::JsonSerializer::serializeValue(std::ostream& os, const Node::ValueType& value)
|
||||
{
|
||||
if (std::holds_alternative<std::string>(value))
|
||||
if (std::holds_alternative<Node::string>(value))
|
||||
{
|
||||
serializeEscapedString(os, std::get<std::string>(value));
|
||||
serializeEscapedString(os, std::get<Node::string>(value));
|
||||
}
|
||||
else if (std::holds_alternative<bool>(value))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user