Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members   Examples  

stringpool.C

Go to the documentation of this file.
00001 // $Id: stringpool.C,v 1.1.1.1 2002/03/24 12:37:02 dvermeir Exp $
00002 #include "stringpool.h"
00003 
00004 StringPool::StringPool() {
00005 }
00006 
00007 StringPool::~StringPool() {
00008 for (PtrSet::const_iterator i=pool_.begin(); i!=pool_.end(); ++i)
00009   delete (*i);
00010 }
00011 
00012 const string*
00013 StringPool::operator()(const string& s) const {
00014 PtrSet::const_iterator i = pool_.find(&s);
00015 return (i==pool_.end() ? 0 : *i);
00016 }
00017 
00018 const string*
00019 StringPool::operator[](const string& s) {
00020 return *(pool_.insert(new string(s)).first);
00021 }
00022 
00023 bool
00024 StringPool::compare::operator()(const string* s1, 
00025   const string* s2) const throw (runtime_error) {
00026 if ((s1 == 0) || (s2 == 0) )
00027   throw runtime_error("StringPool::Compare(): null argument");
00028 return *s1 < *s2;
00029 }
00030 
00031 void
00032 StringPool::remove(const string& s) {
00033 const string* ps((*this)(s));
00034 if (ps)
00035   pool_.erase(ps);
00036 }

textindexer-0.2 [27 March, 2002]