Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- template<typename T>
- std::string variant_container<T>::to_string_impl(bool annotate, bool annotate_empty, std::function<std::string(variant&)> mod_func) const;
- {
- std::ostringstream ss;
- if(annotate) {
- ss << "[";
- }
- bool first_time = true;
- for(const auto& member : container_) {
- if(!first_time) {
- ss << ",";
- }
- first_time = false;
- if(type_ == TYPE_LIST) {
- ss << mod_func(member);
- } else if(type_ == TYPE_MAP) {
- ss << mod_func(member.first);
- ss << "->";
- ss << mod_func(member.second);
- }
- }
- // TODO: evaluate if this really needs to be separately conditional.
- if(annotate_empty && container_->empty()) {
- ss << "->";
- }
- if(annotate) {
- ss << "]";
- }
- return ss.str();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement