summaryrefslogtreecommitdiff
path: root/ace/SString.i
diff options
context:
space:
mode:
authorlevine <levine@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1996-10-21 21:41:34 +0000
committerlevine <levine@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1996-10-21 21:41:34 +0000
commita5fdebc5f6375078ec1763850a4ca23ec7fe6458 (patch)
treebcf0a25c3d45a209a6e3ac37b233a4812f29c732 /ace/SString.i
downloadATCD-a5fdebc5f6375078ec1763850a4ca23ec7fe6458.tar.gz
Initial revision
Diffstat (limited to 'ace/SString.i')
-rw-r--r--ace/SString.i141
1 files changed, 141 insertions, 0 deletions
diff --git a/ace/SString.i b/ace/SString.i
new file mode 100644
index 00000000000..c628f6d42ec
--- /dev/null
+++ b/ace/SString.i
@@ -0,0 +1,141 @@
+/* -*- C++ -*- */
+// $Id$
+
+// SString.i
+
+// Return the <index'th> character in the string.
+
+ACE_INLINE char
+ACE_CString::operator[] (size_t index) const
+{
+ ACE_TRACE ("ACE_CString::operator[]");
+ return this->rep_[index];
+}
+
+// Get a copy of the underlying representation.
+
+ACE_INLINE char *
+ACE_CString::rep (void) const
+{
+ ACE_TRACE ("ACE_CString::rep");
+
+ char *new_string;
+ ACE_NEW_RETURN (new_string, char[this->len_ + 1], 0);
+ ACE_OS::strcpy (new_string, this->rep_);
+
+ return new_string;
+}
+
+// Comparison operator.
+
+ACE_INLINE int
+ACE_CString::operator== (const ACE_CString &s) const
+{
+ ACE_TRACE ("ACE_CString::operator==");
+ return this->len_ == s.len_
+ && ACE_OS::strcmp (this->rep_, s.rep_) == 0;
+}
+
+// Comparison operator.
+
+ACE_INLINE int
+ACE_CString::operator!= (const ACE_CString &s) const
+{
+ ACE_TRACE ("ACE_CString::operator!=");
+ return !(*this == s);
+}
+
+// Return the <index'th> character in the string.
+
+ACE_INLINE char
+ACE_SString::operator[] (size_t index) const
+{
+ ACE_TRACE ("ACE_SString::operator[]");
+ return this->rep_[index];
+}
+
+// Get the underlying pointer (does not make a copy, so beware!).
+
+ACE_INLINE char *
+ACE_SString::rep (void) const
+{
+ ACE_TRACE ("ACE_SString::rep");
+ return this->rep_;
+}
+
+// Comparison operator.
+
+ACE_INLINE int
+ACE_SString::operator== (const ACE_SString &s) const
+{
+ ACE_TRACE ("ACE_SString::operator==");
+ return this->len_ == s.len_
+ && ACE_OS::strcmp (this->rep_, s.rep_) == 0;
+}
+
+// Comparison operator.
+
+ACE_INLINE int
+ACE_SString::operator!= (const ACE_SString &s) const
+{
+ ACE_TRACE ("ACE_SString::operator!=");
+ return !(*this == s);
+}
+
+// Get a copy of the underlying representation.
+
+ACE_INLINE ACE_USHORT16 *
+ACE_WString::rep (void) const
+{
+ ACE_TRACE ("ACE_WString::rep");
+ if (this->len_ <= 0)
+ return 0;
+ else
+ {
+ ACE_USHORT16 *t;
+ ACE_NEW_RETURN (t, ACE_USHORT16[this->len_ + 1], 0);
+ ACE_OS::memcpy (t, this->rep_, this->len_ * sizeof (ACE_USHORT16));
+
+ // null terminate
+ t[this->len_] = 0;
+
+ return t;
+ }
+}
+
+// Get at the underlying representation directly!
+
+ACE_INLINE ACE_USHORT16 *
+ACE_WString::fast_rep (void) const
+{
+ return this->rep_;
+}
+
+// Comparison operator.
+
+ACE_INLINE int
+ACE_WString::operator== (const ACE_WString &s) const
+{
+ ACE_TRACE ("ACE_WString::operator==");
+ return this->len_ == s.len_
+ && ACE_OS::memcmp ((const void *) this->rep_, (const void *) s.rep_,
+ this->len_ * sizeof (ACE_USHORT16)) == 0;
+}
+
+// Comparison operator.
+
+ACE_INLINE int
+ACE_WString::operator!= (const ACE_WString &s) const
+{
+ ACE_TRACE ("ACE_WString::operator!=");
+ return !(*this == s);
+}
+
+// Return the <index'th> character in the string.
+
+ACE_INLINE ACE_USHORT16
+ACE_WString::operator[] (size_t index) const
+{
+ ACE_TRACE ("ACE_WString::operator[]");
+ return this->rep_[index];
+}