Last active
September 16, 2015 01:53
-
-
Save thiagomg/1929547c54a505e83902 to your computer and use it in GitHub Desktop.
Template and OO - Custom class
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Now I can add my own class to this string_builder add function | |
struct LazyMessage { | |
std::string type; | |
int seq; | |
std::vector<std::string> entries; | |
}; | |
namespace Text { | |
namespace internal { | |
template <> | |
struct add<LazyMessage> { | |
add(std::string &buffer, LazyMessage &msg, int size_inc) { | |
std::string s = msg.type; | |
for(const auto &entry : msg.entries) | |
s += " [" + entry + "]"; | |
_check_size(buffer, s.size(), size_inc); | |
buffer += s; | |
} | |
}; | |
} //Namespace internal | |
} //Namespace Text |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment