35 const bool should_free_;
49 Deleter(
bool should_free) : should_free_(should_free) {;}
54 Deleter(
const Deleter&) =
default;
59 Deleter& operator=(Deleter&) =
delete;
66 void operator()(std::string* sp)
const {
98 typedef std::map<std::string, StringUniquePtr> StringMap;
160 std::string* result = itr->second.get();
183 if(p.second.get() == s){
198 std::ios::fmtflags f = o.flags();
201 o <<
"\"" << pair.first <<
"\" "
203 <<
" @ " << std::setw(10) << pair.second.get() <<
"\n";
226 "Attempted to access StringManager singleton before it was "
227 "statically constructed.")
228 return *_GBL_string_manager;
Set of macros for Sparta assertions. Caught by the framework.
#define sparta_assert(...)
Simple variadic assertion that will throw a sparta_exception if the condition fails.
Helpers for enforcing StaticInitialization order.
Static-initialization order controller.
Manages string internment for SPARTA. This allows strings to be compared by pointer once interned.
bool hasString(const std::string &s) const
Checks to see if a string is present without adding it.
static StringManager & getStringManager()
Returns the StringManager singleton.
StringManager()
Constructor.
uint32_t getNumStrings() const
Gets the number of strings in this StringManager.
uint32_t max_string_len_
Maximum string length held by the StringManager.
static const uint64_t IS_CONSTRUCTED_CONST
Value of is_constructed after construction.
const uint64_t is_constructed
Has this singleton been constructed yet. Yes if equal to IS_CONSTRUCTED_CONST.
std::unique_ptr< std::string, Deleter > StringUniquePtr
Mapping of strings to their addresses.
StringMap string_map_
Mapping of ID to string for getting the string associated with this ID. Allows lookup with a string f...
bool isInterned(const std::string *s) const
Determines if a string is interned in this string manager by its pointer.
const std::string *const EMPTY
Holds interned empty strings.
void dumpStrings(std::ostream &o, bool pretty=false) const
Write all strings interned in the string manager to an ostream.
std::string * internString(const std::string &s)
Stores a string in shared space within this manager unless it is already stored.
std::string * findString(const std::string &s) const
Find a string in this manager.
Macros for handling exponential backoff.