41 #ifndef CACHEDSTRING_H
42 #define CACHEDSTRING_H
48 #include <tr1/unordered_map>
100 return "char (cached)";
109 return m_key_val_pr->first.first;
117 typedef std::pair<std::string, cetype_t> key;
121 class Hasher :
public std::unary_function<key, std::size_t> {
123 std::size_t operator()(
const key& k)
const
125 return s_string_hasher(k.first);
128 static std::tr1::hash<std::string> s_string_hasher;
135 std::tr1::unordered_map<key, CachedString*, Hasher,
142 static CachedString* s_blank;
144 map::value_type* m_key_val_pr;
145 mutable Symbol* m_symbol;
148 explicit CachedString(map::value_type* key_val_pr)
149 : String(key_val_pr->first.first.
size(), key_val_pr->first.second),
150 m_key_val_pr(key_val_pr), m_symbol(0)
152 setCString(key_val_pr->first.first.c_str());
157 CachedString(
const CachedString&);
158 CachedString& operator=(
const CachedString&);
164 static void cleanup();
167 static void initialize();
169 friend class SchwarzCounter<CachedString>;
194 const CXXR::String* str = CXXR::SEXP_downcast<const CXXR::String*>(x);
195 return (dynamic_cast<const CXXR::CachedString*>(str) != 0);