Cosmetic: remove trailing spaces.
git-svn-id: svn://svn.code.sf.net/p/loki-lib/code/trunk@1008 7ec92016-0320-0410-acc4-a06ded1c099a
This commit is contained in:
parent
a251ebcc12
commit
a2e99a55dd
4 changed files with 117 additions and 117 deletions
|
@ -26,7 +26,7 @@ class StoragePolicy
|
||||||
typedef @ const_iterator;
|
typedef @ const_iterator;
|
||||||
typedef A allocator_type;
|
typedef A allocator_type;
|
||||||
typedef @ size_type;
|
typedef @ size_type;
|
||||||
|
|
||||||
StoragePolicy(const StoragePolicy& s);
|
StoragePolicy(const StoragePolicy& s);
|
||||||
StoragePolicy(const A&);
|
StoragePolicy(const A&);
|
||||||
StoragePolicy(const E* s, size_type len, const A&);
|
StoragePolicy(const E* s, size_type len, const A&);
|
||||||
|
@ -37,7 +37,7 @@ class StoragePolicy
|
||||||
const_iterator begin() const;
|
const_iterator begin() const;
|
||||||
iterator end();
|
iterator end();
|
||||||
const_iterator end() const;
|
const_iterator end() const;
|
||||||
|
|
||||||
size_type size() const;
|
size_type size() const;
|
||||||
size_type max_size() const;
|
size_type max_size() const;
|
||||||
size_type capacity() const;
|
size_type capacity() const;
|
||||||
|
@ -50,10 +50,10 @@ class StoragePolicy
|
||||||
void resize(size_type newSize, E fill);
|
void resize(size_type newSize, E fill);
|
||||||
|
|
||||||
void swap(StoragePolicy& rhs);
|
void swap(StoragePolicy& rhs);
|
||||||
|
|
||||||
const E* c_str() const;
|
const E* c_str() const;
|
||||||
const E* data() const;
|
const E* data() const;
|
||||||
|
|
||||||
A get_allocator() const;
|
A get_allocator() const;
|
||||||
};
|
};
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -82,7 +82,7 @@ class AllocatorStringStorage : public A
|
||||||
|
|
||||||
void* Alloc(size_type sz, const void* p = 0)
|
void* Alloc(size_type sz, const void* p = 0)
|
||||||
{
|
{
|
||||||
return A::allocate(1 + (sz - 1) / sizeof(E),
|
return A::allocate(1 + (sz - 1) / sizeof(E),
|
||||||
static_cast<const char*>(p));
|
static_cast<const char*>(p));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,43 +118,43 @@ class AllocatorStringStorage : public A
|
||||||
pData_->pEndOfMem_ = pData_->buffer_ + cap;
|
pData_->pEndOfMem_ = pData_->buffer_ + cap;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef E value_type;
|
typedef E value_type;
|
||||||
typedef A allocator_type;
|
typedef A allocator_type;
|
||||||
typedef typename A::pointer iterator;
|
typedef typename A::pointer iterator;
|
||||||
typedef typename A::const_pointer const_iterator;
|
typedef typename A::const_pointer const_iterator;
|
||||||
|
|
||||||
AllocatorStringStorage()
|
AllocatorStringStorage()
|
||||||
: A(), pData_(0)
|
: A(), pData_(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
AllocatorStringStorage(const AllocatorStringStorage& rhs)
|
AllocatorStringStorage(const AllocatorStringStorage& rhs)
|
||||||
: A(rhs.get_allocator())
|
: A(rhs.get_allocator())
|
||||||
{
|
{
|
||||||
const size_type sz = rhs.size();
|
const size_type sz = rhs.size();
|
||||||
Init(sz, sz);
|
Init(sz, sz);
|
||||||
if (sz) flex_string_details::pod_copy(rhs.begin(), rhs.end(), begin());
|
if (sz) flex_string_details::pod_copy(rhs.begin(), rhs.end(), begin());
|
||||||
}
|
}
|
||||||
|
|
||||||
AllocatorStringStorage(const AllocatorStringStorage& s,
|
AllocatorStringStorage(const AllocatorStringStorage& s,
|
||||||
flex_string_details::Shallow)
|
flex_string_details::Shallow)
|
||||||
: A(s.get_allocator())
|
: A(s.get_allocator())
|
||||||
{
|
{
|
||||||
pData_ = s.pData_;
|
pData_ = s.pData_;
|
||||||
}
|
}
|
||||||
|
|
||||||
AllocatorStringStorage(const A& a) : A(a)
|
AllocatorStringStorage(const A& a) : A(a)
|
||||||
{
|
{
|
||||||
pData_ = const_cast<Data*>(
|
pData_ = const_cast<Data*>(
|
||||||
&SimpleStringStorage<E, A>::emptyString_);
|
&SimpleStringStorage<E, A>::emptyString_);
|
||||||
}
|
}
|
||||||
|
|
||||||
AllocatorStringStorage(const E* s, size_type len, const A& a)
|
AllocatorStringStorage(const E* s, size_type len, const A& a)
|
||||||
: A(a)
|
: A(a)
|
||||||
{
|
{
|
||||||
Init(len, len);
|
Init(len, len);
|
||||||
flex_string_details::pod_copy(s, s + len, begin());
|
flex_string_details::pod_copy(s, s + len, begin());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -164,7 +164,7 @@ public:
|
||||||
Init(len, len);
|
Init(len, len);
|
||||||
flex_string_details::pod_fill(&*begin(), &*end(), c);
|
flex_string_details::pod_fill(&*begin(), &*end(), c);
|
||||||
}
|
}
|
||||||
|
|
||||||
AllocatorStringStorage& operator=(const AllocatorStringStorage& rhs)
|
AllocatorStringStorage& operator=(const AllocatorStringStorage& rhs)
|
||||||
{
|
{
|
||||||
const size_type sz = rhs.size();
|
const size_type sz = rhs.size();
|
||||||
|
@ -173,28 +173,28 @@ public:
|
||||||
pData_->pEnd_ = &*begin() + rhs.size();
|
pData_->pEnd_ = &*begin() + rhs.size();
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
~AllocatorStringStorage()
|
~AllocatorStringStorage()
|
||||||
{
|
{
|
||||||
if (capacity())
|
if (capacity())
|
||||||
{
|
{
|
||||||
Free(pData_,
|
Free(pData_,
|
||||||
sizeof(Data) + capacity() * sizeof(E));
|
sizeof(Data) + capacity() * sizeof(E));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
iterator begin()
|
iterator begin()
|
||||||
{ return pData_->buffer_; }
|
{ return pData_->buffer_; }
|
||||||
|
|
||||||
const_iterator begin() const
|
const_iterator begin() const
|
||||||
{ return pData_->buffer_; }
|
{ return pData_->buffer_; }
|
||||||
|
|
||||||
iterator end()
|
iterator end()
|
||||||
{ return pData_->pEnd_; }
|
{ return pData_->pEnd_; }
|
||||||
|
|
||||||
const_iterator end() const
|
const_iterator end() const
|
||||||
{ return pData_->pEnd_; }
|
{ return pData_->pEnd_; }
|
||||||
|
|
||||||
size_type size() const
|
size_type size() const
|
||||||
{ return size_type(end() - begin()); }
|
{ return size_type(end() - begin()); }
|
||||||
|
|
||||||
|
@ -209,7 +209,7 @@ public:
|
||||||
reserve(n);
|
reserve(n);
|
||||||
iterator newEnd = begin() + n;
|
iterator newEnd = begin() + n;
|
||||||
iterator oldEnd = end();
|
iterator oldEnd = end();
|
||||||
if (newEnd > oldEnd)
|
if (newEnd > oldEnd)
|
||||||
{
|
{
|
||||||
// Copy the characters
|
// Copy the characters
|
||||||
flex_string_details::pod_fill(oldEnd, newEnd, c);
|
flex_string_details::pod_fill(oldEnd, newEnd, c);
|
||||||
|
@ -221,23 +221,23 @@ public:
|
||||||
{
|
{
|
||||||
if (res_arg <= capacity())
|
if (res_arg <= capacity())
|
||||||
{
|
{
|
||||||
// @@@ shrink to fit here
|
// @@@ shrink to fit here
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
A& myAlloc = *this;
|
A& myAlloc = *this;
|
||||||
AllocatorStringStorage newStr(myAlloc);
|
AllocatorStringStorage newStr(myAlloc);
|
||||||
newStr.Init(size(), res_arg);
|
newStr.Init(size(), res_arg);
|
||||||
|
|
||||||
flex_string_details::pod_copy(begin(), end(), newStr.begin());
|
flex_string_details::pod_copy(begin(), end(), newStr.begin());
|
||||||
|
|
||||||
swap(newStr);
|
swap(newStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class ForwardIterator>
|
template <class ForwardIterator>
|
||||||
void append(ForwardIterator b, ForwardIterator e)
|
void append(ForwardIterator b, ForwardIterator e)
|
||||||
{
|
{
|
||||||
const size_type
|
const size_type
|
||||||
sz = std::distance(b, e),
|
sz = std::distance(b, e),
|
||||||
neededCapacity = size() + sz;
|
neededCapacity = size() + sz;
|
||||||
|
|
||||||
|
@ -251,26 +251,26 @@ public:
|
||||||
std::copy(b, e, end());
|
std::copy(b, e, end());
|
||||||
pData_->pEnd_ += sz;
|
pData_->pEnd_ += sz;
|
||||||
}
|
}
|
||||||
|
|
||||||
void swap(AllocatorStringStorage& rhs)
|
void swap(AllocatorStringStorage& rhs)
|
||||||
{
|
{
|
||||||
// @@@ The following line is commented due to a bug in MSVC
|
// @@@ The following line is commented due to a bug in MSVC
|
||||||
//std::swap(lhsAlloc, rhsAlloc);
|
//std::swap(lhsAlloc, rhsAlloc);
|
||||||
std::swap(pData_, rhs.pData_);
|
std::swap(pData_, rhs.pData_);
|
||||||
}
|
}
|
||||||
|
|
||||||
const E* c_str() const
|
const E* c_str() const
|
||||||
{
|
{
|
||||||
if (pData_ != &SimpleStringStorage<E, A>::emptyString_)
|
if (pData_ != &SimpleStringStorage<E, A>::emptyString_)
|
||||||
{
|
{
|
||||||
*pData_->pEnd_ = E();
|
*pData_->pEnd_ = E();
|
||||||
}
|
}
|
||||||
return &*begin();
|
return &*begin();
|
||||||
}
|
}
|
||||||
|
|
||||||
const E* data() const
|
const E* data() const
|
||||||
{ return &*begin(); }
|
{ return &*begin(); }
|
||||||
|
|
||||||
A get_allocator() const
|
A get_allocator() const
|
||||||
{ return *this; }
|
{ return *this; }
|
||||||
};
|
};
|
||||||
|
|
|
@ -32,7 +32,7 @@ class StoragePolicy
|
||||||
typedef @ const_iterator;
|
typedef @ const_iterator;
|
||||||
typedef A allocator_type;
|
typedef A allocator_type;
|
||||||
typedef @ size_type;
|
typedef @ size_type;
|
||||||
|
|
||||||
StoragePolicy(const StoragePolicy& s);
|
StoragePolicy(const StoragePolicy& s);
|
||||||
StoragePolicy(const A&);
|
StoragePolicy(const A&);
|
||||||
StoragePolicy(const E* s, size_type len, const A&);
|
StoragePolicy(const E* s, size_type len, const A&);
|
||||||
|
@ -43,7 +43,7 @@ class StoragePolicy
|
||||||
const_iterator begin() const;
|
const_iterator begin() const;
|
||||||
iterator end();
|
iterator end();
|
||||||
const_iterator end() const;
|
const_iterator end() const;
|
||||||
|
|
||||||
size_type size() const;
|
size_type size() const;
|
||||||
size_type max_size() const;
|
size_type max_size() const;
|
||||||
size_type capacity() const;
|
size_type capacity() const;
|
||||||
|
@ -51,17 +51,17 @@ class StoragePolicy
|
||||||
void reserve(size_type res_arg);
|
void reserve(size_type res_arg);
|
||||||
|
|
||||||
void append(const E* s, size_type sz);
|
void append(const E* s, size_type sz);
|
||||||
|
|
||||||
template <class InputIterator>
|
template <class InputIterator>
|
||||||
void append(InputIterator b, InputIterator e);
|
void append(InputIterator b, InputIterator e);
|
||||||
|
|
||||||
void resize(size_type newSize, E fill);
|
void resize(size_type newSize, E fill);
|
||||||
|
|
||||||
void swap(StoragePolicy& rhs);
|
void swap(StoragePolicy& rhs);
|
||||||
|
|
||||||
const E* c_str() const;
|
const E* c_str() const;
|
||||||
const E* data() const;
|
const E* data() const;
|
||||||
|
|
||||||
A get_allocator() const;
|
A get_allocator() const;
|
||||||
};
|
};
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -94,7 +94,7 @@ public:
|
||||||
typedef typename Storage::allocator_type allocator_type;
|
typedef typename Storage::allocator_type allocator_type;
|
||||||
typedef typename allocator_type::size_type size_type;
|
typedef typename allocator_type::size_type size_type;
|
||||||
typedef typename Storage::reference reference;
|
typedef typename Storage::reference reference;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
union
|
union
|
||||||
{
|
{
|
||||||
|
@ -112,14 +112,14 @@ private:
|
||||||
assert(*d.begin() > 0);
|
assert(*d.begin() > 0);
|
||||||
return *d.begin();
|
return *d.begin();
|
||||||
}
|
}
|
||||||
|
|
||||||
RefCountType& Refs()
|
RefCountType& Refs()
|
||||||
{
|
{
|
||||||
Storage& d = Data();
|
Storage& d = Data();
|
||||||
assert(d.size() > 0);
|
assert(d.size() > 0);
|
||||||
return reinterpret_cast<RefCountType&>(*d.begin());
|
return reinterpret_cast<RefCountType&>(*d.begin());
|
||||||
}
|
}
|
||||||
|
|
||||||
void MakeUnique() const
|
void MakeUnique() const
|
||||||
{
|
{
|
||||||
assert(GetRefs() >= 1);
|
assert(GetRefs() >= 1);
|
||||||
|
@ -134,7 +134,7 @@ private:
|
||||||
--(*Data().begin()); // Harmut Kaiser fix:
|
--(*Data().begin()); // Harmut Kaiser fix:
|
||||||
// decrement the use count of the remaining object
|
// decrement the use count of the remaining object
|
||||||
new(buf_) Storage(
|
new(buf_) Storage(
|
||||||
*new(temp.buf_) Storage(Data()),
|
*new(temp.buf_) Storage(Data()),
|
||||||
flex_string_details::Shallow());
|
flex_string_details::Shallow());
|
||||||
*Data().begin() = 1;
|
*Data().begin() = 1;
|
||||||
}
|
}
|
||||||
|
@ -155,12 +155,12 @@ public:
|
||||||
}
|
}
|
||||||
assert(Data().size() > 0);
|
assert(Data().size() > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
CowStringOpt(const allocator_type& a)
|
CowStringOpt(const allocator_type& a)
|
||||||
{
|
{
|
||||||
new(buf_) Storage(1, 1, a);
|
new(buf_) Storage(1, 1, a);
|
||||||
}
|
}
|
||||||
|
|
||||||
CowStringOpt(const E* s, size_type len, const allocator_type& a)
|
CowStringOpt(const E* s, size_type len, const allocator_type& a)
|
||||||
{
|
{
|
||||||
// Warning - MSVC's debugger has trouble tracing through the code below.
|
// Warning - MSVC's debugger has trouble tracing through the code below.
|
||||||
|
@ -177,7 +177,7 @@ public:
|
||||||
new(buf_) Storage(len + 1, c, a);
|
new(buf_) Storage(len + 1, c, a);
|
||||||
Refs() = 1;
|
Refs() = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
CowStringOpt& operator=(const CowStringOpt& rhs)
|
CowStringOpt& operator=(const CowStringOpt& rhs)
|
||||||
{
|
{
|
||||||
CowStringOpt(rhs).swap(*this);
|
CowStringOpt(rhs).swap(*this);
|
||||||
|
@ -194,26 +194,26 @@ public:
|
||||||
{
|
{
|
||||||
assert(Data().size() > 0);
|
assert(Data().size() > 0);
|
||||||
MakeUnique();
|
MakeUnique();
|
||||||
return Data().begin() + 1;
|
return Data().begin() + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
const_iterator begin() const
|
const_iterator begin() const
|
||||||
{
|
{
|
||||||
assert(Data().size() > 0);
|
assert(Data().size() > 0);
|
||||||
return Data().begin() + 1;
|
return Data().begin() + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
iterator end()
|
iterator end()
|
||||||
{
|
{
|
||||||
MakeUnique();
|
MakeUnique();
|
||||||
return Data().end();
|
return Data().end();
|
||||||
}
|
}
|
||||||
|
|
||||||
const_iterator end() const
|
const_iterator end() const
|
||||||
{
|
{
|
||||||
return Data().end();
|
return Data().end();
|
||||||
}
|
}
|
||||||
|
|
||||||
size_type size() const
|
size_type size() const
|
||||||
{
|
{
|
||||||
assert(Data().size() > 0);
|
assert(Data().size() > 0);
|
||||||
|
@ -221,13 +221,13 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
size_type max_size() const
|
size_type max_size() const
|
||||||
{
|
{
|
||||||
assert(Data().max_size() > 0);
|
assert(Data().max_size() > 0);
|
||||||
return Data().max_size() - 1;
|
return Data().max_size() - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_type capacity() const
|
size_type capacity() const
|
||||||
{
|
{
|
||||||
assert(Data().capacity() > 0);
|
assert(Data().capacity() > 0);
|
||||||
return Data().capacity() - 1;
|
return Data().capacity() - 1;
|
||||||
}
|
}
|
||||||
|
@ -245,33 +245,33 @@ public:
|
||||||
MakeUnique();
|
MakeUnique();
|
||||||
Data().append(b, e);
|
Data().append(b, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
void reserve(size_type res_arg)
|
void reserve(size_type res_arg)
|
||||||
{
|
{
|
||||||
if (capacity() > res_arg) return;
|
if (capacity() > res_arg) return;
|
||||||
MakeUnique();
|
MakeUnique();
|
||||||
Data().reserve(res_arg + 1);
|
Data().reserve(res_arg + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void swap(CowStringOpt& rhs)
|
void swap(CowStringOpt& rhs)
|
||||||
{
|
{
|
||||||
Data().swap(rhs.Data());
|
Data().swap(rhs.Data());
|
||||||
}
|
}
|
||||||
|
|
||||||
const E* c_str() const
|
const E* c_str() const
|
||||||
{
|
{
|
||||||
assert(Data().size() > 0);
|
assert(Data().size() > 0);
|
||||||
return Data().c_str() + 1;
|
return Data().c_str() + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
const E* data() const
|
const E* data() const
|
||||||
{
|
{
|
||||||
assert(Data().size() > 0);
|
assert(Data().size() > 0);
|
||||||
return Data().data() + 1;
|
return Data().data() + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
allocator_type get_allocator() const
|
allocator_type get_allocator() const
|
||||||
{
|
{
|
||||||
return Data().get_allocator();
|
return Data().get_allocator();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -26,7 +26,7 @@ class StoragePolicy
|
||||||
typedef @ const_iterator;
|
typedef @ const_iterator;
|
||||||
typedef A allocator_type;
|
typedef A allocator_type;
|
||||||
typedef @ size_type;
|
typedef @ size_type;
|
||||||
|
|
||||||
StoragePolicy(const StoragePolicy& s);
|
StoragePolicy(const StoragePolicy& s);
|
||||||
StoragePolicy(const A&);
|
StoragePolicy(const A&);
|
||||||
StoragePolicy(const E* s, size_type len, const A&);
|
StoragePolicy(const E* s, size_type len, const A&);
|
||||||
|
@ -37,7 +37,7 @@ class StoragePolicy
|
||||||
const_iterator begin() const;
|
const_iterator begin() const;
|
||||||
iterator end();
|
iterator end();
|
||||||
const_iterator end() const;
|
const_iterator end() const;
|
||||||
|
|
||||||
size_type size() const;
|
size_type size() const;
|
||||||
size_type max_size() const;
|
size_type max_size() const;
|
||||||
size_type capacity() const;
|
size_type capacity() const;
|
||||||
|
@ -50,10 +50,10 @@ class StoragePolicy
|
||||||
void resize(size_type newSize, E fill);
|
void resize(size_type newSize, E fill);
|
||||||
|
|
||||||
void swap(StoragePolicy& rhs);
|
void swap(StoragePolicy& rhs);
|
||||||
|
|
||||||
const E* c_str() const;
|
const E* c_str() const;
|
||||||
const E* data() const;
|
const E* data() const;
|
||||||
|
|
||||||
A get_allocator() const;
|
A get_allocator() const;
|
||||||
};
|
};
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -86,7 +86,7 @@ public:
|
||||||
E buffer_[1];
|
E buffer_[1];
|
||||||
};
|
};
|
||||||
static const Data emptyString_;
|
static const Data emptyString_;
|
||||||
|
|
||||||
typedef typename A::size_type size_type;
|
typedef typename A::size_type size_type;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -95,14 +95,14 @@ private:
|
||||||
void Init(size_type size, size_type capacity)
|
void Init(size_type size, size_type capacity)
|
||||||
{
|
{
|
||||||
assert(size <= capacity);
|
assert(size <= capacity);
|
||||||
if (capacity == 0)
|
if (capacity == 0)
|
||||||
{
|
{
|
||||||
pData_ = const_cast<Data*>(&emptyString_);
|
pData_ = const_cast<Data*>(&emptyString_);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// 11-17-2000: comment added:
|
// 11-17-2000: comment added:
|
||||||
// No need to allocate (capacity + 1) to
|
// No need to allocate (capacity + 1) to
|
||||||
// accommodate the terminating 0, because Data already
|
// accommodate the terminating 0, because Data already
|
||||||
// has one one character in there
|
// has one one character in there
|
||||||
pData_ = static_cast<Data*>(
|
pData_ = static_cast<Data*>(
|
||||||
|
@ -112,12 +112,12 @@ private:
|
||||||
pData_->pEndOfMem_ = pData_->buffer_ + capacity;
|
pData_->pEndOfMem_ = pData_->buffer_ + capacity;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Warning - this doesn't initialize pData_. Used in reserve()
|
// Warning - this doesn't initialize pData_. Used in reserve()
|
||||||
SimpleStringStorage()
|
SimpleStringStorage()
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef E value_type;
|
typedef E value_type;
|
||||||
typedef E* iterator;
|
typedef E* iterator;
|
||||||
|
@ -125,23 +125,23 @@ public:
|
||||||
typedef A allocator_type;
|
typedef A allocator_type;
|
||||||
typedef typename A::reference reference;
|
typedef typename A::reference reference;
|
||||||
|
|
||||||
|
|
||||||
SimpleStringStorage(const SimpleStringStorage& rhs)
|
SimpleStringStorage(const SimpleStringStorage& rhs)
|
||||||
{
|
{
|
||||||
const size_type sz = rhs.size();
|
const size_type sz = rhs.size();
|
||||||
Init(sz, sz);
|
Init(sz, sz);
|
||||||
if (sz) flex_string_details::pod_copy(rhs.begin(), rhs.end(), begin());
|
if (sz) flex_string_details::pod_copy(rhs.begin(), rhs.end(), begin());
|
||||||
}
|
}
|
||||||
|
|
||||||
SimpleStringStorage(const SimpleStringStorage& s,
|
SimpleStringStorage(const SimpleStringStorage& s,
|
||||||
flex_string_details::Shallow)
|
flex_string_details::Shallow)
|
||||||
: pData_(s.pData_)
|
: pData_(s.pData_)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
SimpleStringStorage(const A&)
|
SimpleStringStorage(const A&)
|
||||||
{ pData_ = const_cast<Data*>(&emptyString_); }
|
{ pData_ = const_cast<Data*>(&emptyString_); }
|
||||||
|
|
||||||
SimpleStringStorage(const E* s, size_type len, const A&)
|
SimpleStringStorage(const E* s, size_type len, const A&)
|
||||||
{
|
{
|
||||||
Init(len, len);
|
Init(len, len);
|
||||||
|
@ -153,7 +153,7 @@ public:
|
||||||
Init(len, len);
|
Init(len, len);
|
||||||
flex_string_details::pod_fill(begin(), end(), c);
|
flex_string_details::pod_fill(begin(), end(), c);
|
||||||
}
|
}
|
||||||
|
|
||||||
SimpleStringStorage& operator=(const SimpleStringStorage& rhs)
|
SimpleStringStorage& operator=(const SimpleStringStorage& rhs)
|
||||||
{
|
{
|
||||||
const size_type sz = rhs.size();
|
const size_type sz = rhs.size();
|
||||||
|
@ -171,16 +171,16 @@ public:
|
||||||
|
|
||||||
iterator begin()
|
iterator begin()
|
||||||
{ return pData_->buffer_; }
|
{ return pData_->buffer_; }
|
||||||
|
|
||||||
const_iterator begin() const
|
const_iterator begin() const
|
||||||
{ return pData_->buffer_; }
|
{ return pData_->buffer_; }
|
||||||
|
|
||||||
iterator end()
|
iterator end()
|
||||||
{ return pData_->pEnd_; }
|
{ return pData_->pEnd_; }
|
||||||
|
|
||||||
const_iterator end() const
|
const_iterator end() const
|
||||||
{ return pData_->pEnd_; }
|
{ return pData_->pEnd_; }
|
||||||
|
|
||||||
size_type size() const
|
size_type size() const
|
||||||
{ return pData_->pEnd_ - pData_->buffer_; }
|
{ return pData_->pEnd_ - pData_->buffer_; }
|
||||||
|
|
||||||
|
@ -198,7 +198,7 @@ public:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pData_ == &emptyString_)
|
if (pData_ == &emptyString_)
|
||||||
{
|
{
|
||||||
Init(0, res_arg);
|
Init(0, res_arg);
|
||||||
}
|
}
|
||||||
|
@ -206,10 +206,10 @@ public:
|
||||||
{
|
{
|
||||||
const size_type sz = size();
|
const size_type sz = size();
|
||||||
|
|
||||||
void* p = realloc(pData_,
|
void* p = realloc(pData_,
|
||||||
sizeof(Data) + res_arg * sizeof(E));
|
sizeof(Data) + res_arg * sizeof(E));
|
||||||
if (!p) throw std::bad_alloc();
|
if (!p) throw std::bad_alloc();
|
||||||
|
|
||||||
if (p != pData_)
|
if (p != pData_)
|
||||||
{
|
{
|
||||||
pData_ = static_cast<Data*>(p);
|
pData_ = static_cast<Data*>(p);
|
||||||
|
@ -222,7 +222,7 @@ public:
|
||||||
template <class InputIterator>
|
template <class InputIterator>
|
||||||
void append(InputIterator b, InputIterator e)
|
void append(InputIterator b, InputIterator e)
|
||||||
{
|
{
|
||||||
const size_type
|
const size_type
|
||||||
sz = std::distance(b, e),
|
sz = std::distance(b, e),
|
||||||
neededCapacity = size() + sz;
|
neededCapacity = size() + sz;
|
||||||
if (capacity() < neededCapacity)
|
if (capacity() < neededCapacity)
|
||||||
|
@ -235,7 +235,7 @@ public:
|
||||||
std::copy(b, e, end());
|
std::copy(b, e, end());
|
||||||
pData_->pEnd_ += sz;
|
pData_->pEnd_ += sz;
|
||||||
}
|
}
|
||||||
|
|
||||||
void resize(size_type newSize, E fill)
|
void resize(size_type newSize, E fill)
|
||||||
{
|
{
|
||||||
const int delta = int(newSize - size());
|
const int delta = int(newSize - size());
|
||||||
|
@ -243,7 +243,7 @@ public:
|
||||||
|
|
||||||
if (delta > 0)
|
if (delta > 0)
|
||||||
{
|
{
|
||||||
if (newSize > capacity())
|
if (newSize > capacity())
|
||||||
{
|
{
|
||||||
reserve(newSize);
|
reserve(newSize);
|
||||||
}
|
}
|
||||||
|
@ -257,16 +257,16 @@ public:
|
||||||
{
|
{
|
||||||
std::swap(pData_, rhs.pData_);
|
std::swap(pData_, rhs.pData_);
|
||||||
}
|
}
|
||||||
|
|
||||||
const E* c_str() const
|
const E* c_str() const
|
||||||
{
|
{
|
||||||
if (pData_ != &emptyString_) *pData_->pEnd_ = E();
|
if (pData_ != &emptyString_) *pData_->pEnd_ = E();
|
||||||
return pData_->buffer_;
|
return pData_->buffer_;
|
||||||
}
|
}
|
||||||
|
|
||||||
const E* data() const
|
const E* data() const
|
||||||
{ return pData_->buffer_; }
|
{ return pData_->buffer_; }
|
||||||
|
|
||||||
A get_allocator() const
|
A get_allocator() const
|
||||||
{ return A(); }
|
{ return A(); }
|
||||||
};
|
};
|
||||||
|
@ -274,9 +274,9 @@ public:
|
||||||
template <typename E, class A>
|
template <typename E, class A>
|
||||||
const typename SimpleStringStorage<E, A>::Data
|
const typename SimpleStringStorage<E, A>::Data
|
||||||
SimpleStringStorage<E, A>::emptyString_;
|
SimpleStringStorage<E, A>::emptyString_;
|
||||||
//{
|
//{
|
||||||
// const_cast<E*>(SimpleStringStorage<E, A>::emptyString_.buffer_),
|
// const_cast<E*>(SimpleStringStorage<E, A>::emptyString_.buffer_),
|
||||||
// const_cast<E*>(SimpleStringStorage<E, A>::emptyString_.buffer_),
|
// const_cast<E*>(SimpleStringStorage<E, A>::emptyString_.buffer_),
|
||||||
// { E() }
|
// { E() }
|
||||||
//};
|
//};
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ class StoragePolicy
|
||||||
typedef @ const_iterator;
|
typedef @ const_iterator;
|
||||||
typedef A allocator_type;
|
typedef A allocator_type;
|
||||||
typedef @ size_type;
|
typedef @ size_type;
|
||||||
|
|
||||||
StoragePolicy(const StoragePolicy& s);
|
StoragePolicy(const StoragePolicy& s);
|
||||||
StoragePolicy(const A&);
|
StoragePolicy(const A&);
|
||||||
StoragePolicy(const E* s, size_type len, const A&);
|
StoragePolicy(const E* s, size_type len, const A&);
|
||||||
|
@ -37,7 +37,7 @@ class StoragePolicy
|
||||||
const_iterator begin() const;
|
const_iterator begin() const;
|
||||||
iterator end();
|
iterator end();
|
||||||
const_iterator end() const;
|
const_iterator end() const;
|
||||||
|
|
||||||
size_type size() const;
|
size_type size() const;
|
||||||
size_type max_size() const;
|
size_type max_size() const;
|
||||||
size_type capacity() const;
|
size_type capacity() const;
|
||||||
|
@ -45,17 +45,17 @@ class StoragePolicy
|
||||||
void reserve(size_type res_arg);
|
void reserve(size_type res_arg);
|
||||||
|
|
||||||
void append(const E* s, size_type sz);
|
void append(const E* s, size_type sz);
|
||||||
|
|
||||||
template <class InputIterator>
|
template <class InputIterator>
|
||||||
void append(InputIterator b, InputIterator e);
|
void append(InputIterator b, InputIterator e);
|
||||||
|
|
||||||
void resize(size_type newSize, E fill);
|
void resize(size_type newSize, E fill);
|
||||||
|
|
||||||
void swap(StoragePolicy& rhs);
|
void swap(StoragePolicy& rhs);
|
||||||
|
|
||||||
const E* c_str() const;
|
const E* c_str() const;
|
||||||
const E* data() const;
|
const E* data() const;
|
||||||
|
|
||||||
A get_allocator() const;
|
A get_allocator() const;
|
||||||
};
|
};
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -87,13 +87,13 @@ public: // protected:
|
||||||
typedef A allocator_type;
|
typedef A allocator_type;
|
||||||
typedef typename A::size_type size_type;
|
typedef typename A::size_type size_type;
|
||||||
typedef typename A::reference reference;
|
typedef typename A::reference reference;
|
||||||
|
|
||||||
VectorStringStorage(const VectorStringStorage& s) : base(s)
|
VectorStringStorage(const VectorStringStorage& s) : base(s)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
VectorStringStorage(const A& a) : base(1, value_type(), a)
|
VectorStringStorage(const A& a) : base(1, value_type(), a)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
VectorStringStorage(const value_type* s, size_type len, const A& a)
|
VectorStringStorage(const value_type* s, size_type len, const A& a)
|
||||||
: base(a)
|
: base(a)
|
||||||
{
|
{
|
||||||
|
@ -109,26 +109,26 @@ public: // protected:
|
||||||
// Terminating zero
|
// Terminating zero
|
||||||
base::back() = value_type();
|
base::back() = value_type();
|
||||||
}
|
}
|
||||||
|
|
||||||
VectorStringStorage& operator=(const VectorStringStorage& rhs)
|
VectorStringStorage& operator=(const VectorStringStorage& rhs)
|
||||||
{
|
{
|
||||||
base& v = *this;
|
base& v = *this;
|
||||||
v = rhs;
|
v = rhs;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
iterator begin()
|
iterator begin()
|
||||||
{ return base::begin(); }
|
{ return base::begin(); }
|
||||||
|
|
||||||
const_iterator begin() const
|
const_iterator begin() const
|
||||||
{ return base::begin(); }
|
{ return base::begin(); }
|
||||||
|
|
||||||
iterator end()
|
iterator end()
|
||||||
{ return base::end() - 1; }
|
{ return base::end() - 1; }
|
||||||
|
|
||||||
const_iterator end() const
|
const_iterator end() const
|
||||||
{ return base::end() - 1; }
|
{ return base::end() - 1; }
|
||||||
|
|
||||||
size_type size() const
|
size_type size() const
|
||||||
{ return base::size() - 1; }
|
{ return base::size() - 1; }
|
||||||
|
|
||||||
|
@ -139,11 +139,11 @@ public: // protected:
|
||||||
{ return base::capacity() - 1; }
|
{ return base::capacity() - 1; }
|
||||||
|
|
||||||
void reserve(size_type res_arg)
|
void reserve(size_type res_arg)
|
||||||
{
|
{
|
||||||
assert(res_arg < max_size());
|
assert(res_arg < max_size());
|
||||||
base::reserve(res_arg + 1);
|
base::reserve(res_arg + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class ForwardIterator>
|
template <class ForwardIterator>
|
||||||
void append(ForwardIterator b, ForwardIterator e)
|
void append(ForwardIterator b, ForwardIterator e)
|
||||||
{
|
{
|
||||||
|
@ -178,13 +178,13 @@ public: // protected:
|
||||||
|
|
||||||
void swap(VectorStringStorage& rhs)
|
void swap(VectorStringStorage& rhs)
|
||||||
{ base::swap(rhs); }
|
{ base::swap(rhs); }
|
||||||
|
|
||||||
const E* c_str() const
|
const E* c_str() const
|
||||||
{ return &*begin(); }
|
{ return &*begin(); }
|
||||||
|
|
||||||
const E* data() const
|
const E* data() const
|
||||||
{ return &*begin(); }
|
{ return &*begin(); }
|
||||||
|
|
||||||
A get_allocator() const
|
A get_allocator() const
|
||||||
{ return base::get_allocator(); }
|
{ return base::get_allocator(); }
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue