1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
|
#include <string.h>
#include <assert.h>
#include "parm_string.hpp"
#include "string_map.hpp"
#include "string_pair.hpp"
#include "string_pair_enumeration.hpp"
#include "hash-t.hpp"
// This file is part of The New Aspell
// Copyright (C) 2001 by Kevin Atkinson under the GNU LGPL license
// version 2.0 or 2.1. You should have received a copy of the LGPL
// license along with this library if you did not you can find
// it at http://www.gnu.org/.
namespace acommon {
// needed for darwin
template HashTable<StringMap::Parms>::iterator
HashTable<StringMap::Parms>::find_i(char const* const&, bool&);
template std::pair<HashTable<StringMap::Parms>::iterator,bool>
HashTable<StringMap::Parms>::insert(const StringPair &);
template void HashTable<StringMap::Parms>::init(unsigned int);
template void HashTable<StringMap::Parms>::del(void);
template HashTable<StringMap::Parms>::size_type
HashTable<StringMap::Parms>::erase(char const* const&);
template void BlockSList<StringPair>::clear(void);
void StringMap::copy(const StringMap & other)
{
lookup_ = other.lookup_;
for (Iter_ i = lookup_.begin();
!(i == lookup_.end()); // i != lookup_.end() causes problems
// with gcc-2.95
++i)
{
i->first = buffer_.dup(i->first);
i->second = buffer_.dup(i->second);
}
}
class StringMapEnumeration : public StringPairEnumeration {
StringMap::CIter_ i;
StringMap::CIter_ end;
public:
StringMapEnumeration(StringMap::CIter_ i0, StringMap::CIter_ e0)
: i(i0), end(e0) {}
StringPairEnumeration * clone() const;
void assign(const StringPairEnumeration *);
bool at_end() const;
StringPair next();
};
StringPairEnumeration * StringMapEnumeration::clone() const {
return new StringMapEnumeration(*this);
}
void
StringMapEnumeration::assign
(const StringPairEnumeration * other)
{
*this = *(const StringMapEnumeration *)(other);
}
bool StringMapEnumeration::at_end() const {
return i == end;
}
StringPair StringMapEnumeration::next() {
StringPair temp;
if (i == end)
return temp;
temp = *i;
++i;
return temp;
}
StringPairEnumeration * StringMap::elements() const {
return new StringMapEnumeration(lookup_.begin(), lookup_.end());
}
StringMap * new_string_map()
{
return new StringMap();
}
}
|