00001
00011 #include "strings.h"
00012
00013 namespace ace {
00014
00015 const char StringStore::_empty = NULL_CHAR;
00016
00017
00018
00019 const char * StringStore::store(const char *str) {
00020
00021 static strings_store_t::key_compare str_comp;
00022
00023 if ( *str == _empty ) {
00024
00025 return &_empty;
00026 }
00027
00028
00029
00030 strings_store_t::iterator i_str = _strings.lower_bound(str);
00031 if ( i_str != _strings.end() ) {
00032
00033 if ( !str_comp(*i_str, str) && !str_comp(str, *i_str) ) {
00034
00035 return *i_str;
00036 }
00037 }
00038
00039
00040 size_t memory_needed = strlen(str) + 1;
00041 char* mem = _memory_pool.get_memory(memory_needed);
00042
00043
00044
00045 memcpy(mem, str, memory_needed);
00046
00047 return *_strings.insert(i_str, mem);
00048 }
00049
00050 }