aboutsummaryrefslogtreecommitdiff
path: root/dep/ACE_wrappers/ace/SString.cpp
diff options
context:
space:
mode:
authormaximius <none@none>2009-10-17 15:35:07 -0700
committermaximius <none@none>2009-10-17 15:35:07 -0700
commit26b5e033ffde3d161382fc9addbfa99738379641 (patch)
treea344f369ca32945f787a02dee35c3dbe342bed7e /dep/ACE_wrappers/ace/SString.cpp
parentf21f47005dcb6b76e1abc9f35fbcd03eed191bff (diff)
*Massive cleanup (\n\n -> \n, *\n -> \n, cleanup for(...) to for (...), and some other cleanups by hand)
*Fix a possible crash in Spell::DoAllEffectOnTarget --HG-- branch : trunk
Diffstat (limited to 'dep/ACE_wrappers/ace/SString.cpp')
-rw-r--r--dep/ACE_wrappers/ace/SString.cpp95
1 files changed, 0 insertions, 95 deletions
diff --git a/dep/ACE_wrappers/ace/SString.cpp b/dep/ACE_wrappers/ace/SString.cpp
index 9548a4e6f38..7a78334547c 100644
--- a/dep/ACE_wrappers/ace/SString.cpp
+++ b/dep/ACE_wrappers/ace/SString.cpp
@@ -1,5 +1,4 @@
// $Id: SString.cpp 80826 2008-03-04 14:51:23Z wotte $
-
#include "ace/Malloc_T.h"
#include "ace/OS_Memory.h"
#if !defined (ACE_HAS_WINCE)
@@ -9,26 +8,20 @@
#include "ace/Auto_Ptr.h"
#include "ace/OS_NS_string.h"
#include "ace/Numeric_Limits.h"
-
#if !defined (ACE_LACKS_IOSTREAM_TOTALLY)
// FUZZ: disable check_for_streams_include
# include "ace/streams.h"
#endif /* ! ACE_LACKS_IOSTREAM_TOTALLY */
-
#if !defined (__ACE_INLINE__)
#include "ace/SString.inl"
#endif /* __ACE_INLINE__ */
-
ACE_RCSID (ace,
SString,
"SString.cpp,v 4.61 2001/03/04 00:55:30 brunsch Exp")
-
// ************************************************************
-
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
-
#if !defined (ACE_LACKS_IOSTREAM_TOTALLY)
ACE_OSTREAM_TYPE &
operator<< (ACE_OSTREAM_TYPE &os, const ACE_CString &cs)
@@ -37,7 +30,6 @@ operator<< (ACE_OSTREAM_TYPE &os, const ACE_CString &cs)
os << cs.fast_rep ();
return os;
}
-
ACE_OSTREAM_TYPE &
operator<< (ACE_OSTREAM_TYPE &os, const ACE_WString &ws)
{
@@ -51,7 +43,6 @@ operator<< (ACE_OSTREAM_TYPE &os, const ACE_WString &ws)
#endif
return os;
}
-
ACE_OSTREAM_TYPE &
operator<< (ACE_OSTREAM_TYPE &os, const ACE_SString &ss)
{
@@ -60,9 +51,7 @@ operator<< (ACE_OSTREAM_TYPE &os, const ACE_SString &ss)
return os;
}
#endif /* !ACE_LACKS_IOSTREAM_TOTALLY */
-
// *****************************************************************
-
char *
ACE_NS_WString::char_rep (void) const
{
@@ -72,21 +61,17 @@ ACE_NS_WString::char_rep (void) const
else
{
char *t = 0;
-
ACE_NEW_RETURN (t,
char[this->len_ + 1],
0);
-
for (size_type i = 0; i < this->len_; ++i)
// Note that this cast may lose data if wide chars are
// actually used!
t[i] = char (this->rep_[i]);
-
t[this->len_] = '\0';
return t;
}
}
-
ACE_USHORT16 *
ACE_NS_WString::ushort_rep (void) const
{
@@ -96,33 +81,26 @@ ACE_NS_WString::ushort_rep (void) const
else
{
ACE_USHORT16 *t = 0;
-
ACE_NEW_RETURN (t,
ACE_USHORT16[this->len_ + 1],
0);
-
for (size_type i = 0; i < this->len_; ++i)
// Note that this cast may lose data if wide chars are
// actually used!
t[i] = (ACE_USHORT16)this->rep_[i];
-
t[this->len_] = 0;
return t;
}
}
-
ACE_NS_WString::ACE_NS_WString (const char *s,
ACE_Allocator *alloc)
: ACE_WString (alloc)
{
if (s == 0)
return;
-
this->len_ = this->buf_len_ = ACE_OS::strlen (s);
-
if (this->buf_len_ == 0)
return;
-
ACE_ALLOCATOR (this->rep_,
(ACE_WSTRING_TYPE *)
this->allocator_->malloc ((this->buf_len_ + 1) *
@@ -131,7 +109,6 @@ ACE_NS_WString::ACE_NS_WString (const char *s,
for (size_type i = 0; i <= this->buf_len_; ++i)
this->rep_[i] = s[i];
}
-
#if defined (ACE_WSTRING_HAS_USHORT_SUPPORT)
ACE_NS_WString::ACE_NS_WString (const ACE_USHORT16 *s,
size_type len,
@@ -140,12 +117,9 @@ ACE_NS_WString::ACE_NS_WString (const ACE_USHORT16 *s,
{
if (s == 0)
return;
-
this->buf_len_ = len;
-
if (this->buf_len_ == 0)
return;
-
ACE_ALLOCATOR (this->rep_,
(ACE_WSTRING_TYPE *)
this->allocator_->malloc ((this->buf_len_) *
@@ -155,14 +129,10 @@ ACE_NS_WString::ACE_NS_WString (const ACE_USHORT16 *s,
this->rep_[i] = s[i];
}
#endif /* ACE_WSTRING_HAS_USHORT_SUPPORT */
-
// *****************************************************************
-
ACE_SString::size_type const ACE_SString::npos =
ACE_Numeric_Limits<ACE_SString::size_type>::max ();
-
ACE_ALLOC_HOOK_DEFINE(ACE_SString)
-
void
ACE_SString::dump (void) const
{
@@ -170,69 +140,52 @@ ACE_SString::dump (void) const
ACE_TRACE ("ACE_SString::dump");
#endif /* ACE_HAS_DUMP */
}
-
// Copy constructor.
-
ACE_SString::ACE_SString (const ACE_SString &s)
: allocator_ (s.allocator_),
len_ (s.len_)
{
ACE_TRACE ("ACE_SString::ACE_SString");
-
if (this->allocator_ == 0)
this->allocator_ = ACE_Allocator::instance ();
-
this->rep_ = (char *) this->allocator_->malloc (s.len_ + 1);
ACE_OS::memcpy ((void *) this->rep_,
(const void *) s.rep_,
this->len_);
this->rep_[this->len_] = '\0';
}
-
// Default constructor.
-
ACE_SString::ACE_SString (ACE_Allocator *alloc)
: allocator_ (alloc),
len_ (0),
rep_ (0)
-
{
ACE_TRACE ("ACE_SString::ACE_SString");
-
if (this->allocator_ == 0)
this->allocator_ = ACE_Allocator::instance ();
-
this->len_ = 0;
this->rep_ = (char *) this->allocator_->malloc (this->len_ + 1);
this->rep_[this->len_] = '\0';
}
-
// Set the underlying pointer (does not copy memory).
-
void
ACE_SString::rep (char *s)
{
ACE_TRACE ("ACE_SString::rep");
-
this->rep_ = s;
-
if (s == 0)
this->len_ = 0;
else
this->len_ = ACE_OS::strlen (s);
}
-
// Constructor that actually copies memory.
-
ACE_SString::ACE_SString (const char *s,
ACE_Allocator *alloc)
: allocator_ (alloc)
{
ACE_TRACE ("ACE_SString::ACE_SString");
-
if (this->allocator_ == 0)
this->allocator_ = ACE_Allocator::instance ();
-
if (s == 0)
{
this->len_ = 0;
@@ -246,34 +199,27 @@ ACE_SString::ACE_SString (const char *s,
ACE_OS::strcpy (this->rep_, s);
}
}
-
ACE_SString::ACE_SString (char c,
ACE_Allocator *alloc)
: allocator_ (alloc)
{
ACE_TRACE ("ACE_SString::ACE_SString");
-
if (this->allocator_ == 0)
this->allocator_ = ACE_Allocator::instance ();
-
this->len_ = 1;
this->rep_ = (char *) this->allocator_->malloc (this->len_ + 1);
this->rep_[0] = c;
this->rep_[this->len_] = '\0';
}
-
// Constructor that actually copies memory.
-
ACE_SString::ACE_SString (const char *s,
size_type len,
ACE_Allocator *alloc)
: allocator_ (alloc)
{
ACE_TRACE ("ACE_SString::ACE_SString");
-
if (this->allocator_ == 0)
this->allocator_ = ACE_Allocator::instance ();
-
if (s == 0)
{
this->len_ = 0;
@@ -288,15 +234,12 @@ ACE_SString::ACE_SString (const char *s,
this->rep_[len] = '\0'; // Make sure to NUL terminate this!
}
}
-
// Assignment operator (does copy memory).
-
ACE_SString &
ACE_SString::operator= (const ACE_SString &s)
{
ACE_TRACE ("ACE_SString::operator=");
// Check for identify.
-
if (this != &s)
{
// Only reallocate if we don't have enough space...
@@ -308,34 +251,26 @@ ACE_SString::operator= (const ACE_SString &s)
this->len_ = s.len_;
ACE_OS::strcpy (this->rep_, s.rep_);
}
-
return *this;
}
-
// Return substring.
ACE_SString
ACE_SString::substring (size_type offset,
size_type length) const
{
size_t count = length;
-
// case 1. empty string
if (len_ == 0)
return ACE_SString ();
-
// case 2. start pos l
if (offset >= len_)
return ACE_SString ();
-
// get all remaining bytes
if (length == npos || count > (this->len_ - offset))
count = len_ - offset;
-
return ACE_SString (&rep_[offset], count, this->allocator_);
}
-
// ************************************************************
-
ACE_Tokenizer::ACE_Tokenizer (ACE_TCHAR *buffer)
: buffer_ (buffer),
index_ (0),
@@ -343,19 +278,16 @@ ACE_Tokenizer::ACE_Tokenizer (ACE_TCHAR *buffer)
delimiter_index_ (0)
{
}
-
int
ACE_Tokenizer::delimiter (ACE_TCHAR d)
{
if (delimiter_index_ == MAX_DELIMITERS)
return -1;
-
delimiters_[delimiter_index_].delimiter_ = d;
delimiters_[delimiter_index_].replace_ = 0;
delimiter_index_++;
return 0;
}
-
int
ACE_Tokenizer::delimiter_replace (ACE_TCHAR d,
ACE_TCHAR replacement)
@@ -370,17 +302,14 @@ ACE_Tokenizer::delimiter_replace (ACE_TCHAR d,
delimiters_[i].replace_ = 1;
return 0;
}
-
if (delimiter_index_ >= MAX_DELIMITERS)
return -1;
-
delimiters_[delimiter_index_].delimiter_ = d;
delimiters_[delimiter_index_].replacement_ = replacement;
delimiters_[delimiter_index_].replace_ = 1;
delimiter_index_++;
return 0;
}
-
int
ACE_Tokenizer::preserve_designators (ACE_TCHAR start,
ACE_TCHAR stop,
@@ -388,21 +317,18 @@ ACE_Tokenizer::preserve_designators (ACE_TCHAR start,
{
if (preserves_index_ == MAX_PRESERVES)
return -1;
-
preserves_[preserves_index_].start_ = start;
preserves_[preserves_index_].stop_ = stop;
preserves_[preserves_index_].strip_ = strip;
preserves_index_++;
return 0;
}
-
int
ACE_Tokenizer::is_delimiter (ACE_TCHAR d,
int &replace,
ACE_TCHAR &r)
{
replace = 0;
-
for (int x = 0; x < delimiter_index_; x++)
if (delimiters_[x].delimiter_ == d)
{
@@ -413,10 +339,8 @@ ACE_Tokenizer::is_delimiter (ACE_TCHAR d,
}
return 1;
}
-
return 0;
}
-
int
ACE_Tokenizer::is_preserve_designator (ACE_TCHAR start,
ACE_TCHAR &stop,
@@ -429,10 +353,8 @@ ACE_Tokenizer::is_preserve_designator (ACE_TCHAR start,
strip = preserves_[x].strip_;
return 1;
}
-
return 0;
}
-
ACE_TCHAR *
ACE_Tokenizer::next (void)
{
@@ -442,11 +364,9 @@ ACE_Tokenizer::next (void)
index_ = 0;
return 0;
}
-
ACE_TCHAR replacement = 0;
int replace;
ACE_TCHAR *next_token;
-
// Skip all leading delimiters.
for (;;)
{
@@ -457,7 +377,6 @@ ACE_Tokenizer::next (void)
index_ = 0;
return 0;
}
-
if (this->is_delimiter (buffer_[index_],
replace,
replacement))
@@ -465,11 +384,9 @@ ACE_Tokenizer::next (void)
else
break;
}
-
// When we reach this point, buffer_[index_] is a non-delimiter and
// not EOS - the start of our next_token.
next_token = buffer_ + index_;
-
// A preserved region is it's own token.
ACE_TCHAR stop;
int strip;
@@ -484,11 +401,9 @@ ACE_Tokenizer::next (void)
index_ = -1;
goto EXIT_LABEL;
}
-
if (buffer_[index_] == stop)
break;
}
-
if (strip)
{
// Skip start preserve designator.
@@ -498,16 +413,13 @@ ACE_Tokenizer::next (void)
// Increment to the next token.
index_++;
}
-
goto EXIT_LABEL;
}
-
// Step through finding the next delimiter or EOS.
for (;;)
{
// Advance pointer.
index_++;
-
// Check for delimiter.
if (this->is_delimiter (buffer_[index_],
replace,
@@ -516,18 +428,15 @@ ACE_Tokenizer::next (void)
// Replace the delimiter.
if (replace != 0)
buffer_[index_] = replacement;
-
// Move the pointer up and return.
index_++;
goto EXIT_LABEL;
}
-
// A preserve designator signifies the end of this token.
if (this->is_preserve_designator (buffer_[index_],
stop,
strip))
goto EXIT_LABEL;
-
// Check for end of string.
if (buffer_[index_] == '\0')
{
@@ -535,17 +444,13 @@ ACE_Tokenizer::next (void)
goto EXIT_LABEL;
}
}
-
EXIT_LABEL:
return next_token;
}
-
// *************************************************************
-
#if defined (ACE_HAS_EXPLICIT_STATIC_TEMPLATE_MEMBER_INSTANTIATION)
template char ACE_String_Base<char>::NULL_String_;
template ACE_WSTRING_TYPE ACE_String_Base<ACE_WSTRING_TYPE>::NULL_String_;
#endif /* ACE_HAS_EXPLICIT_STATIC_TEMPLATE_MEMBER_INSTANTIATION */
-
ACE_END_VERSIONED_NAMESPACE_DECL