12 #ifndef EMP_DYNAMIC_STRING_H 13 #define EMP_DYNAMIC_STRING_H 18 #include "../base/vector.h" 26 using value_t = std::function<std::string()>;
39 std::string
operator[](
size_t id)
const {
return fun_set[id](); }
51 for (
auto & cur_fun : fun_set) ss << cur_fun();
63 return Set(
id, [in_text](){
return in_text; } );
75 return Append( [in_text](){
return in_text; } );
79 template <
typename IN_TYPE>
90 for (
size_t i = 0; i < strings.
GetSize(); ++i) {
DynamicString & Set(size_t id, const value_t &in_fun)
Set the value of a specified component to the provided function.
Definition: DynamicString.h:56
DynamicString & Clear()
Remove all contents on this DynamicString.
Definition: DynamicString.h:46
DynamicString()
Definition: DynamicString.h:31
size_t GetSize() const
How many string components (funcations or continuous substrings) are in this DynamicString?
Definition: DynamicString.h:35
DynamicString & Append(const value_t &in_fun)
Add a new function to the end of the DynamicString.
Definition: DynamicString.h:67
std::string operator[](size_t id) const
Definition: DynamicString.h:39
Definition: BitVector.h:785
void push_back(PB_Ts &&...args)
Definition: vector.h:189
std::function< std::string()> value_t
Definition: DynamicString.h:26
const value_t & GetFunction(size_t id) const
Definition: DynamicString.h:43
size_t size() const
Definition: vector.h:151
DynamicString & Append(const std::string &in_text)
Add new std::string text to the end of the DynamicString.
Definition: DynamicString.h:74
void resize(size_t new_size)
Definition: vector.h:161
DynamicString & Set(size_t id, const std::string &in_text)
Set the value of a specified component to the provided std::string text.
Definition: DynamicString.h:62
If we are in emscripten, make sure to include the header.
Definition: array.h:37
DynamicString & operator<<(IN_TYPE &&_in)
Allow operator<< to append to the back of a DynamicString.
Definition: DynamicString.h:80
std::string str()
Convert to an std::string.
Definition: DynamicString.h:49
Definition: DynamicString.h:24