You can subscribe to this list here.
| 2008 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(18) |
Dec
(18) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2009 |
Jan
(8) |
Feb
(8) |
Mar
|
Apr
(2) |
May
(8) |
Jun
(5) |
Jul
(7) |
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
(5) |
| 2010 |
Jan
|
Feb
(4) |
Mar
(8) |
Apr
(6) |
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2011 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2012 |
Jan
|
Feb
|
Mar
(39) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: <tbr...@us...> - 2012-03-20 17:14:47
|
Revision: 225
http://xmlwrapp.svn.sourceforge.net/xmlwrapp/?rev=225&view=rev
Author: tbrowder2
Date: 2012-03-20 17:14:41 +0000 (Tue, 20 Mar 2012)
Log Message:
-----------
replace gunichar with uint32_t
Modified Paths:
--------------
trunk/include/xmlwrappstring/xmlwrappstring.h
Modified: trunk/include/xmlwrappstring/xmlwrappstring.h
===================================================================
--- trunk/include/xmlwrappstring/xmlwrappstring.h 2012-03-20 17:00:59 UTC (rev 224)
+++ trunk/include/xmlwrappstring/xmlwrappstring.h 2012-03-20 17:14:41 UTC (rev 225)
@@ -85,7 +85,7 @@
{
public:
typedef std::bidirectional_iterator_tag iterator_category;
- typedef gunichar value_type;
+ typedef uint32_t value_type;
typedef std::string::difference_type difference_type;
typedef value_type reference;
typedef void pointer;
@@ -118,7 +118,7 @@
* but it might be useful as utility function if you prefer using
* std::string even for UTF-8 encoding.
*/
-gunichar get_unichar_from_std_iterator(std::string::const_iterator pos) G_GNUC_PURE;
+uint32_t get_unichar_from_std_iterator(std::string::const_iterator pos) G_GNUC_PURE;
/** xmlws::xmlwrappstring has much the same interface as std::string, but contains
@@ -199,9 +199,9 @@
typedef std::string::size_type size_type;
typedef std::string::difference_type difference_type;
- typedef gunichar value_type;
- typedef gunichar & reference;
- typedef const gunichar & const_reference;
+ typedef uint32_t value_type;
+ typedef uint32_t & reference;
+ typedef const uint32_t & const_reference;
typedef xmlwrappstring_Iterator<std::string::iterator> iterator;
typedef xmlwrappstring_Iterator<std::string::const_iterator> const_iterator;
@@ -228,7 +228,7 @@
#endif /* GLIBMM_HAVE_SUN_REVERSE_ITERATOR */
-#ifdef GLIBMM_HAVE_ALLOWS_STATIC_INLINE_NPOS
+#ifdef 1 // GLIBMM_HAVE_ALLOWS_STATIC_INLINE_NPOS
static GLIBMM_API const size_type npos = std::string::npos;
#else
//The IRIX MipsPro compiler says "The indicated constant value is not known",
@@ -284,7 +284,7 @@
* @param n Number of characters.
* @param uc UCS-4 code point to use.
*/
- xmlwrappstring(size_type n, gunichar uc);
+ xmlwrappstring(size_type n, uint32_t uc);
/*! Construct a xmlwrappstring as multiple characters.
* @param n Number of characters.
@@ -304,14 +304,14 @@
xmlwrappstring& operator=(const std::string& src);
xmlwrappstring& operator=(const char* src);
- xmlwrappstring& operator=(gunichar uc);
+ xmlwrappstring& operator=(uint32_t uc);
xmlwrappstring& operator=(char c);
xmlwrappstring& assign(const xmlwrappstring& src);
xmlwrappstring& assign(const xmlwrappstring& src, size_type i, size_type n);
xmlwrappstring& assign(const char* src, size_type n);
xmlwrappstring& assign(const char* src);
- xmlwrappstring& assign(size_type n, gunichar uc);
+ xmlwrappstring& assign(size_type n, uint32_t uc);
xmlwrappstring& assign(size_type n, char c);
template <class In> xmlwrappstring& assign(In pbegin, In pend);
@@ -321,16 +321,16 @@
xmlwrappstring& operator+=(const xmlwrappstring& src);
xmlwrappstring& operator+=(const char* src);
- xmlwrappstring& operator+=(gunichar uc);
+ xmlwrappstring& operator+=(uint32_t uc);
xmlwrappstring& operator+=(char c);
- void push_back(gunichar uc);
+ void push_back(uint32_t uc);
void push_back(char c);
xmlwrappstring& append(const xmlwrappstring& src);
xmlwrappstring& append(const xmlwrappstring& src, size_type i, size_type n);
xmlwrappstring& append(const char* src, size_type n);
xmlwrappstring& append(const char* src);
- xmlwrappstring& append(size_type n, gunichar uc);
+ xmlwrappstring& append(size_type n, uint32_t uc);
xmlwrappstring& append(size_type n, char c);
template <class In> xmlwrappstring& append(In pbegin, In pend);
@@ -342,12 +342,12 @@
xmlwrappstring& insert(size_type i, const xmlwrappstring& src, size_type i2, size_type n);
xmlwrappstring& insert(size_type i, const char* src, size_type n);
xmlwrappstring& insert(size_type i, const char* src);
- xmlwrappstring& insert(size_type i, size_type n, gunichar uc);
+ xmlwrappstring& insert(size_type i, size_type n, uint32_t uc);
xmlwrappstring& insert(size_type i, size_type n, char c);
- iterator insert(iterator p, gunichar uc);
+ iterator insert(iterator p, uint32_t uc);
iterator insert(iterator p, char c);
- void insert(iterator p, size_type n, gunichar uc);
+ void insert(iterator p, size_type n, uint32_t uc);
void insert(iterator p, size_type n, char c);
template <class In> void insert(iterator p, In pbegin, In pend);
@@ -359,13 +359,13 @@
xmlwrappstring& replace(size_type i, size_type n, const xmlwrappstring& src, size_type i2, size_type n2);
xmlwrappstring& replace(size_type i, size_type n, const char* src, size_type n2);
xmlwrappstring& replace(size_type i, size_type n, const char* src);
- xmlwrappstring& replace(size_type i, size_type n, size_type n2, gunichar uc);
+ xmlwrappstring& replace(size_type i, size_type n, size_type n2, uint32_t uc);
xmlwrappstring& replace(size_type i, size_type n, size_type n2, char c);
xmlwrappstring& replace(iterator pbegin, iterator pend, const xmlwrappstring& src);
xmlwrappstring& replace(iterator pbegin, iterator pend, const char* src, size_type n);
xmlwrappstring& replace(iterator pbegin, iterator pend, const char* src);
- xmlwrappstring& replace(iterator pbegin, iterator pend, size_type n, gunichar uc);
+ xmlwrappstring& replace(iterator pbegin, iterator pend, size_type n, uint32_t uc);
xmlwrappstring& replace(iterator pbegin, iterator pend, size_type n, char c);
template <class In> xmlwrappstring& replace(iterator pbegin, iterator pend, In pbegin2, In pend2);
@@ -442,13 +442,13 @@
size_type find(const xmlwrappstring& str, size_type i=0) const;
size_type find(const char* str, size_type i, size_type n) const;
size_type find(const char* str, size_type i=0) const;
- size_type find(gunichar uc, size_type i=0) const;
+ size_type find(uint32_t uc, size_type i=0) const;
size_type find(char c, size_type i=0) const;
size_type rfind(const xmlwrappstring& str, size_type i=npos) const;
size_type rfind(const char* str, size_type i, size_type n) const;
size_type rfind(const char* str, size_type i=npos) const;
- size_type rfind(gunichar uc, size_type i=npos) const;
+ size_type rfind(uint32_t uc, size_type i=npos) const;
size_type rfind(char c, size_type i=npos) const;
//! @}
@@ -458,25 +458,25 @@
size_type find_first_of(const xmlwrappstring& match, size_type i=0) const;
size_type find_first_of(const char* match, size_type i, size_type n) const;
size_type find_first_of(const char* match, size_type i=0) const;
- size_type find_first_of(gunichar uc, size_type i=0) const;
+ size_type find_first_of(uint32_t uc, size_type i=0) const;
size_type find_first_of(char c, size_type i=0) const;
size_type find_last_of(const xmlwrappstring& match, size_type i=npos) const;
size_type find_last_of(const char* match, size_type i, size_type n) const;
size_type find_last_of(const char* match, size_type i=npos) const;
- size_type find_last_of(gunichar uc, size_type i=npos) const;
+ size_type find_last_of(uint32_t uc, size_type i=npos) const;
size_type find_last_of(char c, size_type i=npos) const;
size_type find_first_not_of(const xmlwrappstring& match, size_type i=0) const;
size_type find_first_not_of(const char* match, size_type i, size_type n) const;
size_type find_first_not_of(const char* match, size_type i=0) const;
- size_type find_first_not_of(gunichar uc, size_type i=0) const;
+ size_type find_first_not_of(uint32_t uc, size_type i=0) const;
size_type find_first_not_of(char c, size_type i=0) const;
size_type find_last_not_of(const xmlwrappstring& match, size_type i=npos) const;
size_type find_last_not_of(const char* match, size_type i, size_type n) const;
size_type find_last_not_of(const char* match, size_type i=npos) const;
- size_type find_last_not_of(gunichar uc, size_type i=npos) const;
+ size_type find_last_not_of(uint32_t uc, size_type i=npos) const;
size_type find_last_not_of(char c, size_type i=npos) const;
//! @}
@@ -512,7 +512,7 @@
//! @name Change the string's size.
//! @{
- void resize(size_type n, gunichar uc);
+ void resize(size_type n, uint32_t uc);
void resize(size_type n, char c='\0');
//! @}
@@ -806,7 +806,7 @@
//The Tru64 compiler needs these partial specializations to be declared here,
//as well as defined later. That's probably correct. murrayc.
template <class In> struct SequenceToString<In, char>;
- template <class In> struct SequenceToString<In, gunichar>;
+ template <class In> struct SequenceToString<In, uint32_t>;
template <class T> class Stringify;
class FormatStream;
@@ -832,19 +832,19 @@
};
template <class In>
-struct xmlwrappstring::SequenceToString<In, gunichar> : public std::string
+struct xmlwrappstring::SequenceToString<In, uint32_t> : public std::string
{
SequenceToString(In pbegin, In pend);
};
template <>
-struct xmlwrappstring::SequenceToString<xmlws::xmlwrappstring::iterator, gunichar> : public std::string
+struct xmlwrappstring::SequenceToString<xmlws::xmlwrappstring::iterator, uint32_t> : public std::string
{
SequenceToString(xmlws::xmlwrappstring::iterator pbegin, xmlws::xmlwrappstring::iterator pend);
};
template <>
-struct xmlwrappstring::SequenceToString<xmlws::xmlwrappstring::const_iterator, gunichar> : public std::string
+struct xmlwrappstring::SequenceToString<xmlws::xmlwrappstring::const_iterator, uint32_t> : public std::string
{
SequenceToString(xmlws::xmlwrappstring::const_iterator pbegin, xmlws::xmlwrappstring::const_iterator pend);
};
@@ -1033,7 +1033,7 @@
{}
template <class In>
-xmlwrappstring::SequenceToString<In,gunichar>::SequenceToString(In pbegin, In pend)
+xmlwrappstring::SequenceToString<In,uint32_t>::SequenceToString(In pbegin, In pend)
{
char utf8_buf[6]; // stores a single UTF-8 character
@@ -1573,7 +1573,7 @@
}
/** @relates xmlws::xmlwrappstring */
-inline xmlwrappstring operator+(const xmlwrappstring& lhs, gunichar rhs)
+inline xmlwrappstring operator+(const xmlwrappstring& lhs, uint32_t rhs)
{
xmlwrappstring temp(lhs);
temp += rhs;
@@ -1581,7 +1581,7 @@
}
/** @relates xmlws::xmlwrappstring */
-inline xmlwrappstring operator+(gunichar lhs, const xmlwrappstring& rhs)
+inline xmlwrappstring operator+(uint32_t lhs, const xmlwrappstring& rhs)
{
xmlwrappstring temp(1, lhs);
temp += rhs;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tbr...@us...> - 2012-03-20 17:01:10
|
Revision: 224
http://xmlwrapp.svn.sourceforge.net/xmlwrapp/?rev=224&view=rev
Author: tbrowder2
Date: 2012-03-20 17:00:59 +0000 (Tue, 20 Mar 2012)
Log Message:
-----------
replace Glib namespace with xmlws
Modified Paths:
--------------
trunk/src/libxmlwrappstring/xmlwrappstring.cc
Modified: trunk/src/libxmlwrappstring/xmlwrappstring.cc
===================================================================
--- trunk/src/libxmlwrappstring/xmlwrappstring.cc 2012-03-20 16:55:55 UTC (rev 223)
+++ trunk/src/libxmlwrappstring/xmlwrappstring.cc 2012-03-20 17:00:59 UTC (rev 224)
@@ -212,7 +212,7 @@
} // anonymous namespace
-namespace Glib
+namespace xmlws
{
#ifndef GLIBMM_HAVE_ALLOWS_STATIC_INLINE_NPOS
@@ -1412,4 +1412,4 @@
#endif /* GLIBMM_HAVE_WIDE_STREAM */
-} // namespace Glib
+} // namespace xmlws
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tbr...@us...> - 2012-03-20 16:56:06
|
Revision: 223
http://xmlwrapp.svn.sourceforge.net/xmlwrapp/?rev=223&view=rev
Author: tbrowder2
Date: 2012-03-20 16:55:55 +0000 (Tue, 20 Mar 2012)
Log Message:
-----------
replace gunichar with uint32_t
Modified Paths:
--------------
trunk/src/libxmlwrappstring/xmlwrappstring.cc
Modified: trunk/src/libxmlwrappstring/xmlwrappstring.cc
===================================================================
--- trunk/src/libxmlwrappstring/xmlwrappstring.cc 2012-03-20 16:49:59 UTC (rev 222)
+++ trunk/src/libxmlwrappstring/xmlwrappstring.cc 2012-03-20 16:55:55 UTC (rev 223)
@@ -19,6 +19,7 @@
*/
#include <xmlwrappstring/xmlwrappstring.h>
+#include <boost/cstdint.hpp> // uint32_t
#include <algorithm>
#include <iostream>
@@ -33,14 +34,14 @@
using xmlws::xmlwrappstring;
-// Little helper to make the conversion from gunichar to UTF-8 a one-liner.
+// Little helper to make the conversion from uint32_t to UTF-8 a one-liner.
//
struct UnicharToUtf8
{
char buf[6];
xmlwrappstring::size_type len;
- explicit UnicharToUtf8(gunichar uc)
+ explicit UnicharToUtf8(uint32_t uc)
: len (g_unichar_to_utf8(uc, buf)) {}
};
@@ -147,11 +148,11 @@
return xmlwrappstring::npos;
long ucs4_match_size = 0;
- const xmlws::ScopedPtr<gunichar> ucs4_match
+ const xmlws::ScopedPtr<uint32_t> ucs4_match
(g_utf8_to_ucs4_fast(utf8_match, utf8_match_size, &ucs4_match_size));
- const gunichar *const match_begin = ucs4_match.get();
- const gunichar *const match_end = match_begin + ucs4_match_size;
+ const uint32_t *const match_begin = ucs4_match.get();
+ const uint32_t *const match_end = match_begin + ucs4_match_size;
const char *const str_begin = str.data();
const char *const str_end = str_begin + str.size();
@@ -160,7 +161,7 @@
pstr < str_end;
pstr = g_utf8_next_char(pstr))
{
- const gunichar *const pfound = std::find(match_begin, match_end, g_utf8_get_char(pstr));
+ const uint32_t *const pfound = std::find(match_begin, match_end, g_utf8_get_char(pstr));
if((pfound != match_end) != find_not_of)
return offset;
@@ -179,11 +180,11 @@
bool find_not_of)
{
long ucs4_match_size = 0;
- const xmlws::ScopedPtr<gunichar> ucs4_match
+ const xmlws::ScopedPtr<uint32_t> ucs4_match
(g_utf8_to_ucs4_fast(utf8_match, utf8_match_size, &ucs4_match_size));
- const gunichar *const match_begin = ucs4_match.get();
- const gunichar *const match_end = match_begin + ucs4_match_size;
+ const uint32_t *const match_begin = ucs4_match.get();
+ const uint32_t *const match_end = match_begin + ucs4_match_size;
const char *const str_begin = str.data();
const char* pstr = str_begin;
@@ -199,7 +200,7 @@
--pstr;
while((static_cast<unsigned char>(*pstr) & 0xC0u) == 0x80);
- const gunichar *const pfound = std::find(match_begin, match_end, g_utf8_get_char(pstr));
+ const uint32_t *const pfound = std::find(match_begin, match_end, g_utf8_get_char(pstr));
if((pfound != match_end) != find_not_of)
return g_utf8_pointer_to_offset(str_begin, pstr);
@@ -258,7 +259,7 @@
* register moves, the generated code is sufficiently close to the optimum
* with GCC 4.1.2 on x86_64.
*/
-gunichar get_unichar_from_std_iterator(std::string::const_iterator pos)
+uint32_t get_unichar_from_std_iterator(std::string::const_iterator pos)
{
unsigned int result = static_cast<unsigned char>(*pos);
@@ -312,7 +313,7 @@
string_ (src)
{}
-xmlwrappstring::xmlwrappstring(xmlwrappstring::size_type n, gunichar uc)
+xmlwrappstring::xmlwrappstring(xmlwrappstring::size_type n, uint32_t uc)
:
string_ ()
{
@@ -370,7 +371,7 @@
return *this;
}
-xmlwrappstring& xmlwrappstring::operator=(gunichar uc)
+xmlwrappstring& xmlwrappstring::operator=(uint32_t uc)
{
const UnicharToUtf8 conv (uc);
string_.assign(conv.buf, conv.len);
@@ -411,7 +412,7 @@
return *this;
}
-xmlwrappstring& xmlwrappstring::assign(xmlwrappstring::size_type n, gunichar uc)
+xmlwrappstring& xmlwrappstring::assign(xmlwrappstring::size_type n, uint32_t uc)
{
xmlwrappstring temp (n, uc);
string_.swap(temp.string_);
@@ -439,7 +440,7 @@
return *this;
}
-xmlwrappstring& xmlwrappstring::operator+=(gunichar uc)
+xmlwrappstring& xmlwrappstring::operator+=(uint32_t uc)
{
const UnicharToUtf8 conv (uc);
string_.append(conv.buf, conv.len);
@@ -455,7 +456,7 @@
/**** xmlws::xmlwrappstring::push_back() *******************************************/
-void xmlwrappstring::push_back(gunichar uc)
+void xmlwrappstring::push_back(uint32_t uc)
{
const UnicharToUtf8 conv (uc);
string_.append(conv.buf, conv.len);
@@ -494,7 +495,7 @@
return *this;
}
-xmlwrappstring& xmlwrappstring::append(xmlwrappstring::size_type n, gunichar uc)
+xmlwrappstring& xmlwrappstring::append(xmlwrappstring::size_type n, uint32_t uc)
{
string_.append(xmlwrappstring(n, uc).string_);
return *this;
@@ -535,7 +536,7 @@
return *this;
}
-xmlwrappstring& xmlwrappstring::insert(xmlwrappstring::size_type i, xmlwrappstring::size_type n, gunichar uc)
+xmlwrappstring& xmlwrappstring::insert(xmlwrappstring::size_type i, xmlwrappstring::size_type n, uint32_t uc)
{
string_.insert(utf8_byte_offset(string_, i), xmlwrappstring(n, uc).string_);
return *this;
@@ -547,7 +548,7 @@
return *this;
}
-xmlwrappstring::iterator xmlwrappstring::insert(xmlwrappstring::iterator p, gunichar uc)
+xmlwrappstring::iterator xmlwrappstring::insert(xmlwrappstring::iterator p, uint32_t uc)
{
const size_type offset = p.base() - string_.begin();
const UnicharToUtf8 conv (uc);
@@ -560,7 +561,7 @@
return iterator(string_.insert(p.base(), c));
}
-void xmlwrappstring::insert(xmlwrappstring::iterator p, xmlwrappstring::size_type n, gunichar uc)
+void xmlwrappstring::insert(xmlwrappstring::iterator p, xmlwrappstring::size_type n, uint32_t uc)
{
string_.insert(p.base() - string_.begin(), xmlwrappstring(n, uc).string_);
}
@@ -605,7 +606,7 @@
}
xmlwrappstring& xmlwrappstring::replace(xmlwrappstring::size_type i, xmlwrappstring::size_type n,
- xmlwrappstring::size_type n2, gunichar uc)
+ xmlwrappstring::size_type n2, uint32_t uc)
{
const Utf8SubstrBounds bounds (string_, i, n);
string_.replace(bounds.i, bounds.n, xmlwrappstring(n2, uc).string_);
@@ -640,7 +641,7 @@
}
xmlwrappstring& xmlwrappstring::replace(xmlwrappstring::iterator pbegin, xmlwrappstring::iterator pend,
- xmlwrappstring::size_type n, gunichar uc)
+ xmlwrappstring::size_type n, uint32_t uc)
{
string_.replace(pbegin.base(), pend.base(), xmlwrappstring(n, uc).string_);
return *this;
@@ -800,7 +801,7 @@
return utf8_char_offset(string_, string_.find(str, utf8_byte_offset(string_, i)));
}
-xmlwrappstring::size_type xmlwrappstring::find(gunichar uc, xmlwrappstring::size_type i) const
+xmlwrappstring::size_type xmlwrappstring::find(uint32_t uc, xmlwrappstring::size_type i) const
{
const UnicharToUtf8 conv (uc);
return utf8_char_offset(string_, string_.find(conv.buf, utf8_byte_offset(string_, i), conv.len));
@@ -831,7 +832,7 @@
return utf8_char_offset(string_, string_.rfind(str, utf8_byte_offset(string_, i)));
}
-xmlwrappstring::size_type xmlwrappstring::rfind(gunichar uc, xmlwrappstring::size_type i) const
+xmlwrappstring::size_type xmlwrappstring::rfind(uint32_t uc, xmlwrappstring::size_type i) const
{
const UnicharToUtf8 conv (uc);
return utf8_char_offset(string_, string_.rfind(conv.buf, utf8_byte_offset(string_, i), conv.len));
@@ -861,7 +862,7 @@
return utf8_find_first_of(string_, i, match, -1, false);
}
-xmlwrappstring::size_type xmlwrappstring::find_first_of(gunichar uc, xmlwrappstring::size_type i) const
+xmlwrappstring::size_type xmlwrappstring::find_first_of(uint32_t uc, xmlwrappstring::size_type i) const
{
return find(uc, i);
}
@@ -890,7 +891,7 @@
return utf8_find_last_of(string_, i, match, -1, false);
}
-xmlwrappstring::size_type xmlwrappstring::find_last_of(gunichar uc, xmlwrappstring::size_type i) const
+xmlwrappstring::size_type xmlwrappstring::find_last_of(uint32_t uc, xmlwrappstring::size_type i) const
{
return rfind(uc, i);
}
@@ -922,7 +923,7 @@
// Unfortunately, all of the find_*_not_of() methods for single
// characters need their own special implementation.
//
-xmlwrappstring::size_type xmlwrappstring::find_first_not_of(gunichar uc, xmlwrappstring::size_type i) const
+xmlwrappstring::size_type xmlwrappstring::find_first_not_of(uint32_t uc, xmlwrappstring::size_type i) const
{
const size_type bi = utf8_byte_offset(string_, i);
if(bi != npos)
@@ -982,7 +983,7 @@
// Unfortunately, all of the find_*_not_of() methods for single
// characters need their own special implementation.
//
-xmlwrappstring::size_type xmlwrappstring::find_last_not_of(gunichar uc, xmlwrappstring::size_type i) const
+xmlwrappstring::size_type xmlwrappstring::find_last_not_of(uint32_t uc, xmlwrappstring::size_type i) const
{
const char *const pbegin = string_.data();
const char *const pend = pbegin + string_.size();
@@ -1051,7 +1052,7 @@
return string_.max_size();
}
-void xmlwrappstring::resize(xmlwrappstring::size_type n, gunichar uc)
+void xmlwrappstring::resize(xmlwrappstring::size_type n, uint32_t uc)
{
const size_type size_now = size();
if(n < size_now)
@@ -1232,13 +1233,13 @@
/**** xmlws::xmlwrappstring::SequenceToString **************************************/
-xmlwrappstring::SequenceToString<xmlws::xmlwrappstring::iterator,gunichar>
+xmlwrappstring::SequenceToString<xmlws::xmlwrappstring::iterator,uint32_t>
::SequenceToString(xmlws::xmlwrappstring::iterator pbegin, xmlws::xmlwrappstring::iterator pend)
:
std::string(pbegin.base(), pend.base())
{}
-xmlwrappstring::SequenceToString<xmlws::xmlwrappstring::const_iterator,gunichar>
+xmlwrappstring::SequenceToString<xmlws::xmlwrappstring::const_iterator,uint32_t>
::SequenceToString(xmlws::xmlwrappstring::const_iterator pbegin, xmlws::xmlwrappstring::const_iterator pend)
:
std::string(pbegin.base(), pend.base())
@@ -1264,12 +1265,12 @@
# if defined(__STDC_ISO_10646__) && SIZEOF_WCHAR_T == 4
// Avoid going through iconv if wchar_t always contains UCS-4.
glong n_bytes = 0;
- const ScopedPtr<char> buf (g_ucs4_to_utf8(reinterpret_cast<const gunichar*>(str.data()),
+ const ScopedPtr<char> buf (g_ucs4_to_utf8(reinterpret_cast<const uint32_t*>(str.data()),
str.size(), 0, &n_bytes, &error));
# elif defined(G_OS_WIN32) && SIZEOF_WCHAR_T == 2
// Avoid going through iconv if wchar_t always contains UTF-16.
glong n_bytes = 0;
- const ScopedPtr<char> buf (g_utf16_to_utf8(reinterpret_cast<const gunichar2*>(str.data()),
+ const ScopedPtr<char> buf (g_utf16_to_utf8(reinterpret_cast<const uint32_t2*>(str.data()),
str.size(), 0, &n_bytes, &error));
# else
gsize n_bytes = 0;
@@ -1348,12 +1349,12 @@
#if defined(__STDC_ISO_10646__) && SIZEOF_WCHAR_T == 4
// Avoid going through iconv if wchar_t always contains UCS-4.
glong n_bytes = 0;
- const ScopedPtr<char> buf (g_ucs4_to_utf8(reinterpret_cast<const gunichar*>(wstr.data()),
+ const ScopedPtr<char> buf (g_ucs4_to_utf8(reinterpret_cast<const uint32_t*>(wstr.data()),
wstr.size(), 0, &n_bytes, &error));
#elif defined(G_OS_WIN32) && SIZEOF_WCHAR_T == 2
// Avoid going through iconv if wchar_t always contains UTF-16.
glong n_bytes = 0;
- const ScopedPtr<char> buf (g_utf16_to_utf8(reinterpret_cast<const gunichar2*>(wstr.data()),
+ const ScopedPtr<char> buf (g_utf16_to_utf8(reinterpret_cast<const uint32_t2*>(wstr.data()),
wstr.size(), 0, &n_bytes, &error));
#else
gsize n_bytes = 0;
@@ -1378,11 +1379,11 @@
#if defined(__STDC_ISO_10646__) && SIZEOF_WCHAR_T == 4
// Avoid going through iconv if wchar_t always contains UCS-4.
- const ScopedPtr<gunichar> buf (g_utf8_to_ucs4(utf8_string.raw().data(),
+ const ScopedPtr<uint32_t> buf (g_utf8_to_ucs4(utf8_string.raw().data(),
utf8_string.raw().size(), 0, 0, &error));
#elif defined(G_OS_WIN32) && SIZEOF_WCHAR_T == 2
// Avoid going through iconv if wchar_t always contains UTF-16.
- const ScopedPtr<gunichar2> buf (g_utf8_to_utf16(utf8_string.raw().data(),
+ const ScopedPtr<uint32_t2> buf (g_utf8_to_utf16(utf8_string.raw().data(),
utf8_string.raw().size(), 0, 0, &error));
#else
// TODO: For some reason the conversion from UTF-8 to WCHAR_T doesn't work
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tbr...@us...> - 2012-03-20 16:50:12
|
Revision: 222
http://xmlwrapp.svn.sourceforge.net/xmlwrapp/?rev=222&view=rev
Author: tbrowder2
Date: 2012-03-20 16:49:59 +0000 (Tue, 20 Mar 2012)
Log Message:
-----------
change ustring to xmlwrappstring; change Glib namespace to xmlws namespace; remove glib headers; add utf8 headers
Modified Paths:
--------------
trunk/include/xmlwrappstring/xmlwrappstring.h
trunk/src/libxmlwrappstring/xmlwrappstring.cc
Modified: trunk/include/xmlwrappstring/xmlwrappstring.h
===================================================================
--- trunk/include/xmlwrappstring/xmlwrappstring.h 2012-03-20 16:18:57 UTC (rev 221)
+++ trunk/include/xmlwrappstring/xmlwrappstring.h 2012-03-20 16:49:59 UTC (rev 222)
@@ -20,10 +20,6 @@
#include "utf8.h"
-#include <glibmmconfig.h>
-#include <glibmm/unicode.h>
-#include <glib.h>
-
#include <iosfwd>
#include <iterator>
#include <sstream>
@@ -32,7 +28,7 @@
#include <cstddef> /* for ptrdiff_t */
#endif
-namespace Glib
+namespace xmlws
{
#ifndef DOXYGEN_SHOULD_SKIP_THIS
@@ -72,7 +68,7 @@
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
-/** The iterator type of Glib::ustring.
+/** The iterator type of xmlws::xmlwrappstring.
* Note this is not a random access iterator but a bidirectional one,
* since all index operations need to iterate over the UTF-8 data. Use
* std::advance() to move to a certain position. However, all of the
@@ -85,7 +81,7 @@
* pointing into the same string.
*/
template <class T>
-class ustring_Iterator
+class xmlwrappstring_Iterator
{
public:
typedef std::bidirectional_iterator_tag iterator_category;
@@ -94,17 +90,17 @@
typedef value_type reference;
typedef void pointer;
- inline ustring_Iterator();
- inline ustring_Iterator(const ustring_Iterator<std::string::iterator>& other);
+ inline xmlwrappstring_Iterator();
+ inline xmlwrappstring_Iterator(const xmlwrappstring_Iterator<std::string::iterator>& other);
inline value_type operator*() const;
- inline ustring_Iterator<T> & operator++();
- inline const ustring_Iterator<T> operator++(int);
- inline ustring_Iterator<T> & operator--();
- inline const ustring_Iterator<T> operator--(int);
+ inline xmlwrappstring_Iterator<T> & operator++();
+ inline const xmlwrappstring_Iterator<T> operator++(int);
+ inline xmlwrappstring_Iterator<T> & operator--();
+ inline const xmlwrappstring_Iterator<T> operator--(int);
- explicit inline ustring_Iterator(T pos);
+ explicit inline xmlwrappstring_Iterator(T pos);
inline T base() const;
private:
@@ -118,25 +114,25 @@
* position, depending on the UTF-8 character width. You have to make
* sure the source contains at least one valid UTF-8 character.
*
- * This is mainly used by the implementation of Glib::ustring::iterator,
+ * This is mainly used by the implementation of xmlws::xmlwrappstring::iterator,
* but it might be useful as utility function if you prefer using
* std::string even for UTF-8 encoding.
*/
gunichar get_unichar_from_std_iterator(std::string::const_iterator pos) G_GNUC_PURE;
-/** Glib::ustring has much the same interface as std::string, but contains
+/** xmlws::xmlwrappstring has much the same interface as std::string, but contains
* %Unicode characters encoded as UTF-8.
*
* @par About UTF-8 and ASCII
* @par
* The standard character set ANSI_X3.4-1968 -- more commonly known as
* ASCII -- is a subset of UTF-8. So, if you want to, you can use
- * Glib::ustring without even thinking about UTF-8.
+ * xmlws::xmlwrappstring without even thinking about UTF-8.
* @par
* Whenever ASCII is mentioned in this manual, we mean the @em real ASCII
* (i.e. as defined in ANSI_X3.4-1968), which contains only 7-bit characters.
- * Glib::ustring can @em not be used with ASCII-compatible extended 8-bit
+ * xmlws::xmlwrappstring can @em not be used with ASCII-compatible extended 8-bit
* charsets like ISO-8859-1. It's a good idea to avoid string literals
* containing non-ASCII characters (e.g. German umlauts) in source code,
* or at least you should use UTF-8 literals.
@@ -144,12 +140,12 @@
* You can find a detailed UTF-8 and %Unicode FAQ here:
* http://www.cl.cam.ac.uk/~mgk25/unicode.html
*
- * @par Glib::ustring vs. std::string
+ * @par xmlws::xmlwrappstring vs. std::string
* @par
- * Glib::ustring has implicit type conversions to and from std::string.
+ * xmlws::xmlwrappstring has implicit type conversions to and from std::string.
* These conversions do @em not convert to/from the current locale (see
- * Glib::locale_from_utf8() and Glib::locale_to_utf8() if you need that). You
- * can always use std::string instead of Glib::ustring -- however, using
+ * xmlws::locale_from_utf8() and xmlws::locale_to_utf8() if you need that). You
+ * can always use std::string instead of xmlws::xmlwrappstring -- however, using
* std::string with multi-byte characters is quite hard. For instance,
* <tt>std::string::operator[]</tt> might return a byte in the middle of a
* character, and <tt>std::string::length()</tt> returns the number of bytes
@@ -160,12 +156,12 @@
* that std::wstring is not a UTF-8 string class because it contains only
* fixed-width characters (where width could be 32, 16, or even 8 bits).
*
- * @par Glib::ustring and stream input/output
+ * @par xmlws::xmlwrappstring and stream input/output
* @par
* The stream I/O operators, that is operator<<() and operator>>(), perform
* implicit charset conversion to/from the current locale. If that's not
* what you intented (e.g. when writing to a configuration file that should
- * always be UTF-8 encoded) use ustring::raw() to override this behaviour.
+ * always be UTF-8 encoded) use xmlwrappstring::raw() to override this behaviour.
* @par
* If you're using std::ostringstream to build strings for display in the
* user interface, you must convert the result back to UTF-8 as shown below:
@@ -173,31 +169,31 @@
* std::ostringstream output;
* output.imbue(std::locale("")); // use the user's locale for this stream
* output << percentage << " % done";
- * label->set_text(Glib::locale_to_utf8(output.str()));
+ * label->set_text(xmlws::locale_to_utf8(output.str()));
* @endcode
*
* @par Formatted output and internationalization
* @par
- * The methods ustring::compose() and ustring::format() provide a convenient
+ * The methods xmlwrappstring::compose() and xmlwrappstring::format() provide a convenient
* and powerful alternative to string streams, as shown in the example below.
* Refer to the method documentation of compose() and format() for details.
* @code
- * using Glib::ustring;
+ * using xmlws::xmlwrappstring;
*
- * ustring message = ustring::compose("%1 is lower than 0x%2.",
- * 12, ustring::format(std::hex, 16));
+ * xmlwrappstring message = xmlwrappstring::compose("%1 is lower than 0x%2.",
+ * 12, xmlwrappstring::format(std::hex, 16));
* @endcode
*
* @par Implementation notes
* @par
- * Glib::ustring does not inherit from std::string, because std::string was
+ * xmlws::xmlwrappstring does not inherit from std::string, because std::string was
* intended to be a final class. For instance, it does not have a virtual
* destructor. Also, a HAS-A relationship is more appropriate because
- * ustring can't just enhance the std::string interface. Rather, it has to
+ * xmlwrappstring can't just enhance the std::string interface. Rather, it has to
* reimplement the interface so that all operations are based on characters
* instead of bytes.
*/
-class ustring
+class xmlwrappstring
{
public:
typedef std::string::size_type size_type;
@@ -207,8 +203,8 @@
typedef gunichar & reference;
typedef const gunichar & const_reference;
- typedef ustring_Iterator<std::string::iterator> iterator;
- typedef ustring_Iterator<std::string::const_iterator> const_iterator;
+ typedef xmlwrappstring_Iterator<std::string::iterator> iterator;
+ typedef xmlwrappstring_Iterator<std::string::const_iterator> const_iterator;
#ifndef GLIBMM_HAVE_SUN_REVERSE_ITERATOR
@@ -242,112 +238,112 @@
/*! Default constructor, which creates an empty string.
*/
- ustring();
+ xmlwrappstring();
- ~ustring();
+ ~xmlwrappstring();
- /*! Construct a ustring as a copy of another ustring.
+ /*! Construct a xmlwrappstring as a copy of another xmlwrappstring.
* @param other A source string.
*/
- ustring(const ustring& other);
+ xmlwrappstring(const xmlwrappstring& other);
/*! Assign the value of another string to this string.
* @param other A source string.
*/
- ustring& operator=(const ustring& other);
+ xmlwrappstring& operator=(const xmlwrappstring& other);
/*! Swap contents with another string.
* @param other String to swap with.
*/
- void swap(ustring& other);
+ void swap(xmlwrappstring& other);
- /*! Construct a ustring as a copy of another std::string.
+ /*! Construct a xmlwrappstring as a copy of another std::string.
* @param src A source <tt>std::string</tt> containing text encoded as UTF-8.
*/
- ustring(const std::string& src);
+ xmlwrappstring(const std::string& src);
- /*! Construct a ustring as a copy of a substring.
- * @param src %Source ustring.
+ /*! Construct a xmlwrappstring as a copy of a substring.
+ * @param src %Source xmlwrappstring.
* @param i Index of first character to copy from.
* @param n Number of UTF-8 characters to copy (defaults to copying the remainder).
*/
- ustring(const ustring& src, size_type i, size_type n=npos);
+ xmlwrappstring(const xmlwrappstring& src, size_type i, size_type n=npos);
- /*! Construct a ustring as a partial copy of a C string.
+ /*! Construct a xmlwrappstring as a partial copy of a C string.
* @param src %Source C string encoded as UTF-8.
* @param n Number of UTF-8 characters to copy.
*/
- ustring(const char* src, size_type n);
+ xmlwrappstring(const char* src, size_type n);
- /*! Construct a ustring as a copy of a C string.
+ /*! Construct a xmlwrappstring as a copy of a C string.
* @param src %Source C string encoded as UTF-8.
*/
- ustring(const char* src);
+ xmlwrappstring(const char* src);
- /*! Construct a ustring as multiple characters.
+ /*! Construct a xmlwrappstring as multiple characters.
* @param n Number of characters.
* @param uc UCS-4 code point to use.
*/
- ustring(size_type n, gunichar uc);
+ xmlwrappstring(size_type n, gunichar uc);
- /*! Construct a ustring as multiple characters.
+ /*! Construct a xmlwrappstring as multiple characters.
* @param n Number of characters.
* @param c ASCII character to use.
*/
- ustring(size_type n, char c);
+ xmlwrappstring(size_type n, char c);
- /*! Construct a ustring as a copy of a range.
+ /*! Construct a xmlwrappstring as a copy of a range.
* @param pbegin Start of range.
* @param pend End of range.
*/
- template <class In> ustring(In pbegin, In pend);
+ template <class In> xmlwrappstring(In pbegin, In pend);
//! @name Assign new contents.
//! @{
- ustring& operator=(const std::string& src);
- ustring& operator=(const char* src);
- ustring& operator=(gunichar uc);
- ustring& operator=(char c);
+ xmlwrappstring& operator=(const std::string& src);
+ xmlwrappstring& operator=(const char* src);
+ xmlwrappstring& operator=(gunichar uc);
+ xmlwrappstring& operator=(char c);
- ustring& assign(const ustring& src);
- ustring& assign(const ustring& src, size_type i, size_type n);
- ustring& assign(const char* src, size_type n);
- ustring& assign(const char* src);
- ustring& assign(size_type n, gunichar uc);
- ustring& assign(size_type n, char c);
- template <class In> ustring& assign(In pbegin, In pend);
+ xmlwrappstring& assign(const xmlwrappstring& src);
+ xmlwrappstring& assign(const xmlwrappstring& src, size_type i, size_type n);
+ xmlwrappstring& assign(const char* src, size_type n);
+ xmlwrappstring& assign(const char* src);
+ xmlwrappstring& assign(size_type n, gunichar uc);
+ xmlwrappstring& assign(size_type n, char c);
+ template <class In> xmlwrappstring& assign(In pbegin, In pend);
//! @}
//! @name Append to the string.
//! @{
- ustring& operator+=(const ustring& src);
- ustring& operator+=(const char* src);
- ustring& operator+=(gunichar uc);
- ustring& operator+=(char c);
+ xmlwrappstring& operator+=(const xmlwrappstring& src);
+ xmlwrappstring& operator+=(const char* src);
+ xmlwrappstring& operator+=(gunichar uc);
+ xmlwrappstring& operator+=(char c);
void push_back(gunichar uc);
void push_back(char c);
- ustring& append(const ustring& src);
- ustring& append(const ustring& src, size_type i, size_type n);
- ustring& append(const char* src, size_type n);
- ustring& append(const char* src);
- ustring& append(size_type n, gunichar uc);
- ustring& append(size_type n, char c);
- template <class In> ustring& append(In pbegin, In pend);
+ xmlwrappstring& append(const xmlwrappstring& src);
+ xmlwrappstring& append(const xmlwrappstring& src, size_type i, size_type n);
+ xmlwrappstring& append(const char* src, size_type n);
+ xmlwrappstring& append(const char* src);
+ xmlwrappstring& append(size_type n, gunichar uc);
+ xmlwrappstring& append(size_type n, char c);
+ template <class In> xmlwrappstring& append(In pbegin, In pend);
//! @}
//! @name Insert into the string.
//! @{
- ustring& insert(size_type i, const ustring& src);
- ustring& insert(size_type i, const ustring& src, size_type i2, size_type n);
- ustring& insert(size_type i, const char* src, size_type n);
- ustring& insert(size_type i, const char* src);
- ustring& insert(size_type i, size_type n, gunichar uc);
- ustring& insert(size_type i, size_type n, char c);
+ xmlwrappstring& insert(size_type i, const xmlwrappstring& src);
+ xmlwrappstring& insert(size_type i, const xmlwrappstring& src, size_type i2, size_type n);
+ xmlwrappstring& insert(size_type i, const char* src, size_type n);
+ xmlwrappstring& insert(size_type i, const char* src);
+ xmlwrappstring& insert(size_type i, size_type n, gunichar uc);
+ xmlwrappstring& insert(size_type i, size_type n, char c);
iterator insert(iterator p, gunichar uc);
iterator insert(iterator p, char c);
@@ -359,27 +355,27 @@
//! @name Replace sub-strings.
//! @{
- ustring& replace(size_type i, size_type n, const ustring& src);
- ustring& replace(size_type i, size_type n, const ustring& src, size_type i2, size_type n2);
- ustring& replace(size_type i, size_type n, const char* src, size_type n2);
- ustring& replace(size_type i, size_type n, const char* src);
- ustring& replace(size_type i, size_type n, size_type n2, gunichar uc);
- ustring& replace(size_type i, size_type n, size_type n2, char c);
+ xmlwrappstring& replace(size_type i, size_type n, const xmlwrappstring& src);
+ xmlwrappstring& replace(size_type i, size_type n, const xmlwrappstring& src, size_type i2, size_type n2);
+ xmlwrappstring& replace(size_type i, size_type n, const char* src, size_type n2);
+ xmlwrappstring& replace(size_type i, size_type n, const char* src);
+ xmlwrappstring& replace(size_type i, size_type n, size_type n2, gunichar uc);
+ xmlwrappstring& replace(size_type i, size_type n, size_type n2, char c);
- ustring& replace(iterator pbegin, iterator pend, const ustring& src);
- ustring& replace(iterator pbegin, iterator pend, const char* src, size_type n);
- ustring& replace(iterator pbegin, iterator pend, const char* src);
- ustring& replace(iterator pbegin, iterator pend, size_type n, gunichar uc);
- ustring& replace(iterator pbegin, iterator pend, size_type n, char c);
- template <class In> ustring& replace(iterator pbegin, iterator pend, In pbegin2, In pend2);
+ xmlwrappstring& replace(iterator pbegin, iterator pend, const xmlwrappstring& src);
+ xmlwrappstring& replace(iterator pbegin, iterator pend, const char* src, size_type n);
+ xmlwrappstring& replace(iterator pbegin, iterator pend, const char* src);
+ xmlwrappstring& replace(iterator pbegin, iterator pend, size_type n, gunichar uc);
+ xmlwrappstring& replace(iterator pbegin, iterator pend, size_type n, char c);
+ template <class In> xmlwrappstring& replace(iterator pbegin, iterator pend, In pbegin2, In pend2);
//! @}
//! @name Erase sub-strings.
//! @{
void clear();
- ustring& erase(size_type i, size_type n=npos);
- ustring& erase();
+ xmlwrappstring& erase(size_type i, size_type n=npos);
+ xmlwrappstring& erase();
iterator erase(iterator p);
iterator erase(iterator pbegin, iterator pend);
@@ -387,10 +383,10 @@
//! @name Compare and collate.
//! @{
- int compare(const ustring& rhs) const;
+ int compare(const xmlwrappstring& rhs) const;
int compare(const char* rhs) const;
- int compare(size_type i, size_type n, const ustring& rhs) const;
- int compare(size_type i, size_type n, const ustring& rhs, size_type i2, size_type n2) const;
+ int compare(size_type i, size_type n, const xmlwrappstring& rhs) const;
+ int compare(size_type i, size_type n, const xmlwrappstring& rhs, size_type i2, size_type n2) const;
int compare(size_type i, size_type n, const char* rhs, size_type n2) const;
int compare(size_type i, size_type n, const char* rhs) const;
@@ -399,11 +395,11 @@
* <tt>std::set<></tt>, you should consider creating a collate key first
* and compare this key instead of the actual string.
*
- * The ustring::compare() methods as well as the relational operators
+ * The xmlwrappstring::compare() methods as well as the relational operators
* <tt>== != < > <= >=</tt> are quite costly
* because they have to deal with %Unicode and the collation rules defined by
* the current locale. Converting both operands to UCS-4 is just the first
- * of several costly steps involved when comparing ustrings. So be careful.
+ * of several costly steps involved when comparing xmlwrappstrings. So be careful.
*/
std::string collate_key() const;
@@ -424,7 +420,7 @@
/*! No reference return; use replace() to write characters. @throw std::out_of_range */
value_type at(size_type i) const;
- inline ustring substr(size_type i=0, size_type n=npos) const;
+ inline xmlwrappstring substr(size_type i=0, size_type n=npos) const;
//! @}
//! @name Access a sequence of characters.
@@ -443,13 +439,13 @@
//! @name Find sub-strings.
//! @{
- size_type find(const ustring& str, size_type i=0) const;
+ size_type find(const xmlwrappstring& str, size_type i=0) const;
size_type find(const char* str, size_type i, size_type n) const;
size_type find(const char* str, size_type i=0) const;
size_type find(gunichar uc, size_type i=0) const;
size_type find(char c, size_type i=0) const;
- size_type rfind(const ustring& str, size_type i=npos) const;
+ size_type rfind(const xmlwrappstring& str, size_type i=npos) const;
size_type rfind(const char* str, size_type i, size_type n) const;
size_type rfind(const char* str, size_type i=npos) const;
size_type rfind(gunichar uc, size_type i=npos) const;
@@ -459,25 +455,25 @@
//! @name Match against a set of characters.
//! @{
- size_type find_first_of(const ustring& match, size_type i=0) const;
+ size_type find_first_of(const xmlwrappstring& match, size_type i=0) const;
size_type find_first_of(const char* match, size_type i, size_type n) const;
size_type find_first_of(const char* match, size_type i=0) const;
size_type find_first_of(gunichar uc, size_type i=0) const;
size_type find_first_of(char c, size_type i=0) const;
- size_type find_last_of(const ustring& match, size_type i=npos) const;
+ size_type find_last_of(const xmlwrappstring& match, size_type i=npos) const;
size_type find_last_of(const char* match, size_type i, size_type n) const;
size_type find_last_of(const char* match, size_type i=npos) const;
size_type find_last_of(gunichar uc, size_type i=npos) const;
size_type find_last_of(char c, size_type i=npos) const;
- size_type find_first_not_of(const ustring& match, size_type i=0) const;
+ size_type find_first_not_of(const xmlwrappstring& match, size_type i=0) const;
size_type find_first_not_of(const char* match, size_type i, size_type n) const;
size_type find_first_not_of(const char* match, size_type i=0) const;
size_type find_first_not_of(gunichar uc, size_type i=0) const;
size_type find_first_not_of(char c, size_type i=0) const;
- size_type find_last_not_of(const ustring& match, size_type i=npos) const;
+ size_type find_last_not_of(const xmlwrappstring& match, size_type i=npos) const;
size_type find_last_not_of(const char* match, size_type i, size_type n) const;
size_type find_last_not_of(const char* match, size_type i=npos) const;
size_type find_last_not_of(gunichar uc, size_type i=npos) const;
@@ -531,7 +527,7 @@
//! @name Get a per-byte representation of the string.
//! @{
- inline operator std::string() const; // e.g. std::string str = ustring();
+ inline operator std::string() const; // e.g. std::string str = xmlwrappstring();
inline const std::string& raw() const;
// Not necessarily an ASCII char*. Use g_utf8_*() where necessary.
@@ -555,7 +551,7 @@
bool validate(const_iterator& first_invalid) const;
/*! Check whether the string is plain 7-bit ASCII. @par
- * Unlike any other ustring method, is_ascii() is safe to use on invalid
+ * Unlike any other xmlwrappstring method, is_ascii() is safe to use on invalid
* UTF-8 strings. If the string isn't valid UTF-8, it cannot be valid
* ASCII either, therefore is_ascii() will just return @c false then.
* @return Whether the string contains only ASCII characters.
@@ -563,7 +559,7 @@
bool is_ascii() const;
/*! "Normalize" the %Unicode character representation of the string. */
- ustring normalize(NormalizeMode mode = NORMALIZE_DEFAULT_COMPOSE) const;
+ xmlwrappstring normalize(NormalizeMode mode = NORMALIZE_DEFAULT_COMPOSE) const;
//! @}
//! @name Character case conversion.
@@ -576,21 +572,21 @@
* <tt>"ß"</tt> will be replaced by two characters
* <tt>"SS"</tt> because there is no capital <tt>"ß"</tt>.
*/
- ustring uppercase() const;
+ xmlwrappstring uppercase() const;
/*! Returns a new UTF-8 string with all characters characters converted to
* their lowercase equivalent, while honoring the current locale. The
* resulting string may change in the number of bytes as well as in the
* number of characters.
*/
- ustring lowercase() const;
+ xmlwrappstring lowercase() const;
/*! Returns a caseless representation of the UTF-8 string. The resulting
* string doesn't correspond to any particular case, therefore the result
* is only useful to compare strings and should never be displayed to the
* user.
*/
- ustring casefold() const;
+ xmlwrappstring casefold() const;
//! @}
//! @name Message formatting.
@@ -601,7 +597,7 @@
*/
template <class T1>
static inline
- ustring compose(const ustring& fmt);
+ xmlwrappstring compose(const xmlwrappstring& fmt);
/*! Substitute placeholders in a format string with the referenced arguments.
* The template string should be in <tt>qt-format</tt>, that is
@@ -610,91 +606,91 @@
* reordered.
* @par Example:
* @code
- * using Glib::ustring;
+ * using xmlws::xmlwrappstring;
* const int percentage = 50;
- * const ustring text = ustring::compose("%1%% done", percentage);
+ * const xmlwrappstring text = xmlwrappstring::compose("%1%% done", percentage);
* @endcode
* @param fmt A template string in <tt>qt-format</tt>.
* @param a1 The argument to substitute for <tt>"%1"</tt>.
* @return The substituted message string.
- * @throw Glib::ConvertError
+ * @throw xmlws::ConvertError
*
* @newin{2,16}
*/
template <class T1>
static inline
- ustring compose(const ustring& fmt, const T1& a1);
+ xmlwrappstring compose(const xmlwrappstring& fmt, const T1& a1);
- /* See the documentation for compose(const ustring& fmt, const T1& a1).
+ /* See the documentation for compose(const xmlwrappstring& fmt, const T1& a1).
* @newin{2,16}
*/
template <class T1, class T2>
static inline
- ustring compose(const ustring& fmt, const T1& a1, const T2& a2);
+ xmlwrappstring compose(const xmlwrappstring& fmt, const T1& a1, const T2& a2);
- /* See the documentation for compose(const ustring& fmt, const T1& a1).
+ /* See the documentation for compose(const xmlwrappstring& fmt, const T1& a1).
* @newin{2,16}
*/
template <class T1, class T2, class T3>
static inline
- ustring compose(const ustring& fmt,
+ xmlwrappstring compose(const xmlwrappstring& fmt,
const T1& a1, const T2& a2, const T3& a3);
- /* See the documentation for compose(const ustring& fmt, const T1& a1).
+ /* See the documentation for compose(const xmlwrappstring& fmt, const T1& a1).
* @newin{2,16}
*/
template <class T1, class T2, class T3, class T4>
static inline
- ustring compose(const ustring& fmt,
+ xmlwrappstring compose(const xmlwrappstring& fmt,
const T1& a1, const T2& a2, const T3& a3,
const T4& a4);
- /* See the documentation for compose(const ustring& fmt, const T1& a1).
+ /* See the documentation for compose(const xmlwrappstring& fmt, const T1& a1).
* @newin{2,16}
*/
template <class T1, class T2, class T3, class T4, class T5>
static inline
- ustring compose(const ustring& fmt,
+ xmlwrappstring compose(const xmlwrappstring& fmt,
const T1& a1, const T2& a2, const T3& a3,
const T4& a4, const T5& a5);
- /* See the documentation for compose(const ustring& fmt, const T1& a1).
+ /* See the documentation for compose(const xmlwrappstring& fmt, const T1& a1).
* @newin{2,16}
*/
template <class T1, class T2, class T3, class T4, class T5, class T6>
static inline
- ustring compose(const ustring& fmt,
+ xmlwrappstring compose(const xmlwrappstring& fmt,
const T1& a1, const T2& a2, const T3& a3,
const T4& a4, const T5& a5, const T6& a6);
- /* See the documentation for compose(const ustring& fmt, const T1& a1).
+ /* See the documentation for compose(const xmlwrappstring& fmt, const T1& a1).
* @newin{2,16}
*/
template <class T1, class T2, class T3, class T4, class T5, class T6, class T7>
static inline
- ustring compose(const ustring& fmt,
+ xmlwrappstring compose(const xmlwrappstring& fmt,
const T1& a1, const T2& a2, const T3& a3,
const T4& a4, const T5& a5, const T6& a6,
const T7& a7);
- /* See the documentation for compose(const ustring& fmt, const T1& a1).
+ /* See the documentation for compose(const xmlwrappstring& fmt, const T1& a1).
* @newin{2,16}
*/
template <class T1, class T2, class T3, class T4,
class T5, class T6, class T7, class T8>
static inline
- ustring compose(const ustring& fmt,
+ xmlwrappstring compose(const xmlwrappstring& fmt,
const T1& a1, const T2& a2, const T3& a3,
const T4& a4, const T5& a5, const T6& a6,
const T7& a7, const T8& a8);
- /* See the documentation for compose(const ustring& fmt, const T1& a1).
+ /* See the documentation for compose(const xmlwrappstring& fmt, const T1& a1).
* @newin{2,16}
*/
template <class T1, class T2, class T3, class T4, class T5,
class T6, class T7, class T8, class T9>
static inline
- ustring compose(const ustring& fmt,
+ xmlwrappstring compose(const xmlwrappstring& fmt,
const T1& a1, const T2& a2, const T3& a3,
const T4& a4, const T5& a5, const T6& a6,
const T7& a7, const T8& a8, const T9& a9);
@@ -707,9 +703,9 @@
* in conjunction with compose() to facilitate localization of user-visible
* messages.
* @code
- * using Glib::ustring;
+ * using xmlws::xmlwrappstring;
* double value = 22.0 / 7.0;
- * ustring text = ustring::format(std::fixed, std::setprecision(2), value);
+ * xmlwrappstring text = xmlwrappstring::format(std::fixed, std::setprecision(2), value);
* @endcode
* @note The use of a wide character stream in the implementation of format()
* is almost completely transparent. However, one of the instances where the
@@ -718,20 +714,20 @@
* must be of type <tt>wchar_t</tt>. This can be achieved by using the
* <tt>L</tt> prefix with a character literal, as shown in the example.
* @code
- * using Glib::ustring;
+ * using xmlws::xmlwrappstring;
* // Insert leading zeroes to fill in at least six digits
- * ustring text = ustring::format(std::setfill(L'0'), std::setw(6), 123);
+ * xmlwrappstring text = xmlwrappstring::format(std::setfill(L'0'), std::setw(6), 123);
* @endcode
*
* @param a1 A streamable value or an I/O manipulator.
* @return The string representation of the argument stream.
- * @throw Glib::ConvertError
+ * @throw xmlws::ConvertError
*
* @newin{2,16}
*/
template <class T1>
static inline
- ustring format(const T1& a1);
+ xmlwrappstring format(const T1& a1);
/* See the documentation for format(const T1& a1).
*
@@ -739,7 +735,7 @@
*/
template <class T1, class T2>
static inline
- ustring format(const T1& a1, const T2& a2);
+ xmlwrappstring format(const T1& a1, const T2& a2);
/* See the documentation for format(const T1& a1).
*
@@ -747,7 +743,7 @@
*/
template <class T1, class T2, class T3>
static inline
- ustring format(const T1& a1, const T2& a2, const T3& a3);
+ xmlwrappstring format(const T1& a1, const T2& a2, const T3& a3);
/* See the documentation for format(const T1& a1).
*
@@ -755,7 +751,7 @@
*/
template <class T1, class T2, class T3, class T4>
static inline
- ustring format(const T1& a1, const T2& a2, const T3& a3, const T4& a4);
+ xmlwrappstring format(const T1& a1, const T2& a2, const T3& a3, const T4& a4);
/* See the documentation for format(const T1& a1).
*
@@ -763,7 +759,7 @@
*/
template <class T1, class T2, class T3, class T4, class T5>
static inline
- ustring format(const T1& a1, const T2& a2, const T3& a3,
+ xmlwrappstring format(const T1& a1, const T2& a2, const T3& a3,
const T4& a4, const T5& a5);
/* See the documentation for format(const T1& a1).
@@ -772,7 +768,7 @@
*/
template <class T1, class T2, class T3, class T4, class T5, class T6>
static inline
- ustring format(const T1& a1, const T2& a2, const T3& a3,
+ xmlwrappstring format(const T1& a1, const T2& a2, const T3& a3,
const T4& a4, const T5& a5, const T6& a6);
/* See the documentation for format(const T1& a1).
@@ -782,7 +778,7 @@
template <class T1, class T2, class T3, class T4,
class T5, class T6, class T7>
static inline
- ustring format(const T1& a1, const T2& a2, const T3& a3, const T4& a4,
+ xmlwrappstring format(const T1& a1, const T2& a2, const T3& a3, const T4& a4,
const T5& a5, const T6& a6, const T7& a7);
/* See the documentation for format(const T1& a1).
@@ -792,7 +788,7 @@
template <class T1, class T2, class T3, class T4,
class T5, class T6, class T7, class T8>
static inline
- ustring format(const T1& a1, const T2& a2, const T3& a3, const T4& a4,
+ xmlwrappstring format(const T1& a1, const T2& a2, const T3& a3, const T4& a4,
const T5& a5, const T6& a6, const T7& a7, const T8& a8);
//! @}
@@ -803,7 +799,7 @@
#ifdef GLIBMM_HAVE_STD_ITERATOR_TRAITS
template <class In, class ValueType = typename std::iterator_traits<In>::value_type>
#else
- template <class In, class ValueType = typename Glib::IteratorTraits<In>::value_type>
+ template <class In, class ValueType = typename xmlws::IteratorTraits<In>::value_type>
#endif
struct SequenceToString;
@@ -815,7 +811,7 @@
template <class T> class Stringify;
class FormatStream;
- static ustring compose_argv(const ustring& fmt, int argc, const ustring* const* argv);
+ static xmlwrappstring compose_argv(const xmlwrappstring& fmt, int argc, const xmlwrappstring* const* argv);
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
@@ -826,34 +822,34 @@
#ifndef DOXYGEN_SHOULD_SKIP_THIS
template <class In, class ValueType>
-struct ustring::SequenceToString
+struct xmlwrappstring::SequenceToString
{};
template <class In>
-struct ustring::SequenceToString<In, char> : public std::string
+struct xmlwrappstring::SequenceToString<In, char> : public std::string
{
SequenceToString(In pbegin, In pend);
};
template <class In>
-struct ustring::SequenceToString<In, gunichar> : public std::string
+struct xmlwrappstring::SequenceToString<In, gunichar> : public std::string
{
SequenceToString(In pbegin, In pend);
};
template <>
-struct ustring::SequenceToString<Glib::ustring::iterator, gunichar> : public std::string
+struct xmlwrappstring::SequenceToString<xmlws::xmlwrappstring::iterator, gunichar> : public std::string
{
- SequenceToString(Glib::ustring::iterator pbegin, Glib::ustring::iterator pend);
+ SequenceToString(xmlws::xmlwrappstring::iterator pbegin, xmlws::xmlwrappstring::iterator pend);
};
template <>
-struct ustring::SequenceToString<Glib::ustring::const_iterator, gunichar> : public std::string
+struct xmlwrappstring::SequenceToString<xmlws::xmlwrappstring::const_iterator, gunichar> : public std::string
{
- SequenceToString(Glib::ustring::const_iterator pbegin, Glib::ustring::const_iterator pend);
+ SequenceToString(xmlws::xmlwrappstring::const_iterator pbegin, xmlws::xmlwrappstring::const_iterator pend);
};
-class ustring::FormatStream
+class xmlwrappstring::FormatStream
{
private:
#ifdef GLIBMM_HAVE_WIDE_STREAM
@@ -864,8 +860,8 @@
StreamType stream_;
// noncopyable
- FormatStream(const ustring::FormatStream&);
- FormatStream& operator=(const ustring::FormatStream&);
+ FormatStream(const xmlwrappstring::FormatStream&);
+ FormatStream& operator=(const xmlwrappstring::FormatStream&);
public:
FormatStream();
@@ -878,37 +874,37 @@
//This overload exists to avoid the templated stream() being called for non-const char*.
inline void stream(char* value);
- ustring to_string() const;
+ xmlwrappstring to_string() const;
};
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
/** Stream input operator.
- * @relates Glib::ustring
- * @throw Glib::ConvertError
+ * @relates xmlws::xmlwrappstring
+ * @throw xmlws::ConvertError
*/
-std::istream& operator>>(std::istream& is, Glib::ustring& utf8_string);
+std::istream& operator>>(std::istream& is, xmlws::xmlwrappstring& utf8_string);
/** Stream output operator.
- * @relates Glib::ustring
- * @throw Glib::ConvertError
+ * @relates xmlws::xmlwrappstring
+ * @throw xmlws::ConvertError
*/
-std::ostream& operator<<(std::ostream& os, const Glib::ustring& utf8_string);
+std::ostream& operator<<(std::ostream& os, const xmlws::xmlwrappstring& utf8_string);
#ifdef GLIBMM_HAVE_WIDE_STREAM
/** Wide stream input operator.
- * @relates Glib::ustring
- * @throw Glib::ConvertError
+ * @relates xmlws::xmlwrappstring
+ * @throw xmlws::ConvertError
*/
-std::wistream& operator>>(std::wistream& is, ustring& utf8_string);
+std::wistream& operator>>(std::wistream& is, xmlwrappstring& utf8_string);
/** Wide stream output operator.
- * @relates Glib::ustring
- * @throw Glib::ConvertError
+ * @relates xmlws::xmlwrappstring
+ * @throw xmlws::ConvertError
*/
-std::wostream& operator<<(std::wostream& os, const ustring& utf8_string);
+std::wostream& operator<<(std::wostream& os, const xmlwrappstring& utf8_string);
#endif /* GLIBMM_HAVE_WIDE_STREAM */
@@ -918,64 +914,64 @@
#ifndef DOXYGEN_SHOULD_SKIP_THIS
-/**** Glib::ustring_Iterator<> *********************************************/
+/**** xmlws::xmlwrappstring_Iterator<> *********************************************/
template <class T> inline
-ustring_Iterator<T>::ustring_Iterator(T pos)
+xmlwrappstring_Iterator<T>::xmlwrappstring_Iterator(T pos)
:
pos_ (pos)
{}
template <class T> inline
-T ustring_Iterator<T>::base() const
+T xmlwrappstring_Iterator<T>::base() const
{
return pos_;
}
template <class T> inline
-ustring_Iterator<T>::ustring_Iterator()
+xmlwrappstring_Iterator<T>::xmlwrappstring_Iterator()
:
pos_ ()
{}
template <class T> inline
-ustring_Iterator<T>::ustring_Iterator(const ustring_Iterator<std::string::iterator>& other)
+xmlwrappstring_Iterator<T>::xmlwrappstring_Iterator(const xmlwrappstring_Iterator<std::string::iterator>& other)
:
pos_ (other.base())
{}
template <class T> inline
-typename ustring_Iterator<T>::value_type ustring_Iterator<T>::operator*() const
+typename xmlwrappstring_Iterator<T>::value_type xmlwrappstring_Iterator<T>::operator*() const
{
- return Glib::get_unichar_from_std_iterator(pos_);
+ return xmlws::get_unichar_from_std_iterator(pos_);
}
template <class T> inline
-ustring_Iterator<T>& ustring_Iterator<T>::operator++()
+xmlwrappstring_Iterator<T>& xmlwrappstring_Iterator<T>::operator++()
{
pos_ += g_utf8_skip[static_cast<unsigned char>(*pos_)];
return *this;
}
template <class T> inline
-const ustring_Iterator<T> ustring_Iterator<T>::operator++(int)
+const xmlwrappstring_Iterator<T> xmlwrappstring_Iterator<T>::operator++(int)
{
- const ustring_Iterator<T> temp (*this);
+ const xmlwrappstring_Iterator<T> temp (*this);
this->operator++();
return temp;
}
template <class T> inline
-ustring_Iterator<T>& ustring_Iterator<T>::operator--()
+xmlwrappstring_Iterator<T>& xmlwrappstring_Iterator<T>::operator--()
{
do --pos_; while((static_cast<unsigned char>(*pos_) & 0xC0u) == 0x80);
return *this;
}
template <class T> inline
-const ustring_Iterator<T> ustring_Iterator<T>::operator--(int)
+const xmlwrappstring_Iterator<T> xmlwrappstring_Iterator<T>::operator--(int)
{
- const ustring_Iterator<T> temp (*this);
+ const xmlwrappstring_Iterator<T> temp (*this);
this->operator--();
return temp;
}
@@ -983,44 +979,44 @@
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
-/** @relates Glib::ustring_Iterator */
+/** @relates xmlws::xmlwrappstring_Iterator */
inline
-bool operator==(const Glib::ustring::const_iterator& lhs, const Glib::ustring::const_iterator& rhs)
+bool operator==(const xmlws::xmlwrappstring::const_iterator& lhs, const xmlws::xmlwrappstring::const_iterator& rhs)
{
return (lhs.base() == rhs.base());
}
-/** @relates Glib::ustring_Iterator */
+/** @relates xmlws::xmlwrappstring_Iterator */
inline
-bool operator!=(const Glib::ustring::const_iterator& lhs, const Glib::ustring::const_iterator& rhs)
+bool operator!=(const xmlws::xmlwrappstring::const_iterator& lhs, const xmlws::xmlwrappstring::const_iterator& rhs)
{
return (lhs.base() != rhs.base());
}
-/** @relates Glib::ustring_Iterator */
+/** @relates xmlws::xmlwrappstring_Iterator */
inline
-bool operator<(const Glib::ustring::const_iterator& lhs, const Glib::ustring::const_iterator& rhs)
+bool operator<(const xmlws::xmlwrappstring::const_iterator& lhs, const xmlws::xmlwrappstring::const_iterator& rhs)
{
return (lhs.base() < rhs.base());
}
-/** @relates Glib::ustring_Iterator */
+/** @relates xmlws::xmlwrappstring_Iterator */
inline
-bool operator>(const Glib::ustring::const_iterator& lhs, const Glib::ustring::const_iterator& rhs)
+bool operator>(const xmlws::xmlwrappstring::const_iterator& lhs, const xmlws::xmlwrappstring::const_iterator& rhs)
{
return (lhs.base() > rhs.base());
}
-/** @relates Glib::ustring_Iterator */
+/** @relates xmlws::xmlwrappstring_Iterator */
inline
-bool operator<=(const Glib::ustring::const_iterator& lhs, const Glib::ustring::const_iterator& rhs)
+bool operator<=(const xmlws::xmlwrappstring::const_iterator& lhs, const xmlws::xmlwrappstring::const_iterator& rhs)
{
return (lhs.base() <= rhs.base());
}
-/** @relates Glib::ustring_Iterator */
+/** @relates xmlws::xmlwrappstring_Iterator */
inline
-bool operator>=(const Glib::ustring::const_iterator& lhs, const Glib::ustring::const_iterator& rhs)
+bool operator>=(const xmlws::xmlwrappstring::const_iterator& lhs, const xmlws::xmlwrappstring::const_iterator& rhs)
{
return (lhs.base() >= rhs.base());
}
@@ -1028,16 +1024,16 @@
#ifndef DOXYGEN_SHOULD_SKIP_THIS
-/**** Glib::ustring::SequenceToString **************************************/
+/**** xmlws::xmlwrappstring::SequenceToString **************************************/
template <class In>
-ustring::SequenceToString<In,char>::SequenceToString(In pbegin, In pend)
+xmlwrappstring::SequenceToString<In,char>::SequenceToString(In pbegin, In pend)
:
std::string(pbegin, pend)
{}
template <class In>
-ustring::SequenceToString<In,gunichar>::SequenceToString(In pbegin, In pend)
+xmlwrappstring::SequenceToString<In,gunichar>::SequenceToString(In pbegin, In pend)
{
char utf8_buf[6]; // stores a single UTF-8 character
@@ -1048,99 +1044,99 @@
}
}
-/**** Glib::ustring::FormatStream ******************************************/
+/**** xmlws::xmlwrappstring::FormatStream ******************************************/
template <class T> inline
-void ustring::FormatStream::stream(const T& value)
+void xmlwrappstring::FormatStream::stream(const T& value)
{
stream_ << value;
}
inline
-void ustring::FormatStream::stream(const char* value)
+void xmlwrappstring::FormatStream::stream(const char* value)
{
- stream_ << ustring(value);
+ stream_ << xmlwrappstring(value);
}
inline
-void ustring::FormatStream::stream(char* value)
+void xmlwrappstring::FormatStream::stream(char* value)
{
- stream_ << ustring(value);
+ stream_ << xmlwrappstring(value);
}
-/**** Glib::ustring ********************************************************/
+/**** xmlws::xmlwrappstring ********************************************************/
template <class In>
-ustring::ustring(In pbegin, In pend)
+xmlwrappstring::xmlwrappstring(In pbegin, In pend)
:
- string_ (Glib::ustring::SequenceToString<In>(pbegin, pend))
+ string_ (xmlws::xmlwrappstring::SequenceToString<In>(pbegin, pend))
{}
template <class In>
-ustring& ustring::assign(In pbegin, In pend)
+xmlwrappstring& xmlwrappstring::assign(In pbegin, In pend)
{
- Glib::ustring::SequenceToString<In> temp_string (pbegin, pend);
+ xmlws::xmlwrappstring::SequenceToString<In> temp_string (pbegin, pend);
string_.swap(temp_string); // constant-time operation
return *this;
}
template <class In>
-ustring& ustring::append(In pbegin, In pend)
+xmlwrappstring& xmlwrappstring::append(In pbegin, In pend)
{
- string_.append(Glib::ustring::SequenceToString<In>(pbegin, pend));
+ string_.append(xmlws::xmlwrappstring::SequenceToString<In>(pbegin, pend));
return *this;
}
template <class In>
-void ustring::insert(ustring::iterator p, In pbegin, In pend)
+void xmlwrappstring::insert(xmlwrappstring::iterator p, In pbegin, In pend)
{
- string_.insert(p.base(), Glib::ustring::SequenceToString<In>(pbegin, pend));
+ string_.insert(p.base(), xmlws::xmlwrappstring::SequenceToString<In>(pbegin, pend));
}
template <class In>
-ustring& ustring::replace(ustring::iterator pbegin, ustring::iterator pend, In pbegin2, In pend2)
+xmlwrappstring& xmlwrappstring::replace(xmlwrappstring::iterator pbegin, xmlwrappstring::iterator pend, In pbegin2, In pend2)
{
string_.replace(
pbegin.base(), pend.base(),
- Glib::ustring::SequenceToString<In>(pbegin2, pend2));
+ xmlws::xmlwrappstring::SequenceToString<In>(pbegin2, pend2));
return *this;
}
-// The ustring methods substr() and operator std::string() are inline,
+// The xmlwrappstring methods substr() and operator std::string() are inline,
// so that the compiler has a fair chance to optimize the copy ctor away.
inline
-ustring ustring::substr(ustring::size_type i, ustring::size_type n) const
+xmlwrappstring xmlwrappstring::substr(xmlwrappstring::size_type i, xmlwrappstring::size_type n) const
{
- return ustring(*this, i, n);
+ return xmlwrappstring(*this, i, n);
}
inline
-ustring::operator std::string() const
+xmlwrappstring::operator std::string() const
{
return string_;
}
inline
-const std::string& ustring::raw() const
+const std::string& xmlwrappstring::raw() const
{
return string_;
}
template <class T1>
inline // static
-ustring ustring::format(const T1& a1)
+xmlwrappstring xmlwrappstring::format(const T1& a1)
{
- ustring::FormatStream buf;
+ xmlwrappstring::FormatStream buf;
buf.stream(a1);
return buf.to_string();
}
template <class T1, class T2>
inline // static
-ustring ustring::format(const T1& a1, const T2& a2)
+xmlwrappstring xmlwrappstring::format(const T1& a1, const T2& a2)
{
- ustring::FormatStream buf;
+ xmlwrappstring::FormatStream buf;
buf.stream(a1);
buf.stream(a2);
return buf.to_string();
@@ -1148,9 +1144,9 @@
template <class T1, class T2, class T3>
inline // static
-ustring ustring::format(const T1& a1, const T2& a2, const T3& a3)
+xmlwrappstring xmlwrappstring::format(const T1& a1, const T2& a2, const T3& a3)
{
- ustring::FormatStream buf;
+ xmlwrappstring::FormatStream buf;
buf.stream(a1);
buf.stream(a2);
buf.stream(a3);
@@ -1159,9 +1155,9 @@
template <class T1, class T2, class T3, class T4>
inline // static
-ustring ustring::format(const T1& a1, const T2& a2, const T3& a3, const T4& a4)
+xmlwrappstring xmlwrappstring::format(const T1& a1, const T2& a2, const T3& a3, const T4& a4)
{
- ustring::FormatStream buf;
+ xmlwrappstring::FormatStream buf;
buf.stream(a1);
buf.stream(a2);
buf.stream(a3);
@@ -1171,10 +1167,10 @@
template <class T1, class T2, class T3, class T4, class T5>
inline // static
-ustring ustring::format(const T1& a1, const T2& a2, const T3& a3,
+xmlwrappstring xmlwrappstring::format(const T1& a1, const T2& a2, const T3& a3,
const T4& a4, const T5& a5)
{
- ustring::FormatStream buf;
+ xmlwrappstring::FormatStream buf;
buf.stream(a1);
buf.stream(a2);
buf.stream(a3);
@@ -1185,10 +1181,10 @@
template <class T1, class T2, class T3, class T4, class T5, class T6>
inline // static
-ustring ustring::format(const T1& a1, const T2& a2, const T3& a3,
+xmlwrappstring xmlwrappstring::format(const T1& a1, const T2& a2, const T3& a3,
const T4& a4, const T5& a5, const T6& a6)
{
- ustring::FormatStream buf;
+ xmlwrappstring::FormatStream buf;
buf.stream(a1);
buf.stream(a2);
buf.stream(a3);
@@ -1201,10 +1197,10 @@
template <class T1, class T2, class T3, class T4,
class T5, class T6, class T7>
inline // static
-ustring ustring::format(const T1& a1, const T2& a2, const T3& a3, const T4& a4,
+xmlwrappstring xmlwrappstring::format(const T1& a1, const T2& a2, const T3& a3, const T4& a4,
const T5& a5, const T6& a6, const T7& a7)
{
- ustring::FormatStream buf;
+ xmlwrappstring::FormatStream buf;
buf.stream(a1);
buf.stream(a2);
buf.stream(a3);
@@ -1218,10 +1214,10 @@
template <class T1, class T2, class T3, class T4,
class T5, class T6, class T7, class T8>
inline // static
-ustring ustring::format(const T1& a1, const T2& a2, const T3& a3, const T4& a4,
+xmlwrappstring xmlwrappstring::format(const T1& a1, const T2& a2, const T3& a3, const T4& a4,
const T5& a5, const T6& a6, const T7& a7, const T8& a8)
{
- ustring::FormatStream buf;
+ xmlwrappstring::FormatStream buf;
buf.stream(a1);
buf.stream(a2);
buf.stream(a3);
@@ -1233,382 +1229,382 @@
return buf.to_string();
}
-/** An inner class used by ustring.
+/** An inner class used by xmlwrappstring.
*/
template <class T>
-class ustring::Stringify
+class xmlwrappstring::Stringify
{
private:
- ustring string_;
+ xmlwrappstring string_;
// noncopyable
- Stringify(const ustring::Stringify<T>&);
- Stringify<T>& operator=(const ustring::Stringify<T>&);
+ Stringify(const xmlwrappstring::Stringify<T>&);
+ Stringify<T>& operator=(const xmlwrappstring::Stringify<T>&);
public:
- explicit inline Stringify(const T& arg) : string_ (ustring::format(arg)) {}
+ explicit inline Stringify(const T& arg) : string_ (xmlwrappstring::format(arg)) {}
//TODO: Why is this here? See the template specialization:
explicit inline Stringify(const char* arg) : string_(arg) {}
- inline const ustring* ptr() const { return &string_; }
+ inline const xmlwrappstring* ptr() const { return &string_; }
};
-/// A template specialization for Stringify<ustring>:
+/// A template specialization for Stringify<xmlwrappstring>:
template <>
-class ustring::Stringify<ustring>
+class xmlwrappstring::Stringify<xmlwrappstring>
{
private:
- const ustring& string_;
+ const xmlwrappstring& string_;
// noncopyable
- Stringify(const ustring::Stringify<ustring>&);
- Stringify<ustring>& operator=(const ustring::Stringify<ustring>&);
+ Stringify(const xmlwrappstring::Stringify<xmlwrappstring>&);
+ Stringify<xmlwrappstring>& operator=(const xmlwrappstring::Stringify<xmlwrappstring>&);
public:
- explicit inline Stringify(const ustring& arg) : string_(arg) {}
- inline const ustring* ptr() const { return &string_; }
+ explicit inline Stringify(const xmlwrappstring& arg) : string_(arg) {}
+ inline const xmlwrappstring* ptr() const { return &string_; }
};
/** A template specialization for Stringify<const char*>,
* because the regular template has ambiguous constructor overloads for char*.
*/
template <>
-class ustring::Stringify<const char*>
+class xmlwrappstring::Stringify<const char*>
{
private:
- const ustring string_;
+ const xmlwrappstring string_;
// noncopyable
- Stringify(const ustring::Stringify<const char*>&);
- Stringify<ustring>& operator=(const ustring::Stringify<const char*>&);
+ Stringify(const xmlwrappstring::Stringify<const char*>&);
+ Stringify<xmlwrappstring>& operator=(const xmlwrappstring::Stringify<const char*>&);
public:
explicit inline Stringify(const char* arg) : string_(arg) {}
- inline const ustring* ptr() const { return &string_; }
+ inline const xmlwrappstring* ptr() const { return &string_; }
};
/** A template specialization for Stringify<char[N]> (for string literals),
* because the regular template has ambiguous constructor overloads for char*.
*/
template <std::size_t N>
-class ustring::Stringify<char[N]>
+class xmlwrappstring::Stringify<char[N]>
{
private:
- const ustring string_;
+ const xmlwrappstring string_;
// noncopyable
- Stringify(const ustring::Stringify<char[N]>&);
- Stringify<ustring>& operator=(const ustring::Stringify<char[N]>&);
+ Stringify(const xmlwrappstring::Stringify<char[N]>&);
+ Stringify<xmlwrappstring>& operator=(const xmlwrappstring::Stringify<char[N]>&);
public:
explicit inline Stringify(const char arg[N]) : string_(arg) {}
- inline const ustring* ptr() const { return &string_; }
+ inline const xmlwrappstring* ptr() const { return &string_; }
};
template <class T1>
inline // static
-ustring ustring::compose(const ustring& fmt)
+xmlwrappstring xmlwrappstring::compose(const xmlwrappstring& fmt)
{
- return ustring::compose_argv(fmt, 0, 0);
+ return xmlwrappstring::compose_argv(fmt, 0, 0);
}
template <class T1>
inline // static
-ustring ustring::compose(const ustring& fmt, const T1& a1)
+xmlwrappstring xmlwrappstring::compose(const xmlwrappstring& fmt, const T1& a1)
{
- const ustring::Stringify<T1> s1(a1);
+ const xmlwrappstring::Stringify<T1> s1(a1);
- const ustring *const argv[] = { s1.ptr() };
- return ustring::compose_argv(fmt, G_N_ELEMENTS(argv), argv);
+ const xmlwrappstring *const argv[] = { s1.ptr() };
+ return xmlwrappstring::compose_argv(fmt, G_N_ELEMENTS(argv), argv);
}
template <class T1, class T2>
inline // static
-ustring ustring::compose(const ustring& fmt, const T1& a1, const T2& a2)
+xmlwrappstring xmlwrappstring::compose(const xmlwrappstring& fmt, const T1& a1, const T2& a2)
{
- const ustring::Stringify<T1> s1(a1);
- const ustring::Stringify<T2> s2(a2);
+ const xmlwrappstring::Stringify<T1> s1(a1);
+ const xmlwrappstring::Stringify<T2> s2(a2);
- const ustring *const argv[] = { s1.ptr(), s2.ptr() };
- return ustring::compose_argv(fmt, G_N_ELEMENTS(argv), argv);
+ const xmlwrappstring *const argv[] = { s1.ptr(), s2.ptr() };
+ return xmlwrappstring::compose_argv(fmt, G_N_ELEMENTS(argv), argv);
}
template <class T1, class T2, class T3>
inline // static
-ustring ustring::compose(const ustring& fmt,
+xmlwrappstring xmlwrappstring::compose(const xmlwrappstring& fmt,
const T1& a1, const T2& a2, const T3& a3)
{
- const ustring::Stringify<T1> s1(a1);
- const ustring::Stringify<T2> s2(a2);
- const ustring::Stringify<T3> s3(a3);
+ const xmlwrappstring::Stringify<T1> s1(a1);
+ const xmlwrappstring::Stringify<T2> s2(a2);
+ const xmlwrappstring::Stringify<T3> s3(a3);
- const ustring *const argv[] = { s1.ptr(), s2.ptr(), s3.ptr() };
- return ustring::compose_argv(fmt, G_N_ELEMENTS(argv), argv);
+ const xmlwrappstring *const argv[] = { s1.ptr(), s2.ptr(), s3.ptr() };
+ return xmlwrappstring::compose_argv(fmt, G_N_ELEMENTS(argv), argv);
}
template <class T1, class T2, class T3, class T4>
inline // static
-ustring ustring::compose(const ustring& fmt,
+xmlwrappstring xmlwrappstring::compose(const xmlwrappstring& fmt,
const T1& a1, const T2& a2, const T3& a3, const T4& a4)
{
- const ustring::Stringify<T1> s1(a1);
- const ustring::Stringify<T2> s2(a2);
- const ustring::Stringify<T3> s3(a3);
- const ustring::Stringify<T4> s4(a4);
+ const xmlwrappstring::Stringify<T1> s1(a1);
+ const xmlwrappstring::Stringify<T2> s2(a2);
+ const xmlwrappstring::Stringify<T3> s3(a3);
+ const xmlwrappstring::Stringify<T4> s4(a4);
- const ustring *const argv[] = { s1.ptr(), s2.ptr(), s3.ptr(), s4.ptr() };
- return ustring::compose_argv(fmt, G_N_ELEMENTS(argv), argv);
+ const xmlwrappstring *const argv[] = { s1.ptr(), s2.ptr(), s3.ptr(), s4.ptr() };
+ return xmlwrappstring::compose_argv(fmt, G_N_ELEMENTS(argv), argv);
}
template <class T1, class T2, class T3, class T4, class T5>
inline // static
-ustring ustring::compose(const ustring& fmt,
+xmlwrappstring xmlwrappstring::compose(const xmlwrappstring& fmt,
const T1& a1, const T2& a2, const T3& a3,
const T4& a4, const T5& a5)
{
- const ustring::Stringify<T1> s1(a1);
- const ustring::Stringify<T2> s2(a2);
- const ustring::Stringify<T3> s3(a3);
- const ustring::Stringify<T4> s4(a4);
- const ustring::Stringify<T5> s5(a5);
+ const xmlwrappstring::Stringify<T1> s1(a1);
+ const xmlwrappstring::Stringify<T2> s2(a2);
+ const xmlwrappstring::Stringify<T3> s3(a3);
+ const xmlwrappstring::Stringify<T4> s4(a4);
+ const xmlwrappstring::Stringify<T5> s5(a5);
- const ustring *const argv[] = { s1.ptr(), s2.ptr(), s3.ptr(), s4.ptr(), s5.ptr() };
- return ustring::compose_argv(fmt, G_N_ELEMENTS(argv), argv);
+ const xmlwrappstring *const argv[] = { s1.ptr(), s2.ptr(), s3.ptr(), s4.ptr(), s5.ptr() };
+ return xmlwrappstring::compose_argv(fmt, G_N_ELEMENTS(argv), argv);
}
template <class T1, class T2, class T3, class T4, class T5, class T6>
inline // static
-ustring ustring::compose(const ustring& fmt,
+xmlwrappstring xmlwrappstring::compose(const xmlwrappstring& fmt,
const T1& a1, const T2& a2, const T3& a3,
const T4& a4, const T5& a5, const T6& a6)
{
- const ustring::Stringify<T1> s1(a1);
- const ustring::Stringify<T2> s2(a2);
- const ustring::Stringify<T3> s3(a3);
- const ustring::Stringify<T4> s4(a4);
- const ustring::Stringify<T5> s5(a5);
- const ustring::Stringify<T6> s6(a6);
+ const xmlwrappstring::Stringify<T1> s1(a1);
+ const xmlwrappstring::Stringify<T2> s2(a2);
+ const xmlwrappstring::Stringify<T3> s3(a3);
+ const xmlwrappstring::Stringify<T4> s4(a4);
+ const xmlwrappstring::Stringify<T5> s5(a5);
+ const xmlwrappstring::Stringify<T6> s6(a6);
- const ustring *const argv[] = { s1.ptr(), s2.ptr(), s3.ptr(), s4.ptr(),
+ const xmlwrappstring *const argv[] = { s1.ptr(), s2.ptr(), s3.ptr(), s4.ptr(),
s5.ptr(), s6.ptr() };
- return ustring::compose_argv(fmt, G_N_ELEMENTS(argv), argv);
+ return xmlwrappstring::compose_argv(fmt, G_N_ELEMENTS(argv), argv);
}
template <class T1, class T2, class T3, class T4, class T5, class T6, class T7>
inline // static
-ustring ustring::compose(const ustring& fmt,
+xmlwrappstring xmlwrappstring::compose(const xmlwrappstring& fmt,
const T1& a1, const T2& a2, const T3& a3,
const T4& a4, const T5& a5, const T6& a6, const T7& a7)
{
- const ustring::Stringify<T1> s1(a1);
- const ustring::Stringify<T2> s2(a2);
- const ustring::Stringify<T3> s3(a3);
- const ustring::Stringify<T4> s4(a4);
- const ustring::Stringify<T5> s5(a5);
- const ustring::Stringify<T6> s6(a6);
- const ustring::Stringify<T7> s7(a7);
+ const xmlwrappstring::Stringify<T1> s1(a1);
+ const xmlwrappstring::Stringify<T2> s2(a2);
+ const xmlwrappstring::Stringify<T3> s3(a3);
+ const xmlwrappstring::Stringify<T4> s4(a4);
+ const xmlwrappstring::Stringify<T5> s5(a5);
+ const xmlwrappstring::Stringify<T6> s6(a6);
+ const xmlwrappstring::Stringify<T7> s7(a7);
- const ustring *const argv[] = { s1.ptr(), s2.ptr(), s3.ptr(), s4.ptr(),
+ const xmlwrappstring *const argv[] = { s1.ptr(), s2.ptr(), s3.ptr(), s4.ptr(),
s5.ptr(), s6.ptr(), s7.ptr() };
- return ustring::compose_argv(fmt, G_N_ELEMENTS(argv), argv);
+ return xmlwrappstring::compose_argv(fmt, G_N_ELEMENTS(argv), argv);
}
template <class T1, class T2, class T3, class T4,
class T5, class T6, class T7, class T8>
inline // static
-ustring ustring::compose(const ustring& fmt,
+xmlwrappstring xmlwrappstring::compose(const xmlwrappstring& fmt,
const T1& a1, const T2& a2, const T3& a3,
const T4& a4, const T5& a5, const T6& a6,
const T7& a7, const T8& a8)
{
- const ustring::Stringify<T1> s1(a1);
- const ustring::Stringify<T2> s2(a2);
- const ustring::Stringify<T3> s3(a3);
- const ustring::Stringify<T4> s4(a4);
- const ustring::Stringify<T5> s5(a5);
- const ustring::Stringify<T6> s6(a6);
- const ustring::Stringify<T7> s7(a7);
- const ustring::Stringify<T8> s8(a8);
+ const xmlwrappstring::Stringify<T1> s1(a1);
+ const xmlwrappstring::Stringify<T2> s2(a2);
+ const xmlwrappstring::Stringify<T3> s3(a3);
+ const xmlwrappstring::Stringify<T4> s4(a4);
+ const xmlwrappstring::Stringify<T5> s5(a5);
+ const xmlwrappstring::Stringify<T6> s6(a6);
+ const xmlwrappstring::Stringify<T7> s7(a7);
+ const xmlwrappstring::Stringify<T8> s8(a8);
- const ustring *const argv[] = { s1.ptr(), s2.ptr(), s3.ptr(), s4.ptr(),
+ const xmlwrappstring *const argv[] = { s1.ptr(), s2.ptr(), s3.ptr(), s4.ptr(),
s5.ptr(), s6.ptr(), s7.ptr(), s8.ptr() };
- return ustring::compose_argv(fmt, G_N_ELEMENTS(argv), argv);
+ return xmlwrappstring::compose_argv(fmt, G_N_ELEMENTS(argv), argv);
}
template <class T1, class T2, class T3, class T4, class T5,
class T6, class T7, class T8, class T9>
inline // static
-ustring ustring::compose(const ustring& fmt,
+xmlwrappstring xmlwrappstring::compose(const xmlwrappstring& fmt,
const T1& a1, const T2& a2, const T3& a3,
const T4& a4, const T5& a5, const T6& a6,
const T7& a7, const T8& a8, const T9& a9)
{
- const ustring::Stringify<T1> s1(a1);
- const ustring::Stringify<T2> s2(a2);
- const ustring::Stringify<T3> s3(a3);
- const ustring::Stringify<T4> s4(a4);
- const ustring::Stringify<T5> s5(a5);
- const ustring::Stringify<T6> s6(a6);
- const ustring::Stringify<T7> s7(a7);
- const ustring::Stringify<T8> s8(a8);
- const ustring::Stringify<T9> s9(a9);
+ const xmlwrappstring::Stringify<T1> s1(a1);
+ const xmlwrappstring::Stringify<T2> s2(a2);
+ const xmlwrappstring::Stringify<T3> s3(a3);
+ const xmlwrappstring::Stringify<T4> s4(a4);
+ ...
[truncated message content] |
|
From: <tbr...@us...> - 2012-03-20 16:19:08
|
Revision: 221
http://xmlwrapp.svn.sourceforge.net/xmlwrapp/?rev=221&view=rev
Author: tbrowder2
Date: 2012-03-20 16:18:57 +0000 (Tue, 20 Mar 2012)
Log Message:
-----------
correct name
Modified Paths:
--------------
trunk/LICENSE
Modified: trunk/LICENSE
===================================================================
--- trunk/LICENSE 2012-03-20 16:18:25 UTC (rev 220)
+++ trunk/LICENSE 2012-03-20 16:18:57 UTC (rev 221)
@@ -8,7 +8,7 @@
licenses/ustring.license
GNU LESSER GENERAL PUBLIC LICENSE (LGPL): Version 2.1, February 1999
- licenses/utf8string.license
+ licenses/utf8-for-cpp.license
Copyright (C) 2012 Thomas M. Browder, Jr. <tom...@gm...>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tbr...@us...> - 2012-03-20 16:18:36
|
Revision: 220
http://xmlwrapp.svn.sourceforge.net/xmlwrapp/?rev=220&view=rev
Author: tbrowder2
Date: 2012-03-20 16:18:25 +0000 (Tue, 20 Mar 2012)
Log Message:
-----------
correct name
Added Paths:
-----------
trunk/licenses/utf8-for-cpp.license
Removed Paths:
-------------
trunk/licenses/utf8string.license
Copied: trunk/licenses/utf8-for-cpp.license (from rev 217, trunk/licenses/utf8string.license)
===================================================================
--- trunk/licenses/utf8-for-cpp.license (rev 0)
+++ trunk/licenses/utf8-for-cpp.license 2012-03-20 16:18:25 UTC (rev 220)
@@ -0,0 +1,25 @@
+// Copyright 2006 Nemanja Trifunovic
+
+/*
+Permission is hereby granted, free of charge, to any person or organization
+obtaining a copy of the software and accompanying documentation covered by
+this license (the "Software") to use, reproduce, display, distribute,
+execute, and transmit the Software, and to prepare derivative works of the
+Software, and to permit third-parties to whom the Software is furnished to
+do so, all subject to the following:
+
+The copyright notices in the Software and this entire statement, including
+the above license grant, this restriction and the following disclaimer,
+must be included in all copies of the Software, in whole or in part, and
+all derivative works of the Software, unless such copies or derivative
+works are solely in the form of machine-executable object code generated by
+a source language processor.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
+*/
Deleted: trunk/licenses/utf8string.license
===================================================================
--- trunk/licenses/utf8string.license 2012-03-20 16:13:27 UTC (rev 219)
+++ trunk/licenses/utf8string.license 2012-03-20 16:18:25 UTC (rev 220)
@@ -1,25 +0,0 @@
-// Copyright 2006 Nemanja Trifunovic
-
-/*
-Permission is hereby granted, free of charge, to any person or organization
-obtaining a copy of the software and accompanying documentation covered by
-this license (the "Software") to use, reproduce, display, distribute,
-execute, and transmit the Software, and to prepare derivative works of the
-Software, and to permit third-parties to whom the Software is furnished to
-do so, all subject to the following:
-
-The copyright notices in the Software and this entire statement, including
-the above license grant, this restriction and the following disclaimer,
-must be included in all copies of the Software, in whole or in part, and
-all derivative works of the Software, unless such copies or derivative
-works are solely in the form of machine-executable object code generated by
-a source language processor.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
-SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
-FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
-ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-DEALINGS IN THE SOFTWARE.
-*/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tbr...@us...> - 2012-03-20 16:13:38
|
Revision: 219
http://xmlwrapp.svn.sourceforge.net/xmlwrapp/?rev=219&view=rev
Author: tbrowder2
Date: 2012-03-20 16:13:27 +0000 (Tue, 20 Mar 2012)
Log Message:
-----------
add utf-8 project files
Modified Paths:
--------------
trunk/include/Makefile.am
Modified: trunk/include/Makefile.am
===================================================================
--- trunk/include/Makefile.am 2012-03-20 16:12:52 UTC (rev 218)
+++ trunk/include/Makefile.am 2012-03-20 16:13:27 UTC (rev 219)
@@ -16,7 +16,11 @@
xmlwrappstring_includedir= $(includedir)/xmlwrappstring
xmlwrappstring_include_HEADERS = \
- xmlwrappstring/xmlwrappstring.h
+ xmlwrappstring/xmlwrappstring.h \
+ xmlwrappstring/utf8.h \
+ xmlwrappstring/utf8/checked.h \
+ xmlwrappstring/utf8/core.h \
+ xmlwrappstring/utf8/unchecked.h
if WITH_XSLT
xsltwrapp_includedir= $(includedir)/xsltwrapp
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tbr...@us...> - 2012-03-20 16:13:03
|
Revision: 218
http://xmlwrapp.svn.sourceforge.net/xmlwrapp/?rev=218&view=rev
Author: tbrowder2
Date: 2012-03-20 16:12:52 +0000 (Tue, 20 Mar 2012)
Log Message:
-----------
add announcement for next release
Modified Paths:
--------------
trunk/NEWS
Modified: trunk/NEWS
===================================================================
--- trunk/NEWS 2012-03-20 16:12:08 UTC (rev 217)
+++ trunk/NEWS 2012-03-20 16:12:52 UTC (rev 218)
@@ -1,4 +1,9 @@
+Version 0.7.0
+ Added libxmlwrappstring, a UTF-8 C++ string class based on the
+ Glib::ustring (http://ftp.gnome.org/pub/GNOME/sources/glibmm/2.31/)
+ and the UTF-8-CPP project (http://utfcpp.sourceforge.net/)
+
Added xml::node::set_text_content() for setting unescaped textual
content.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tbr...@us...> - 2012-03-20 16:12:18
|
Revision: 217
http://xmlwrapp.svn.sourceforge.net/xmlwrapp/?rev=217&view=rev
Author: tbrowder2
Date: 2012-03-20 16:12:08 +0000 (Tue, 20 Mar 2012)
Log Message:
-----------
add license info for all parts
Modified Paths:
--------------
trunk/LICENSE
Added Paths:
-----------
trunk/licenses/
trunk/licenses/ustring.license
trunk/licenses/utf8string.license
Modified: trunk/LICENSE
===================================================================
--- trunk/LICENSE 2012-03-20 15:59:36 UTC (rev 216)
+++ trunk/LICENSE 2012-03-20 16:12:08 UTC (rev 217)
@@ -1,5 +1,25 @@
-Copyright (C) 2001-2003 Peter J Jones <pj...@pm...>
+This project is licensed as two separate parts:
+
+(1) xmlwrappstring
+==================
+
+See:
+
+ licenses/ustring.license
+ GNU LESSER GENERAL PUBLIC LICENSE (LGPL): Version 2.1, February 1999
+
+ licenses/utf8string.license
+
+Copyright (C) 2012 Thomas M. Browder, Jr. <tom...@gm...>
+
+
+(2) xmlwrapp, xsltwrapp
+=======================
+
+Copyright (C) 2001-2003 Peter J. Jones <pj...@pm...>
+Copyright (C) 2005-2008 Thomas M. Browder, Jr. <tom...@gm...>
Copyright (C) 2009-2010 Vaclav Slavik <vs...@gm...>
+Copyright (C) 2012 Thomas M. Browder, Jr. <tom...@gm...>
All Rights Reserved
Redistribution and use in source and binary forms, with or without
Added: trunk/licenses/ustring.license
===================================================================
--- trunk/licenses/ustring.license (rev 0)
+++ trunk/licenses/ustring.license 2012-03-20 16:12:08 UTC (rev 217)
@@ -0,0 +1,521 @@
+/* Copyright (C) 2002 The gtkmm Development Team
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+License follows:
+
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 2.1, February 1999
+
+ Copyright (C) 1991, 1999 Free Software Foundation, Inc.
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the Lesser GPL. It also counts
+ as the successor of the GNU Library Public License, version 2, hence
+ the version number 2.1.]
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+ This license, the Lesser General Public License, applies to some
+specially designated software packages--typically libraries--of the
+Free Software Foundation and other authors who decide to use it. You
+can use it too, but we suggest you first think carefully about whether
+this license or the ordinary General Public License is the better
+strategy to use in any particular case, based on the explanations below.
+
+ When we speak of free software, we are referring to freedom of use,
+not price. Our General Public Licenses are designed to make sure that
+you have the freedom to distribute copies of free software (and charge
+for this service if you wish); that you receive source code or can get
+it if you want it; that you can change the software and use pieces of
+it in new free programs; and that you are informed that you can do
+these things.
+
+ To protect your rights, we need to make restrictions that forbid
+distributors to deny you these rights or to ask you to surrender these
+rights. These restrictions translate to certain responsibilities for
+you if you distribute copies of the library or if you modify it.
+
+ For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you. You must make sure that they, too, receive or can get the source
+code. If you link other code with the library, you must provide
+complete object files to the recipients, so that they can relink them
+with the library after making changes to the library and recompiling
+it. And you must show them these terms so they know their rights.
+
+ We protect your rights with a two-step method: (1) we copyright the
+library, and (2) we offer you this license, which gives you legal
+permission to copy, distribute and/or modify the library.
+
+ To protect each distributor, we want to make it very clear that
+there is no warranty for the free library. Also, if the library is
+modified by someone else and passed on, the recipients should know
+that what they have is not the original version, so that the original
+author's reputation will not be affected by problems that might be
+introduced by others.
+
+ Finally, software patents pose a constant threat to the existence of
+any free program. We wish to make sure that a company cannot
+effectively restrict the users of a free program by obtaining a
+restrictive license from a patent holder. Therefore, we insist that
+any patent license obtained for a version of the library must be
+consistent with the full freedom of use specified in this license.
+
+ Most GNU software, including some libraries, is covered by the
+ordinary GNU General Public License. This license, the GNU Lesser
+General Public License, applies to certain designated libraries, and
+is quite different from the ordinary General Public License. We use
+this license for certain libraries in order to permit linking those
+libraries into non-free programs.
+
+ When a program is linked with a library, whether statically or using
+a shared library, the combination of the two is legally speaking a
+combined work, a derivative of the original library. The ordinary
+General Public License therefore permits such linking only if the
+entire combination fits its criteria of freedom. The Lesser General
+Public License permits more lax criteria for linking other code with
+the library.
+
+ We call this license the "Lesser" General Public License because it
+does Less to protect the user's freedom than the ordinary General
+Public License. It also provides other free software developers Less
+of an advantage over competing non-free programs. These disadvantages
+are the reason we use the ordinary General Public License for many
+libraries. However, the Lesser license provides advantages in certain
+special circumstances.
+
+ For example, on rare occasions, there may be a special need to
+encourage the widest possible use of a certain library, so that it becomes
+a de-facto standard. To achieve this, non-free programs must be
+allowed to use the library. A more frequent case is that a free
+library does the same job as widely used non-free libraries. In this
+case, there is little to gain by limiting the free library to free
+software only, so we use the Lesser General Public License.
+
+ In other cases, permission to use a particular library in non-free
+programs enables a greater number of people to use a large body of
+free software. For example, permission to use the GNU C Library in
+non-free programs enables many more people to use the whole GNU
+operating system, as well as its variant, the GNU/Linux operating
+system.
+
+ Although the Lesser General Public License is Less protective of the
+users' freedom, it does ensure that the user of a program that is
+linked with the Library has the freedom and the wherewithal to run
+that program using a modified version of the Library.
+
+ The precise terms and conditions for copying, distribution and
+modification follow. Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library". The
+former contains code derived from the library, whereas the latter must
+be combined with the library in order to run.
+
+ GNU LESSER GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License Agreement applies to any software library or other
+program which contains a notice placed by the copyright holder or
+other authorized party saying it may be distributed under the terms of
+this Lesser General Public License (also called "this License").
+Each licensee is addressed as "you".
+
+ A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+ The "Library", below, refers to any such software library or work
+which has been distributed under these terms. A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language. (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+ "Source code" for a work means the preferred form of the work for
+making modifications to it. For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control compilation
+and installation of the library.
+
+ Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it). Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+
+ 1. You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+ You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+
+ 2. You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) The modified work must itself be a software library.
+
+ b) You must cause the files modified to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ c) You must cause the whole of the work to be licensed at no
+ charge to all third parties under the terms of this License.
+
+ d) If a facility in the modified Library refers to a function or a
+ table of data to be supplied by an application program that uses
+ the facility, other than as an argument passed when the facility
+ is invoked, then you must make a good faith effort to ensure that,
+ in the event an application does not supply such function or
+ table, the facility still operates, and performs whatever part of
+ its purpose remains meaningful.
+
+ (For example, a function in a library to compute square roots has
+ a purpose that is entirely well-defined independent of the
+ application. Therefore, Subsection 2d requires that any
+ application-supplied function or table used by this function must
+ be optional: if the application does not supply it, the square
+ root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Library,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Library, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library. To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License. (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.) Do not make any other change in
+these notices.
+
+ Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+ This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+ 4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+ If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library". Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+ However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library". The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+ When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library. The
+threshold for this to be true is not precisely defined by law.
+
+ If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work. (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+ Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+
+ 6. As an exception to the Sections above, you may also combine or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+ You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License. You must supply a copy of this License. If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License. Also, you must do one
+of these things:
+
+ a) Accompany the work with the complete corresponding
+ machine-readable source code for the Library including whatever
+ changes were used in the work (which must be distributed under
+ Sections 1 and 2 above); and, if the work is an executable linked
+ with the Library, with the complete machine-readable "work that
+ uses the Library", as object code and/or source code, so that the
+ user can modify the Library and then relink to produce a modified
+ executable containing the modified Library. (It is understood
+ that the user who changes the contents of definitions files in the
+ Library will not necessarily be able to recompile the application
+ to use the modified definitions.)
+
+ b) Use a suitable shared library mechanism for linking with the
+ Library. A suitable mechanism is one that (1) uses at run time a
+ copy of the library already present on the user's computer system,
+ rather than copying library functions into the executable, and (2)
+ will operate properly with a modified version of the library, if
+ the user installs one, as long as the modified version is
+ interface-compatible with the version that the work was made with.
+
+ c) Accompany the work with a written offer, valid for at
+ least three years, to give the same user the materials
+ specified in Subsection 6a, above, for a charge no more
+ than the cost of performing this distribution.
+
+ d) If distribution of the work is made by offering access to copy
+ from a designated place, offer equivalent access to copy the above
+ specified materials from the same place.
+
+ e) Verify that the user has already received a copy of these
+ materials or that you have already sent this user a copy.
+
+ For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it. However, as a special exception,
+the materials to be distributed need not include anything that is
+normally distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+ It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system. Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+
+ 7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+ a) Accompany the combined library with a copy of the same work
+ based on the Library, uncombined with any other library
+ facilities. This must be distributed under the terms of the
+ Sections above.
+
+ b) Give prominent notice with the combined library of the fact
+ that part of it is a work based on the Library, and explaining
+ where to find the accompanying uncombined form of the same work.
+
+ 8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License. Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License. However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+ 9. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Library or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+ 10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties with
+this License.
+
+ 11. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all. For example, if a patent
+license would not permit royalty-free redistribution of the Library by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under any
+particular circumstance, the balance of the section is intended to apply,
+and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library under this License may add
+an explicit geographical distribution limitation excluding those countries,
+so that distribution is permitted only in or among countries not thus
+excluded. In such case, this License incorporates the limitation as if
+written in the body of this License.
+
+ 13. The Free Software Foundation may publish revised and/or new
+versions of the Lesser General Public License from time to time.
+Such new versions will be similar in spirit to the present version,
+but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Library
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation. If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+
+ 14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission. For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this. Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+ NO WARRANTY
+
+ 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Libraries
+
+ If you develop a new library, and you want it to be of the greatest
+possible use to the public, we recommend making it free software that
+everyone can redistribute and change. You can do so by permitting
+redistribution under these terms (or, alternatively, under the terms of the
+ordinary General Public License).
+
+ To apply these terms, attach the following notices to the library. It is
+safest to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least the
+"copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the library's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+Also add information on how to contact you by electronic and paper mail.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the library, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the
+ library `Frob' (a library for tweaking knobs) written by James Random Hacker.
+
+ <signature of Ty Coon>, 1 April 1990
+ Ty Coon, President of Vice
+
+That's all there is to it!
Added: trunk/licenses/utf8string.license
===================================================================
--- trunk/licenses/utf8string.license (rev 0)
+++ trunk/licenses/utf8string.license 2012-03-20 16:12:08 UTC (rev 217)
@@ -0,0 +1,25 @@
+// Copyright 2006 Nemanja Trifunovic
+
+/*
+Permission is hereby granted, free of charge, to any person or organization
+obtaining a copy of the software and accompanying documentation covered by
+this license (the "Software") to use, reproduce, display, distribute,
+execute, and transmit the Software, and to prepare derivative works of the
+Software, and to permit third-parties to whom the Software is furnished to
+do so, all subject to the following:
+
+The copyright notices in the Software and this entire statement, including
+the above license grant, this restriction and the following disclaimer,
+must be included in all copies of the Software, in whole or in part, and
+all derivative works of the Software, unless such copies or derivative
+works are solely in the form of machine-executable object code generated by
+a source language processor.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
+*/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tbr...@us...> - 2012-03-20 15:59:47
|
Revision: 216
http://xmlwrapp.svn.sourceforge.net/xmlwrapp/?rev=216&view=rev
Author: tbrowder2
Date: 2012-03-20 15:59:36 +0000 (Tue, 20 Mar 2012)
Log Message:
-----------
add the utf8 string headers
Modified Paths:
--------------
trunk/include/xmlwrappstring/xmlwrappstring.h
Added Paths:
-----------
trunk/include/xmlwrappstring/utf8/
trunk/include/xmlwrappstring/utf8/checked.h
trunk/include/xmlwrappstring/utf8/core.h
trunk/include/xmlwrappstring/utf8/unchecked.h
trunk/include/xmlwrappstring/utf8.h
Added: trunk/include/xmlwrappstring/utf8/checked.h
===================================================================
--- trunk/include/xmlwrappstring/utf8/checked.h (rev 0)
+++ trunk/include/xmlwrappstring/utf8/checked.h 2012-03-20 15:59:36 UTC (rev 216)
@@ -0,0 +1,325 @@
+#ifndef UTF8_FOR_CPP_CHECKED_H
+#define UTF8_FOR_CPP_CHECKED_H
+
+// Copyright 2006 Nemanja Trifunovic
+
+/*
+Permission is hereby granted, free of charge, to any person or organization
+obtaining a copy of the software and accompanying documentation covered by
+this license (the "Software") to use, reproduce, display, distribute,
+execute, and transmit the Software, and to prepare derivative works of the
+Software, and to permit third-parties to whom the Software is furnished to
+do so, all subject to the following:
+
+The copyright notices in the Software and this entire statement, including
+the above license grant, this restriction and the following disclaimer,
+must be included in all copies of the Software, in whole or in part, and
+all derivative works of the Software, unless such copies or derivative
+works are solely in the form of machine-executable object code generated by
+a source language processor.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
+*/
+
+
+#include "core.h"
+#include <stdexcept>
+
+namespace utf8
+{
+ // Base for the exceptions that may be thrown from the library
+ class exception : public std::exception {
+ };
+
+ // Exceptions that may be thrown from the library functions.
+ class invalid_code_point : public exception {
+ uint32_t cp;
+ public:
+ invalid_code_point(uint32_t cp) : cp(cp) {}
+ virtual const char* what() const throw() { return "Invalid code point"; }
+ uint32_t code_point() const {return cp;}
+ };
+
+ class invalid_utf8 : public exception {
+ uint8_t u8;
+ public:
+ invalid_utf8 (uint8_t u) : u8(u) {}
+ virtual const char* what() const throw() { return "Invalid UTF-8"; }
+ uint8_t utf8_octet() const {return u8;}
+ };
+
+ class invalid_utf16 : public exception {
+ uint16_t u16;
+ public:
+ invalid_utf16 (uint16_t u) : u16(u) {}
+ virtual const char* what() const throw() { return "Invalid UTF-16"; }
+ uint16_t utf16_word() const {return u16;}
+ };
+
+ class not_enough_room : public exception {
+ public:
+ virtual const char* what() const throw() { return "Not enough space"; }
+ };
+
+ /// The library API - functions intended to be called by the users
+
+ template <typename octet_iterator, typename output_iterator>
+ output_iterator replace_invalid(octet_iterator start, octet_iterator end, output_iterator out, uint32_t replacement)
+ {
+ while (start != end) {
+ octet_iterator sequence_start = start;
+ internal::utf_error err_code = internal::validate_next(start, end);
+ switch (err_code) {
+ case internal::UTF8_OK :
+ for (octet_iterator it = sequence_start; it != start; ++it)
+ *out++ = *it;
+ break;
+ case internal::NOT_ENOUGH_ROOM:
+ throw not_enough_room();
+ case internal::INVALID_LEAD:
+ append (replacement, out);
+ ++start;
+ break;
+ case internal::INCOMPLETE_SEQUENCE:
+ case internal::OVERLONG_SEQUENCE:
+ case internal::INVALID_CODE_POINT:
+ append (replacement, out);
+ ++start;
+ // just one replacement mark for the sequence
+ while (internal::is_trail(*start) && start != end)
+ ++start;
+ break;
+ }
+ }
+ return out;
+ }
+
+ template <typename octet_iterator, typename output_iterator>
+ inline output_iterator replace_invalid(octet_iterator start, octet_iterator end, output_iterator out)
+ {
+ static const uint32_t replacement_marker = internal::mask16(0xfffd);
+ return replace_invalid(start, end, out, replacement_marker);
+ }
+
+ template <typename octet_iterator>
+ octet_iterator append(uint32_t cp, octet_iterator result)
+ {
+ if (!internal::is_code_point_valid(cp))
+ throw invalid_code_point(cp);
+
+ if (cp < 0x80) // one octet
+ *(result++) = static_cast<uint8_t>(cp);
+ else if (cp < 0x800) { // two octets
+ *(result++) = static_cast<uint8_t>((cp >> 6) | 0xc0);
+ *(result++) = static_cast<uint8_t>((cp & 0x3f) | 0x80);
+ }
+ else if (cp < 0x10000) { // three octets
+ *(result++) = static_cast<uint8_t>((cp >> 12) | 0xe0);
+ *(result++) = static_cast<uint8_t>(((cp >> 6) & 0x3f) | 0x80);
+ *(result++) = static_cast<uint8_t>((cp & 0x3f) | 0x80);
+ }
+ else { // four octets
+ *(result++) = static_cast<uint8_t>((cp >> 18) | 0xf0);
+ *(result++) = static_cast<uint8_t>(((cp >> 12) & 0x3f) | 0x80);
+ *(result++) = static_cast<uint8_t>(((cp >> 6) & 0x3f) | 0x80);
+ *(result++) = static_cast<uint8_t>((cp & 0x3f) | 0x80);
+ }
+ return result;
+ }
+
+ template <typename octet_iterator>
+ uint32_t next(octet_iterator& it, octet_iterator end)
+ {
+ uint32_t cp = 0;
+ internal::utf_error err_code = internal::validate_next(it, end, &cp);
+ switch (err_code) {
+ case internal::UTF8_OK :
+ break;
+ case internal::NOT_ENOUGH_ROOM :
+ throw not_enough_room();
+ case internal::INVALID_LEAD :
+ case internal::INCOMPLETE_SEQUENCE :
+ case internal::OVERLONG_SEQUENCE :
+ throw invalid_utf8(*it);
+ case internal::INVALID_CODE_POINT :
+ throw invalid_code_point(cp);
+ }
+ return cp;
+ }
+
+ template <typename octet_iterator>
+ uint32_t peek_next(octet_iterator it, octet_iterator end)
+ {
+ return next(it, end);
+ }
+
+ template <typename octet_iterator>
+ uint32_t prior(octet_iterator& it, octet_iterator start)
+ {
+ // can't do much if it == start
+ if (it == start)
+ throw not_enough_room();
+
+ octet_iterator end = it;
+ // Go back until we hit either a lead octet or start
+ while (internal::is_trail(*(--it)))
+ if (it == start)
+ throw invalid_utf8(*it); // error - no lead byte in the sequence
+ return peek_next(it, end);
+ }
+
+ /// Deprecated in versions that include "prior"
+ template <typename octet_iterator>
+ uint32_t previous(octet_iterator& it, octet_iterator pass_start)
+ {
+ octet_iterator end = it;
+ while (internal::is_trail(*(--it)))
+ if (it == pass_start)
+ throw invalid_utf8(*it); // error - no lead byte in the sequence
+ octet_iterator temp = it;
+ return next(temp, end);
+ }
+
+ template <typename octet_iterator, typename distance_type>
+ void advance (octet_iterator& it, distance_type n, octet_iterator end)
+ {
+ for (distance_type i = 0; i < n; ++i)
+ next(it, end);
+ }
+
+ template <typename octet_iterator>
+ typename std::iterator_traits<octet_iterator>::difference_type
+ distance (octet_iterator first, octet_iterator last)
+ {
+ typename std::iterator_traits<octet_iterator>::difference_type dist;
+ for (dist = 0; first < last; ++dist)
+ next(first, last);
+ return dist;
+ }
+
+ template <typename u16bit_iterator, typename octet_iterator>
+ octet_iterator utf16to8 (u16bit_iterator start, u16bit_iterator end, octet_iterator result)
+ {
+ while (start != end) {
+ uint32_t cp = internal::mask16(*start++);
+ // Take care of surrogate pairs first
+ if (internal::is_lead_surrogate(cp)) {
+ if (start != end) {
+ uint32_t trail_surrogate = internal::mask16(*start++);
+ if (internal::is_trail_surrogate(trail_surrogate))
+ cp = (cp << 10) + trail_surrogate + internal::SURROGATE_OFFSET;
+ else
+ throw invalid_utf16(static_cast<uint16_t>(trail_surrogate));
+ }
+ else
+ throw invalid_utf16(static_cast<uint16_t>(cp));
+
+ }
+ // Lone trail surrogate
+ else if (internal::is_trail_surrogate(cp))
+ throw invalid_utf16(static_cast<uint16_t>(cp));
+
+ result = append(cp, result);
+ }
+ return result;
+ }
+
+ template <typename u16bit_iterator, typename octet_iterator>
+ u16bit_iterator utf8to16 (octet_iterator start, octet_iterator end, u16bit_iterator result)
+ {
+ while (start != end) {
+ uint32_t cp = next(start, end);
+ if (cp > 0xffff) { //make a surrogate pair
+ *result++ = static_cast<uint16_t>((cp >> 10) + internal::LEAD_OFFSET);
+ *result++ = static_cast<uint16_t>((cp & 0x3ff) + internal::TRAIL_SURROGATE_MIN);
+ }
+ else
+ *result++ = static_cast<uint16_t>(cp);
+ }
+ return result;
+ }
+
+ template <typename octet_iterator, typename u32bit_iterator>
+ octet_iterator utf32to8 (u32bit_iterator start, u32bit_iterator end, octet_iterator result)
+ {
+ while (start != end)
+ result = append(*(start++), result);
+
+ return result;
+ }
+
+ template <typename octet_iterator, typename u32bit_iterator>
+ u32bit_iterator utf8to32 (octet_iterator start, octet_iterator end, u32bit_iterator result)
+ {
+ while (start != end)
+ (*result++) = next(start, end);
+
+ return result;
+ }
+
+ // The iterator class
+ template <typename octet_iterator>
+ class iterator : public std::iterator <std::bidirectional_iterator_tag, uint32_t> {
+ octet_iterator it;
+ octet_iterator range_start;
+ octet_iterator range_end;
+ public:
+ iterator () {};
+ explicit iterator (const octet_iterator& octet_it,
+ const octet_iterator& range_start,
+ const octet_iterator& range_end) :
+ it(octet_it), range_start(range_start), range_end(range_end)
+ {
+ if (it < range_start || it > range_end)
+ throw std::out_of_range("Invalid utf-8 iterator position");
+ }
+ // the default "big three" are OK
+ octet_iterator base () const { return it; }
+ uint32_t operator * () const
+ {
+ octet_iterator temp = it;
+ return next(temp, range_end);
+ }
+ bool operator == (const iterator& rhs) const
+ {
+ if (range_start != rhs.range_start || range_end != rhs.range_end)
+ throw std::logic_error("Comparing utf-8 iterators defined with different ranges");
+ return (it == rhs.it);
+ }
+ bool operator != (const iterator& rhs) const
+ {
+ return !(operator == (rhs));
+ }
+ iterator& operator ++ ()
+ {
+ next(it, range_end);
+ return *this;
+ }
+ iterator operator ++ (int)
+ {
+ iterator temp = *this;
+ next(it, range_end);
+ return temp;
+ }
+ iterator& operator -- ()
+ {
+ prior(it, range_start);
+ return *this;
+ }
+ iterator operator -- (int)
+ {
+ iterator temp = *this;
+ prior(it, range_start);
+ return temp;
+ }
+ }; // class iterator
+
+} // namespace utf8
+
+#endif // UTF8_FOR_CPP_CHECKED_H
Property changes on: trunk/include/xmlwrappstring/utf8/checked.h
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:eol-style
+ native
Added: trunk/include/xmlwrappstring/utf8/core.h
===================================================================
--- trunk/include/xmlwrappstring/utf8/core.h (rev 0)
+++ trunk/include/xmlwrappstring/utf8/core.h 2012-03-20 15:59:36 UTC (rev 216)
@@ -0,0 +1,357 @@
+#ifndef UTF8_FOR_CPP_CORE_H
+#define UTF8_FOR_CPP_CORE_H
+
+// Copyright 2006 Nemanja Trifunovic
+
+/*
+Permission is hereby granted, free of charge, to any person or organization
+obtaining a copy of the software and accompanying documentation covered by
+this license (the "Software") to use, reproduce, display, distribute,
+execute, and transmit the Software, and to prepare derivative works of the
+Software, and to permit third-parties to whom the Software is furnished to
+do so, all subject to the following:
+
+The copyright notices in the Software and this entire statement, including
+the above license grant, this restriction and the following disclaimer,
+must be included in all copies of the Software, in whole or in part, and
+all derivative works of the Software, unless such copies or derivative
+works are solely in the form of machine-executable object code generated by
+a source language processor.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
+*/
+
+
+
+#include <iterator>
+
+namespace utf8
+{
+ // The typedefs for 8-bit, 16-bit and 32-bit unsigned integers
+ // You may need to change them to match your system.
+ // These typedefs have the same names as ones from cstdint, or boost/cstdint
+ typedef unsigned char uint8_t;
+ typedef unsigned short uint16_t;
+ typedef unsigned int uint32_t;
+
+// Helper code - not intended to be directly called by the library users. May be changed at any time
+namespace internal
+{
+ // Unicode constants
+ // Leading (high) surrogates: 0xd800 - 0xdbff
+ // Trailing (low) surrogates: 0xdc00 - 0xdfff
+ const uint16_t LEAD_SURROGATE_MIN = 0xd800u;
+ const uint16_t LEAD_SURROGATE_MAX = 0xdbffu;
+ const uint16_t TRAIL_SURROGATE_MIN = 0xdc00u;
+ const uint16_t TRAIL_SURROGATE_MAX = 0xdfffu;
+ const uint16_t LEAD_OFFSET = LEAD_SURROGATE_MIN - (0x10000 >> 10);
+ const uint32_t SURROGATE_OFFSET = 0x10000u - (LEAD_SURROGATE_MIN << 10) - TRAIL_SURROGATE_MIN;
+
+ // Maximum valid value for a Unicode code point
+ const uint32_t CODE_POINT_MAX = 0x0010ffffu;
+
+ template<typename octet_type>
+ inline uint8_t mask8(octet_type oc)
+ {
+ return static_cast<uint8_t>(0xff & oc);
+ }
+ template<typename u16_type>
+ inline uint16_t mask16(u16_type oc)
+ {
+ return static_cast<uint16_t>(0xffff & oc);
+ }
+ template<typename octet_type>
+ inline bool is_trail(octet_type oc)
+ {
+ return ((mask8(oc) >> 6) == 0x2);
+ }
+
+ template <typename u16>
+ inline bool is_lead_surrogate(u16 cp)
+ {
+ return (cp >= LEAD_SURROGATE_MIN && cp <= LEAD_SURROGATE_MAX);
+ }
+
+ template <typename u16>
+ inline bool is_trail_surrogate(u16 cp)
+ {
+ return (cp >= TRAIL_SURROGATE_MIN && cp <= TRAIL_SURROGATE_MAX);
+ }
+
+ template <typename u16>
+ inline bool is_surrogate(u16 cp)
+ {
+ return (cp >= LEAD_SURROGATE_MIN && cp <= TRAIL_SURROGATE_MAX);
+ }
+
+ template <typename u32>
+ inline bool is_code_point_valid(u32 cp)
+ {
+ return (cp <= CODE_POINT_MAX && !is_surrogate(cp));
+ }
+
+ template <typename octet_iterator>
+ inline typename std::iterator_traits<octet_iterator>::difference_type
+ sequence_length(octet_iterator lead_it)
+ {
+ uint8_t lead = mask8(*lead_it);
+ if (lead < 0x80)
+ return 1;
+ else if ((lead >> 5) == 0x6)
+ return 2;
+ else if ((lead >> 4) == 0xe)
+ return 3;
+ else if ((lead >> 3) == 0x1e)
+ return 4;
+ else
+ return 0;
+ }
+
+ template <typename octet_difference_type>
+ inline bool is_overlong_sequence(uint32_t cp, octet_difference_type length)
+ {
+ if (cp < 0x80) {
+ if (length != 1)
+ return true;
+ }
+ else if (cp < 0x800) {
+ if (length != 2)
+ return true;
+ }
+ else if (cp < 0x10000) {
+ if (length != 3)
+ return true;
+ }
+
+ return false;
+ }
+
+ enum utf_error {UTF8_OK, NOT_ENOUGH_ROOM, INVALID_LEAD, INCOMPLETE_SEQUENCE, OVERLONG_SEQUENCE, INVALID_CODE_POINT};
+
+ /// get_sequence_x functions decode utf-8 sequences of the length x
+
+ template <typename octet_iterator>
+ utf_error get_sequence_1(octet_iterator& it, octet_iterator end, uint32_t* code_point)
+ {
+ if (it != end) {
+ if (code_point)
+ *code_point = mask8(*it);
+ return UTF8_OK;
+ }
+ return NOT_ENOUGH_ROOM;
+ }
+
+ template <typename octet_iterator>
+ utf_error get_sequence_2(octet_iterator& it, octet_iterator end, uint32_t* code_point)
+ {
+ utf_error ret_code = NOT_ENOUGH_ROOM;
+
+ if (it != end) {
+ uint32_t cp = mask8(*it);
+ if (++it != end) {
+ if (is_trail(*it)) {
+ cp = ((cp << 6) & 0x7ff) + ((*it) & 0x3f);
+
+ if (code_point)
+ *code_point = cp;
+ ret_code = UTF8_OK;
+ }
+ else
+ ret_code = INCOMPLETE_SEQUENCE;
+ }
+ else
+ ret_code = NOT_ENOUGH_ROOM;
+ }
+
+ return ret_code;
+ }
+
+ template <typename octet_iterator>
+ utf_error get_sequence_3(octet_iterator& it, octet_iterator end, uint32_t* code_point)
+ {
+ utf_error ret_code = NOT_ENOUGH_ROOM;
+
+ if (it != end) {
+ uint32_t cp = mask8(*it);
+ if (++it != end) {
+ if (is_trail(*it)) {
+ cp = ((cp << 12) & 0xffff) + ((mask8(*it) << 6) & 0xfff);
+ if (++it != end) {
+ if (is_trail(*it)) {
+ cp += (*it) & 0x3f;
+
+ if (code_point)
+ *code_point = cp;
+ ret_code = UTF8_OK;
+ }
+ else
+ ret_code = INCOMPLETE_SEQUENCE;
+ }
+ else
+ ret_code = NOT_ENOUGH_ROOM;
+ }
+ else
+ ret_code = INCOMPLETE_SEQUENCE;
+ }
+ else
+ ret_code = NOT_ENOUGH_ROOM;
+ }
+
+ return ret_code;
+ }
+
+ template <typename octet_iterator>
+ utf_error get_sequence_4(octet_iterator& it, octet_iterator end, uint32_t* code_point)
+ {
+ utf_error ret_code = NOT_ENOUGH_ROOM;
+
+ if (it != end) {
+ uint32_t cp = mask8(*it);
+ if (++it != end) {
+ if (is_trail(*it)) {
+ cp = ((cp << 18) & 0x1fffff) + ((mask8(*it) << 12) & 0x3ffff);
+ if (++it != end) {
+ if (is_trail(*it)) {
+ cp += (mask8(*it) << 6) & 0xfff;
+ if (++it != end) {
+ if (is_trail(*it)) {
+ cp += (*it) & 0x3f;
+
+ if (code_point)
+ *code_point = cp;
+ ret_code = UTF8_OK;
+ }
+ else
+ ret_code = INCOMPLETE_SEQUENCE;
+ }
+ else
+ ret_code = NOT_ENOUGH_ROOM;
+ }
+ else
+ ret_code = INCOMPLETE_SEQUENCE;
+ }
+ else
+ ret_code = NOT_ENOUGH_ROOM;
+ }
+ else
+ ret_code = INCOMPLETE_SEQUENCE;
+ }
+ else
+ ret_code = NOT_ENOUGH_ROOM;
+ }
+
+ return ret_code;
+ }
+
+ template <typename octet_iterator>
+ utf_error validate_next(octet_iterator& it, octet_iterator end, uint32_t* code_point)
+ {
+ // Save the original value of it so we can go back in case of failure
+ // Of course, it does not make much sense with i.e. stream iterators
+ octet_iterator original_it = it;
+
+ uint32_t cp = 0;
+ // Determine the sequence length based on the lead octet
+ typedef typename std::iterator_traits<octet_iterator>::difference_type octet_difference_type;
+ octet_difference_type length = sequence_length(it);
+ if (length == 0)
+ return INVALID_LEAD;
+
+ // Now that we have a valid sequence length, get trail octets and calculate the code point
+ utf_error err = UTF8_OK;
+ switch (length) {
+ case 1:
+ err = get_sequence_1(it, end, &cp);
+ break;
+ case 2:
+ err = get_sequence_2(it, end, &cp);
+ break;
+ case 3:
+ err = get_sequence_3(it, end, &cp);
+ break;
+ case 4:
+ err = get_sequence_4(it, end, &cp);
+ break;
+ }
+
+ if (err == UTF8_OK) {
+ // Decoding succeeded. Now, security checks...
+ if (is_code_point_valid(cp)) {
+ if (!is_overlong_sequence(cp, length)){
+ // Passed! Return here.
+ if (code_point)
+ *code_point = cp;
+ ++it;
+ return UTF8_OK;
+ }
+ else
+ err = OVERLONG_SEQUENCE;
+ }
+ else
+ err = INVALID_CODE_POINT;
+ }
+
+ // Failure branch - restore the original value of the iterator
+ it = original_it;
+ return err;
+ }
+
+ template <typename octet_iterator>
+ inline utf_error validate_next(octet_iterator& it, octet_iterator end) {
+ return validate_next(it, end, 0);
+ }
+
+} // namespace internal
+
+ /// The library API - functions intended to be called by the users
+
+ // Byte order mark
+ const uint8_t bom[] = {0xef, 0xbb, 0xbf};
+
+ template <typename octet_iterator>
+ octet_iterator find_invalid(octet_iterator start, octet_iterator end)
+ {
+ octet_iterator result = start;
+ while (result != end) {
+ internal::utf_error err_code = internal::validate_next(result, end);
+ if (err_code != internal::UTF8_OK)
+ return result;
+ }
+ return result;
+ }
+
+ template <typename octet_iterator>
+ inline bool is_valid(octet_iterator start, octet_iterator end)
+ {
+ return (find_invalid(start, end) == end);
+ }
+
+ template <typename octet_iterator>
+ inline bool starts_with_bom (octet_iterator it, octet_iterator end)
+ {
+ return (
+ ((it != end) && (internal::mask8(*it++)) == bom[0]) &&
+ ((it != end) && (internal::mask8(*it++)) == bom[1]) &&
+ ((it != end) && (internal::mask8(*it)) == bom[2])
+ );
+ }
+
+ //Deprecated in release 2.3
+ template <typename octet_iterator>
+ inline bool is_bom (octet_iterator it)
+ {
+ return (
+ (internal::mask8(*it++)) == bom[0] &&
+ (internal::mask8(*it++)) == bom[1] &&
+ (internal::mask8(*it)) == bom[2]
+ );
+ }
+} // namespace utf8
+
+#endif // UTF8_FOR_CPP_CORE_H
Property changes on: trunk/include/xmlwrappstring/utf8/core.h
___________________________________________________________________
Added: svn:executable
+ *
Added: svn:mime-type
+ text/plain
Added: svn:eol-style
+ native
Added: trunk/include/xmlwrappstring/utf8/unchecked.h
===================================================================
--- trunk/include/xmlwrappstring/utf8/unchecked.h (rev 0)
+++ trunk/include/xmlwrappstring/utf8/unchecked.h 2012-03-20 15:59:36 UTC (rev 216)
@@ -0,0 +1,227 @@
+#ifndef UTF8_FOR_CPP_UNCHECKED_H
+#define UTF8_FOR_CPP_UNCHECKED_H
+
+// Copyright 2006 Nemanja Trifunovic
+
+/*
+Permission is hereby granted, free of charge, to any person or organization
+obtaining a copy of the software and accompanying documentation covered by
+this license (the "Software") to use, reproduce, display, distribute,
+execute, and transmit the Software, and to prepare derivative works of the
+Software, and to permit third-parties to whom the Software is furnished to
+do so, all subject to the following:
+
+The copyright notices in the Software and this entire statement, including
+the above license grant, this restriction and the following disclaimer,
+must be included in all copies of the Software, in whole or in part, and
+all derivative works of the Software, unless such copies or derivative
+works are solely in the form of machine-executable object code generated by
+a source language processor.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
+*/
+
+
+#include "core.h"
+
+namespace utf8
+{
+ namespace unchecked
+ {
+ template <typename octet_iterator>
+ octet_iterator append(uint32_t cp, octet_iterator result)
+ {
+ if (cp < 0x80) // one octet
+ *(result++) = static_cast<uint8_t>(cp);
+ else if (cp < 0x800) { // two octets
+ *(result++) = static_cast<uint8_t>((cp >> 6) | 0xc0);
+ *(result++) = static_cast<uint8_t>((cp & 0x3f) | 0x80);
+ }
+ else if (cp < 0x10000) { // three octets
+ *(result++) = static_cast<uint8_t>((cp >> 12) | 0xe0);
+ *(result++) = static_cast<uint8_t>(((cp >> 6) & 0x3f) | 0x80);
+ *(result++) = static_cast<uint8_t>((cp & 0x3f) | 0x80);
+ }
+ else { // four octets
+ *(result++) = static_cast<uint8_t>((cp >> 18) | 0xf0);
+ *(result++) = static_cast<uint8_t>(((cp >> 12) & 0x3f)| 0x80);
+ *(result++) = static_cast<uint8_t>(((cp >> 6) & 0x3f) | 0x80);
+ *(result++) = static_cast<uint8_t>((cp & 0x3f) | 0x80);
+ }
+ return result;
+ }
+
+ template <typename octet_iterator>
+ uint32_t next(octet_iterator& it)
+ {
+ uint32_t cp = internal::mask8(*it);
+ typename std::iterator_traits<octet_iterator>::difference_type length = utf8::internal::sequence_length(it);
+ switch (length) {
+ case 1:
+ break;
+ case 2:
+ it++;
+ cp = ((cp << 6) & 0x7ff) + ((*it) & 0x3f);
+ break;
+ case 3:
+ ++it;
+ cp = ((cp << 12) & 0xffff) + ((internal::mask8(*it) << 6) & 0xfff);
+ ++it;
+ cp += (*it) & 0x3f;
+ break;
+ case 4:
+ ++it;
+ cp = ((cp << 18) & 0x1fffff) + ((internal::mask8(*it) << 12) & 0x3ffff);
+ ++it;
+ cp += (internal::mask8(*it) << 6) & 0xfff;
+ ++it;
+ cp += (*it) & 0x3f;
+ break;
+ }
+ ++it;
+ return cp;
+ }
+
+ template <typename octet_iterator>
+ uint32_t peek_next(octet_iterator it)
+ {
+ return next(it);
+ }
+
+ template <typename octet_iterator>
+ uint32_t prior(octet_iterator& it)
+ {
+ while (internal::is_trail(*(--it))) ;
+ octet_iterator temp = it;
+ return next(temp);
+ }
+
+ // Deprecated in versions that include prior, but only for the sake of consistency (see utf8::previous)
+ template <typename octet_iterator>
+ inline uint32_t previous(octet_iterator& it)
+ {
+ return prior(it);
+ }
+
+ template <typename octet_iterator, typename distance_type>
+ void advance (octet_iterator& it, distance_type n)
+ {
+ for (distance_type i = 0; i < n; ++i)
+ next(it);
+ }
+
+ template <typename octet_iterator>
+ typename std::iterator_traits<octet_iterator>::difference_type
+ distance (octet_iterator first, octet_iterator last)
+ {
+ typename std::iterator_traits<octet_iterator>::difference_type dist;
+ for (dist = 0; first < last; ++dist)
+ next(first);
+ return dist;
+ }
+
+ template <typename u16bit_iterator, typename octet_iterator>
+ octet_iterator utf16to8 (u16bit_iterator start, u16bit_iterator end, octet_iterator result)
+ {
+ while (start != end) {
+ uint32_t cp = internal::mask16(*start++);
+ // Take care of surrogate pairs first
+ if (internal::is_lead_surrogate(cp)) {
+ uint32_t trail_surrogate = internal::mask16(*start++);
+ cp = (cp << 10) + trail_surrogate + internal::SURROGATE_OFFSET;
+ }
+ result = append(cp, result);
+ }
+ return result;
+ }
+
+ template <typename u16bit_iterator, typename octet_iterator>
+ u16bit_iterator utf8to16 (octet_iterator start, octet_iterator end, u16bit_iterator result)
+ {
+ while (start < end) {
+ uint32_t cp = next(start);
+ if (cp > 0xffff) { //make a surrogate pair
+ *result++ = static_cast<uint16_t>((cp >> 10) + internal::LEAD_OFFSET);
+ *result++ = static_cast<uint16_t>((cp & 0x3ff) + internal::TRAIL_SURROGATE_MIN);
+ }
+ else
+ *result++ = static_cast<uint16_t>(cp);
+ }
+ return result;
+ }
+
+ template <typename octet_iterator, typename u32bit_iterator>
+ octet_iterator utf32to8 (u32bit_iterator start, u32bit_iterator end, octet_iterator result)
+ {
+ while (start != end)
+ result = append(*(start++), result);
+
+ return result;
+ }
+
+ template <typename octet_iterator, typename u32bit_iterator>
+ u32bit_iterator utf8to32 (octet_iterator start, octet_iterator end, u32bit_iterator result)
+ {
+ while (start < end)
+ (*result++) = next(start);
+
+ return result;
+ }
+
+ // The iterator class
+ template <typename octet_iterator>
+ class iterator : public std::iterator <std::bidirectional_iterator_tag, uint32_t> {
+ octet_iterator it;
+ public:
+ iterator () {};
+ explicit iterator (const octet_iterator& octet_it): it(octet_it) {}
+ // the default "big three" are OK
+ octet_iterator base () const { return it; }
+ uint32_t operator * () const
+ {
+ octet_iterator temp = it;
+ return next(temp);
+ }
+ bool operator == (const iterator& rhs) const
+ {
+ return (it == rhs.it);
+ }
+ bool operator != (const iterator& rhs) const
+ {
+ return !(operator == (rhs));
+ }
+ iterator& operator ++ ()
+ {
+ std::advance(it, internal::sequence_length(it));
+ return *this;
+ }
+ iterator operator ++ (int)
+ {
+ iterator temp = *this;
+ std::advance(it, internal::sequence_length(it));
+ return temp;
+ }
+ iterator& operator -- ()
+ {
+ prior(it);
+ return *this;
+ }
+ iterator operator -- (int)
+ {
+ iterator temp = *this;
+ prior(it);
+ return temp;
+ }
+ }; // class iterator
+
+ } // namespace utf8::unchecked
+} // namespace utf8
+
+
+#endif // UTF8_FOR_CPP_UNCHECKED_H
Property changes on: trunk/include/xmlwrappstring/utf8/unchecked.h
___________________________________________________________________
Added: svn:executable
+ *
Added: svn:mime-type
+ text/plain
Added: svn:eol-style
+ native
Added: trunk/include/xmlwrappstring/utf8.h
===================================================================
--- trunk/include/xmlwrappstring/utf8.h (rev 0)
+++ trunk/include/xmlwrappstring/utf8.h 2012-03-20 15:59:36 UTC (rev 216)
@@ -0,0 +1,34 @@
+#ifndef UTF8_FOR_CPP_H
+#define UTF8_FOR_CPP_H
+
+// Copyright 2006 Nemanja Trifunovic
+
+/*
+Permission is hereby granted, free of charge, to any person or organization
+obtaining a copy of the software and accompanying documentation covered by
+this license (the "Software") to use, reproduce, display, distribute,
+execute, and transmit the Software, and to prepare derivative works of the
+Software, and to permit third-parties to whom the Software is furnished to
+do so, all subject to the following:
+
+The copyright notices in the Software and this entire statement, including
+the above license grant, this restriction and the following disclaimer,
+must be included in all copies of the Software, in whole or in part, and
+all derivative works of the Software, unless such copies or derivative
+works are solely in the form of machine-executable object code generated by
+a source language processor.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
+*/
+
+
+#include "utf8/checked.h"
+#include "utf8/unchecked.h"
+
+#endif // UTF8_FOR_CPP_H
Property changes on: trunk/include/xmlwrappstring/utf8.h
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:eol-style
+ native
Modified: trunk/include/xmlwrappstring/xmlwrappstring.h
===================================================================
--- trunk/include/xmlwrappstring/xmlwrappstring.h 2012-03-20 14:52:40 UTC (rev 215)
+++ trunk/include/xmlwrappstring/xmlwrappstring.h 2012-03-20 15:59:36 UTC (rev 216)
@@ -1,9 +1,6 @@
-// -*- c++ -*-
-#ifndef _GLIBMM_USTRING_H
-#define _GLIBMM_USTRING_H
+#ifndef XMLWRAPPSTRING_H
+#define XMLWRAPPSTRING_H
-/* $Id$ */
-
/* Copyright (C) 2002 The gtkmm Development Team
*
* This library is free software; you can redistribute it and/or
@@ -21,6 +18,8 @@
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+#include "utf8.h"
+
#include <glibmmconfig.h>
#include <glibmm/unicode.h>
#include <glib.h>
@@ -1612,4 +1611,5 @@
} // namespace Glib
-#endif /* _GLIBMM_USTRING_H */
+#endif // XMLWRAPPSTRING_H
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tbr...@us...> - 2012-03-20 14:52:50
|
Revision: 215
http://xmlwrapp.svn.sourceforge.net/xmlwrapp/?rev=215&view=rev
Author: tbrowder2
Date: 2012-03-20 14:52:40 +0000 (Tue, 20 Mar 2012)
Log Message:
-----------
xmlwrappstring header removed from local sources
Modified Paths:
--------------
trunk/src/Makefile.am
Modified: trunk/src/Makefile.am
===================================================================
--- trunk/src/Makefile.am 2012-03-20 14:49:40 UTC (rev 214)
+++ trunk/src/Makefile.am 2012-03-20 14:52:40 UTC (rev 215)
@@ -12,8 +12,7 @@
libxmlwrappstring_la_LDFLAGS = -version-info 6:0:1 -no-undefined
libxmlwrappstring_la_SOURCES = \
- libxmlwrappstring/xmlwrappstring.cc \
- libxmlwrappstring/xmlwrappstring.h
+ libxmlwrappstring/xmlwrappstring.cc
libxmlwrapp_la_CPPFLAGS = $(AM_CPPFLAGS) $(LIBXML_CFLAGS)
libxmlwrapp_la_LIBADD = $(LIBXML_LIBS)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tbr...@us...> - 2012-03-20 14:49:51
|
Revision: 214
http://xmlwrapp.svn.sourceforge.net/xmlwrapp/?rev=214&view=rev
Author: tbrowder2
Date: 2012-03-20 14:49:40 +0000 (Tue, 20 Mar 2012)
Log Message:
-----------
ensure Makefile.in files are removed with distclean target
Modified Paths:
--------------
trunk/Makefile.am
trunk/docs/Makefile.am
trunk/examples/01-tree_parsing/Makefile.am
trunk/examples/02-event_parsing/Makefile.am
trunk/examples/03-xml_generation/Makefile.am
trunk/examples/04-xslt/Makefile.am
trunk/examples/Makefile.am
trunk/include/Makefile.am
trunk/src/Makefile.am
trunk/tests/Makefile.am
Modified: trunk/Makefile.am
===================================================================
--- trunk/Makefile.am 2012-03-20 14:35:16 UTC (rev 213)
+++ trunk/Makefile.am 2012-03-20 14:49:40 UTC (rev 214)
@@ -21,3 +21,5 @@
dist-hook:
(cd $(distdir)/platform/Win32 ; bakefile_gen)
rm -f $(distdir)/platform/Win32/.bakefile_gen.state
+
+DISTCLEANFILES = Makefile.in
Modified: trunk/docs/Makefile.am
===================================================================
--- trunk/docs/Makefile.am 2012-03-20 14:35:16 UTC (rev 213)
+++ trunk/docs/Makefile.am 2012-03-20 14:49:40 UTC (rev 214)
@@ -5,3 +5,5 @@
dist-hook:
cd $(distdir) && doxygen
+
+DISTCLEANFILES = Makefile.in
Modified: trunk/examples/01-tree_parsing/Makefile.am
===================================================================
--- trunk/examples/01-tree_parsing/Makefile.am 2012-03-20 14:35:16 UTC (rev 213)
+++ trunk/examples/01-tree_parsing/Makefile.am 2012-03-20 14:49:40 UTC (rev 214)
@@ -4,3 +4,5 @@
example_SOURCES = example.cc
example_CPPFLAGS = -I$(top_srcdir)/include
example_LDADD = ../../src/libxmlwrapp.la
+
+DISTCLEANFILES = Makefile.in
Modified: trunk/examples/02-event_parsing/Makefile.am
===================================================================
--- trunk/examples/02-event_parsing/Makefile.am 2012-03-20 14:35:16 UTC (rev 213)
+++ trunk/examples/02-event_parsing/Makefile.am 2012-03-20 14:49:40 UTC (rev 214)
@@ -4,3 +4,5 @@
example_SOURCES = example.cc
example_CPPFLAGS = -I$(top_srcdir)/include
example_LDADD = ../../src/libxmlwrapp.la
+
+DISTCLEANFILES = Makefile.in
Modified: trunk/examples/03-xml_generation/Makefile.am
===================================================================
--- trunk/examples/03-xml_generation/Makefile.am 2012-03-20 14:35:16 UTC (rev 213)
+++ trunk/examples/03-xml_generation/Makefile.am 2012-03-20 14:49:40 UTC (rev 214)
@@ -4,3 +4,5 @@
example_SOURCES = example.cc
example_CPPFLAGS = -I$(top_srcdir)/include
example_LDADD = ../../src/libxmlwrapp.la
+
+DISTCLEANFILES = Makefile.in
Modified: trunk/examples/04-xslt/Makefile.am
===================================================================
--- trunk/examples/04-xslt/Makefile.am 2012-03-20 14:35:16 UTC (rev 213)
+++ trunk/examples/04-xslt/Makefile.am 2012-03-20 14:49:40 UTC (rev 214)
@@ -10,3 +10,5 @@
endif
EXTRA_DIST = example.xml example.xsl
+
+DISTCLEANFILES = Makefile.in
Modified: trunk/examples/Makefile.am
===================================================================
--- trunk/examples/Makefile.am 2012-03-20 14:35:16 UTC (rev 213)
+++ trunk/examples/Makefile.am 2012-03-20 14:49:40 UTC (rev 214)
@@ -4,3 +4,5 @@
02-event_parsing \
03-xml_generation \
04-xslt
+
+DISTCLEANFILES = Makefile.in
Modified: trunk/include/Makefile.am
===================================================================
--- trunk/include/Makefile.am 2012-03-20 14:35:16 UTC (rev 213)
+++ trunk/include/Makefile.am 2012-03-20 14:49:40 UTC (rev 214)
@@ -14,6 +14,10 @@
xmlwrapp/version.h \
xmlwrapp/xmlwrapp.h
+xmlwrappstring_includedir= $(includedir)/xmlwrappstring
+xmlwrappstring_include_HEADERS = \
+ xmlwrappstring/xmlwrappstring.h
+
if WITH_XSLT
xsltwrapp_includedir= $(includedir)/xsltwrapp
xsltwrapp_include_HEADERS = \
@@ -21,3 +25,5 @@
xsltwrapp/stylesheet.h \
xsltwrapp/xsltwrapp.h
endif
+
+DISTCLEANFILES = Makefile.in
Modified: trunk/src/Makefile.am
===================================================================
--- trunk/src/Makefile.am 2012-03-20 14:35:16 UTC (rev 213)
+++ trunk/src/Makefile.am 2012-03-20 14:49:40 UTC (rev 214)
@@ -52,3 +52,5 @@
libxslt/stylesheet.cc
endif
+
+DISTCLEANFILES = Makefile.in
Modified: trunk/tests/Makefile.am
===================================================================
--- trunk/tests/Makefile.am 2012-03-20 14:35:16 UTC (rev 213)
+++ trunk/tests/Makefile.am 2012-03-20 14:49:40 UTC (rev 214)
@@ -31,3 +31,5 @@
$(srcdir)/*/data/*.xsl \
$(srcdir)/*/data/*.dtd \
$(srcdir)/*/data/output
+
+DISTCLEANFILES = Makefile.in
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tbr...@us...> - 2012-03-20 14:35:28
|
Revision: 213
http://xmlwrapp.svn.sourceforge.net/xmlwrapp/?rev=213&view=rev
Author: tbrowder2
Date: 2012-03-20 14:35:16 +0000 (Tue, 20 Mar 2012)
Log Message:
-----------
correct autotools errors
Modified Paths:
--------------
trunk/src/Makefile.am
trunk/tests/Makefile.am
Removed Paths:
-------------
trunk/src/libxmlwrappstring/xmlwrappstring.h
Modified: trunk/src/Makefile.am
===================================================================
--- trunk/src/Makefile.am 2012-03-20 14:33:34 UTC (rev 212)
+++ trunk/src/Makefile.am 2012-03-20 14:35:16 UTC (rev 213)
@@ -13,7 +13,7 @@
libxmlwrappstring_la_SOURCES = \
libxmlwrappstring/xmlwrappstring.cc \
- libxmlwrappstring/xmlwrappstring.h \
+ libxmlwrappstring/xmlwrappstring.h
libxmlwrapp_la_CPPFLAGS = $(AM_CPPFLAGS) $(LIBXML_CFLAGS)
libxmlwrapp_la_LIBADD = $(LIBXML_LIBS)
Deleted: trunk/src/libxmlwrappstring/xmlwrappstring.h
===================================================================
--- trunk/src/libxmlwrappstring/xmlwrappstring.h 2012-03-20 14:33:34 UTC (rev 212)
+++ trunk/src/libxmlwrappstring/xmlwrappstring.h 2012-03-20 14:35:16 UTC (rev 213)
@@ -1,1615 +0,0 @@
-// -*- c++ -*-
-#ifndef _GLIBMM_USTRING_H
-#define _GLIBMM_USTRING_H
-
-/* $Id$ */
-
-/* Copyright (C) 2002 The gtkmm Development Team
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free
- * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#include <glibmmconfig.h>
-#include <glibmm/unicode.h>
-#include <glib.h>
-
-#include <iosfwd>
-#include <iterator>
-#include <sstream>
-#include <string>
-#ifndef GLIBMM_HAVE_STD_ITERATOR_TRAITS
-#include <cstddef> /* for ptrdiff_t */
-#endif
-
-namespace Glib
-{
-
-#ifndef DOXYGEN_SHOULD_SKIP_THIS
-#ifndef GLIBMM_HAVE_STD_ITERATOR_TRAITS
-
-template <class T>
-struct IteratorTraits
-{
- typedef typename T::iterator_category iterator_category;
- typedef typename T::value_type value_type;
- typedef typename T::difference_type difference_type;
- typedef typename T::pointer pointer;
- typedef typename T::reference reference;
-};
-
-template <class T>
-struct IteratorTraits<T*>
-{
- typedef std::random_access_iterator_tag iterator_category;
- typedef T value_type;
- typedef ptrdiff_t difference_type;
- typedef T* pointer;
- typedef T& reference;
-};
-
-template <class T>
-struct IteratorTraits<const T*>
-{
- typedef std::random_access_iterator_tag iterator_category;
- typedef T value_type;
- typedef ptrdiff_t difference_type;
- typedef const T* pointer;
- typedef const T& reference;
-};
-
-#endif /* GLIBMM_HAVE_STD_ITERATOR_TRAITS */
-#endif /* DOXYGEN_SHOULD_SKIP_THIS */
-
-
-/** The iterator type of Glib::ustring.
- * Note this is not a random access iterator but a bidirectional one,
- * since all index operations need to iterate over the UTF-8 data. Use
- * std::advance() to move to a certain position. However, all of the
- * relational operators are available:
- * <tt>== != < > <= >=</tt>
- *
- * A writeable iterator isn't provided because: The number of bytes of
- * the old UTF-8 character and the new one to write could be different.
- * Therefore, any write operation would invalidate all other iterators
- * pointing into the same string.
- */
-template <class T>
-class ustring_Iterator
-{
-public:
- typedef std::bidirectional_iterator_tag iterator_category;
- typedef gunichar value_type;
- typedef std::string::difference_type difference_type;
- typedef value_type reference;
- typedef void pointer;
-
- inline ustring_Iterator();
- inline ustring_Iterator(const ustring_Iterator<std::string::iterator>& other);
-
- inline value_type operator*() const;
-
- inline ustring_Iterator<T> & operator++();
- inline const ustring_Iterator<T> operator++(int);
- inline ustring_Iterator<T> & operator--();
- inline const ustring_Iterator<T> operator--(int);
-
- explicit inline ustring_Iterator(T pos);
- inline T base() const;
-
-private:
- T pos_;
-};
-
-
-/** Extract a UCS-4 character from UTF-8 data.
- * Convert a single UTF-8 (multibyte) character starting at @p pos to
- * a UCS-4 wide character. This may read up to 6 bytes after the start
- * position, depending on the UTF-8 character width. You have to make
- * sure the source contains at least one valid UTF-8 character.
- *
- * This is mainly used by the implementation of Glib::ustring::iterator,
- * but it might be useful as utility function if you prefer using
- * std::string even for UTF-8 encoding.
- */
-gunichar get_unichar_from_std_iterator(std::string::const_iterator pos) G_GNUC_PURE;
-
-
-/** Glib::ustring has much the same interface as std::string, but contains
- * %Unicode characters encoded as UTF-8.
- *
- * @par About UTF-8 and ASCII
- * @par
- * The standard character set ANSI_X3.4-1968 -- more commonly known as
- * ASCII -- is a subset of UTF-8. So, if you want to, you can use
- * Glib::ustring without even thinking about UTF-8.
- * @par
- * Whenever ASCII is mentioned in this manual, we mean the @em real ASCII
- * (i.e. as defined in ANSI_X3.4-1968), which contains only 7-bit characters.
- * Glib::ustring can @em not be used with ASCII-compatible extended 8-bit
- * charsets like ISO-8859-1. It's a good idea to avoid string literals
- * containing non-ASCII characters (e.g. German umlauts) in source code,
- * or at least you should use UTF-8 literals.
- * @par
- * You can find a detailed UTF-8 and %Unicode FAQ here:
- * http://www.cl.cam.ac.uk/~mgk25/unicode.html
- *
- * @par Glib::ustring vs. std::string
- * @par
- * Glib::ustring has implicit type conversions to and from std::string.
- * These conversions do @em not convert to/from the current locale (see
- * Glib::locale_from_utf8() and Glib::locale_to_utf8() if you need that). You
- * can always use std::string instead of Glib::ustring -- however, using
- * std::string with multi-byte characters is quite hard. For instance,
- * <tt>std::string::operator[]</tt> might return a byte in the middle of a
- * character, and <tt>std::string::length()</tt> returns the number of bytes
- * rather than characters. So don't do that without a good reason.
- * @par
- * In a perfect world the C++ Standard Library would contain a UTF-8 string
- * class. Unfortunately, the C++ standard doesn't mention UTF-8 at all. Note
- * that std::wstring is not a UTF-8 string class because it contains only
- * fixed-width characters (where width could be 32, 16, or even 8 bits).
- *
- * @par Glib::ustring and stream input/output
- * @par
- * The stream I/O operators, that is operator<<() and operator>>(), perform
- * implicit charset conversion to/from the current locale. If that's not
- * what you intented (e.g. when writing to a configuration file that should
- * always be UTF-8 encoded) use ustring::raw() to override this behaviour.
- * @par
- * If you're using std::ostringstream to build strings for display in the
- * user interface, you must convert the result back to UTF-8 as shown below:
- * @code
- * std::ostringstream output;
- * output.imbue(std::locale("")); // use the user's locale for this stream
- * output << percentage << " % done";
- * label->set_text(Glib::locale_to_utf8(output.str()));
- * @endcode
- *
- * @par Formatted output and internationalization
- * @par
- * The methods ustring::compose() and ustring::format() provide a convenient
- * and powerful alternative to string streams, as shown in the example below.
- * Refer to the method documentation of compose() and format() for details.
- * @code
- * using Glib::ustring;
- *
- * ustring message = ustring::compose("%1 is lower than 0x%2.",
- * 12, ustring::format(std::hex, 16));
- * @endcode
- *
- * @par Implementation notes
- * @par
- * Glib::ustring does not inherit from std::string, because std::string was
- * intended to be a final class. For instance, it does not have a virtual
- * destructor. Also, a HAS-A relationship is more appropriate because
- * ustring can't just enhance the std::string interface. Rather, it has to
- * reimplement the interface so that all operations are based on characters
- * instead of bytes.
- */
-class ustring
-{
-public:
- typedef std::string::size_type size_type;
- typedef std::string::difference_type difference_type;
-
- typedef gunichar value_type;
- typedef gunichar & reference;
- typedef const gunichar & const_reference;
-
- typedef ustring_Iterator<std::string::iterator> iterator;
- typedef ustring_Iterator<std::string::const_iterator> const_iterator;
-
-#ifndef GLIBMM_HAVE_SUN_REVERSE_ITERATOR
-
- typedef std::reverse_iterator<iterator> reverse_iterator;
- typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
-
-#else
-
- typedef std::reverse_iterator<iterator,
- iterator::iterator_category,
- iterator::value_type,
- iterator::reference,
- iterator::pointer,
- iterator::difference_type> reverse_iterator;
- typedef std::reverse_iterator<const_iterator,
- const_iterator::iterator_category,
- const_iterator::value_type,
- const_iterator::reference,
- const_iterator::pointer,
- const_iterator::difference_type> const_reverse_iterator;
-
-#endif /* GLIBMM_HAVE_SUN_REVERSE_ITERATOR */
-
-#ifdef GLIBMM_HAVE_ALLOWS_STATIC_INLINE_NPOS
- static GLIBMM_API const size_type npos = std::string::npos;
-#else
- //The IRIX MipsPro compiler says "The indicated constant value is not known",
- //so we need to initalize the static member data elsewhere.
- static GLIBMM_API const size_type npos;
-#endif
-
- /*! Default constructor, which creates an empty string.
- */
- ustring();
-
- ~ustring();
-
- /*! Construct a ustring as a copy of another ustring.
- * @param other A source string.
- */
- ustring(const ustring& other);
-
- /*! Assign the value of another string to this string.
- * @param other A source string.
- */
- ustring& operator=(const ustring& other);
-
- /*! Swap contents with another string.
- * @param other String to swap with.
- */
- void swap(ustring& other);
-
- /*! Construct a ustring as a copy of another std::string.
- * @param src A source <tt>std::string</tt> containing text encoded as UTF-8.
- */
- ustring(const std::string& src);
-
- /*! Construct a ustring as a copy of a substring.
- * @param src %Source ustring.
- * @param i Index of first character to copy from.
- * @param n Number of UTF-8 characters to copy (defaults to copying the remainder).
- */
- ustring(const ustring& src, size_type i, size_type n=npos);
-
- /*! Construct a ustring as a partial copy of a C string.
- * @param src %Source C string encoded as UTF-8.
- * @param n Number of UTF-8 characters to copy.
- */
- ustring(const char* src, size_type n);
-
- /*! Construct a ustring as a copy of a C string.
- * @param src %Source C string encoded as UTF-8.
- */
- ustring(const char* src);
-
- /*! Construct a ustring as multiple characters.
- * @param n Number of characters.
- * @param uc UCS-4 code point to use.
- */
- ustring(size_type n, gunichar uc);
-
- /*! Construct a ustring as multiple characters.
- * @param n Number of characters.
- * @param c ASCII character to use.
- */
- ustring(size_type n, char c);
-
- /*! Construct a ustring as a copy of a range.
- * @param pbegin Start of range.
- * @param pend End of range.
- */
- template <class In> ustring(In pbegin, In pend);
-
-
-//! @name Assign new contents.
-//! @{
-
- ustring& operator=(const std::string& src);
- ustring& operator=(const char* src);
- ustring& operator=(gunichar uc);
- ustring& operator=(char c);
-
- ustring& assign(const ustring& src);
- ustring& assign(const ustring& src, size_type i, size_type n);
- ustring& assign(const char* src, size_type n);
- ustring& assign(const char* src);
- ustring& assign(size_type n, gunichar uc);
- ustring& assign(size_type n, char c);
- template <class In> ustring& assign(In pbegin, In pend);
-
-//! @}
-//! @name Append to the string.
-//! @{
-
- ustring& operator+=(const ustring& src);
- ustring& operator+=(const char* src);
- ustring& operator+=(gunichar uc);
- ustring& operator+=(char c);
- void push_back(gunichar uc);
- void push_back(char c);
-
- ustring& append(const ustring& src);
- ustring& append(const ustring& src, size_type i, size_type n);
- ustring& append(const char* src, size_type n);
- ustring& append(const char* src);
- ustring& append(size_type n, gunichar uc);
- ustring& append(size_type n, char c);
- template <class In> ustring& append(In pbegin, In pend);
-
-//! @}
-//! @name Insert into the string.
-//! @{
-
- ustring& insert(size_type i, const ustring& src);
- ustring& insert(size_type i, const ustring& src, size_type i2, size_type n);
- ustring& insert(size_type i, const char* src, size_type n);
- ustring& insert(size_type i, const char* src);
- ustring& insert(size_type i, size_type n, gunichar uc);
- ustring& insert(size_type i, size_type n, char c);
-
- iterator insert(iterator p, gunichar uc);
- iterator insert(iterator p, char c);
- void insert(iterator p, size_type n, gunichar uc);
- void insert(iterator p, size_type n, char c);
- template <class In> void insert(iterator p, In pbegin, In pend);
-
-//! @}
-//! @name Replace sub-strings.
-//! @{
-
- ustring& replace(size_type i, size_type n, const ustring& src);
- ustring& replace(size_type i, size_type n, const ustring& src, size_type i2, size_type n2);
- ustring& replace(size_type i, size_type n, const char* src, size_type n2);
- ustring& replace(size_type i, size_type n, const char* src);
- ustring& replace(size_type i, size_type n, size_type n2, gunichar uc);
- ustring& replace(size_type i, size_type n, size_type n2, char c);
-
- ustring& replace(iterator pbegin, iterator pend, const ustring& src);
- ustring& replace(iterator pbegin, iterator pend, const char* src, size_type n);
- ustring& replace(iterator pbegin, iterator pend, const char* src);
- ustring& replace(iterator pbegin, iterator pend, size_type n, gunichar uc);
- ustring& replace(iterator pbegin, iterator pend, size_type n, char c);
- template <class In> ustring& replace(iterator pbegin, iterator pend, In pbegin2, In pend2);
-
-//! @}
-//! @name Erase sub-strings.
-//! @{
-
- void clear();
- ustring& erase(size_type i, size_type n=npos);
- ustring& erase();
- iterator erase(iterator p);
- iterator erase(iterator pbegin, iterator pend);
-
-//! @}
-//! @name Compare and collate.
-//! @{
-
- int compare(const ustring& rhs) const;
- int compare(const char* rhs) const;
- int compare(size_type i, size_type n, const ustring& rhs) const;
- int compare(size_type i, size_type n, const ustring& rhs, size_type i2, size_type n2) const;
- int compare(size_type i, size_type n, const char* rhs, size_type n2) const;
- int compare(size_type i, size_type n, const char* rhs) const;
-
- /*! Create a unique sorting key for the UTF-8 string. If you need to
- * compare UTF-8 strings regularly, e.g. for sorted containers such as
- * <tt>std::set<></tt>, you should consider creating a collate key first
- * and compare this key instead of the actual string.
- *
- * The ustring::compare() methods as well as the relational operators
- * <tt>== != < > <= >=</tt> are quite costly
- * because they have to deal with %Unicode and the collation rules defined by
- * the current locale. Converting both operands to UCS-4 is just the first
- * of several costly steps involved when comparing ustrings. So be careful.
- */
- std::string collate_key() const;
-
- /*! Create a unique key for the UTF-8 string that can be used for caseless
- * sorting. <tt>ustr.casefold_collate_key()</tt> results in the same string
- * as <tt>ustr.casefold().collate_key()</tt>, but the former is likely more
- * efficient.
- */
- std::string casefold_collate_key() const;
-
-//! @}
-//! @name Extract characters and sub-strings.
-//! @{
-
- /*! No reference return; use replace() to write characters. */
- value_type operator[](size_type i) const;
-
- /*! No reference return; use replace() to write characters. @throw std::out_of_range */
- value_type at(size_type i) const;
-
- inline ustring substr(size_type i=0, size_type n=npos) const;
-
-//! @}
-//! @name Access a sequence of characters.
-//! @{
-
- iterator begin();
- iterator end();
- const_iterator begin() const;
- const_iterator end() const;
- reverse_iterator rbegin();
- reverse_iterator rend();
- const_reverse_iterator rbegin() const;
- const_reverse_iterator rend() const;
-
-//! @}
-//! @name Find sub-strings.
-//! @{
-
- size_type find(const ustring& str, size_type i=0) const;
- size_type find(const char* str, size_type i, size_type n) const;
- size_type find(const char* str, size_type i=0) const;
- size_type find(gunichar uc, size_type i=0) const;
- size_type find(char c, size_type i=0) const;
-
- size_type rfind(const ustring& str, size_type i=npos) const;
- size_type rfind(const char* str, size_type i, size_type n) const;
- size_type rfind(const char* str, size_type i=npos) const;
- size_type rfind(gunichar uc, size_type i=npos) const;
- size_type rfind(char c, size_type i=npos) const;
-
-//! @}
-//! @name Match against a set of characters.
-//! @{
-
- size_type find_first_of(const ustring& match, size_type i=0) const;
- size_type find_first_of(const char* match, size_type i, size_type n) const;
- size_type find_first_of(const char* match, size_type i=0) const;
- size_type find_first_of(gunichar uc, size_type i=0) const;
- size_type find_first_of(char c, size_type i=0) const;
-
- size_type find_last_of(const ustring& match, size_type i=npos) const;
- size_type find_last_of(const char* match, size_type i, size_type n) const;
- size_type find_last_of(const char* match, size_type i=npos) const;
- size_type find_last_of(gunichar uc, size_type i=npos) const;
- size_type find_last_of(char c, size_type i=npos) const;
-
- size_type find_first_not_of(const ustring& match, size_type i=0) const;
- size_type find_first_not_of(const char* match, size_type i, size_type n) const;
- size_type find_first_not_of(const char* match, size_type i=0) const;
- size_type find_first_not_of(gunichar uc, size_type i=0) const;
- size_type find_first_not_of(char c, size_type i=0) const;
-
- size_type find_last_not_of(const ustring& match, size_type i=npos) const;
- size_type find_last_not_of(const char* match, size_type i, size_type n) const;
- size_type find_last_not_of(const char* match, size_type i=npos) const;
- size_type find_last_not_of(gunichar uc, size_type i=npos) const;
- size_type find_last_not_of(char c, size_type i=npos) const;
-
-//! @}
-//! @name Retrieve the string's size.
-//! @{
-
- /** Returns true if the string is empty. Equivalent to *this == "".
- * @result Whether the string is empty.
- */
- bool empty() const;
-
- /** Returns the number of characters in the string, not including any null-termination.
- * @result The number of UTF-8 characters.
- *
- * @see bytes(), empty()
- */
- size_type size() const;
-
- //We have length() as well as size(), because std::string has both.
-
- /** This is the same as size().
- */
- size_type length() const;
-
- /** Returns the number of bytes in the string, not including any null-termination.
- * @result The number of bytes.
- *
- * @see size(), empty()
- */
- size_type bytes() const;
-
-//! @}
-//! @name Change the string's size.
-//! @{
-
- void resize(size_type n, gunichar uc);
- void resize(size_type n, char c='\0');
-
-//! @}
-//! @name Control the allocated memory.
-//! @{
-
- size_type capacity() const;
- size_type max_size() const;
- void reserve(size_type n=0);
-
-//! @}
-//! @name Get a per-byte representation of the string.
-//! @{
-
- inline operator std::string() const; // e.g. std::string str = ustring();
- inline const std::string& raw() const;
-
- // Not necessarily an ASCII char*. Use g_utf8_*() where necessary.
- const char* data() const;
- const char* c_str() const;
-
- /*! @return Number of copied @em bytes, not characters. */
- size_type copy(char* dest, size_type n, size_type i=0) const;
-
-//! @}
-//! @name UTF-8 utilities.
-//! @{
-
- /*! Check whether the string is valid UTF-8. */
- bool validate() const;
-
- /*! Check whether the string is valid UTF-8. */
- bool validate(iterator& first_invalid);
-
- /*! Check whether the string is valid UTF-8. */
- bool validate(const_iterator& first_invalid) const;
-
- /*! Check whether the string is plain 7-bit ASCII. @par
- * Unlike any other ustring method, is_ascii() is safe to use on invalid
- * UTF-8 strings. If the string isn't valid UTF-8, it cannot be valid
- * ASCII either, therefore is_ascii() will just return @c false then.
- * @return Whether the string contains only ASCII characters.
- */
- bool is_ascii() const;
-
- /*! "Normalize" the %Unicode character representation of the string. */
- ustring normalize(NormalizeMode mode = NORMALIZE_DEFAULT_COMPOSE) const;
-
-//! @}
-//! @name Character case conversion.
-//! @{
-
- /*! Returns a new UTF-8 string with all characters characters converted to
- * their uppercase equivalent, while honoring the current locale. The
- * resulting string may change in the number of bytes as well as in the
- * number of characters. For instance, the German sharp s
- * <tt>"ß"</tt> will be replaced by two characters
- * <tt>"SS"</tt> because there is no capital <tt>"ß"</tt>.
- */
- ustring uppercase() const;
-
- /*! Returns a new UTF-8 string with all characters characters converted to
- * their lowercase equivalent, while honoring the current locale. The
- * resulting string may change in the number of bytes as well as in the
- * number of characters.
- */
- ustring lowercase() const;
-
- /*! Returns a caseless representation of the UTF-8 string. The resulting
- * string doesn't correspond to any particular case, therefore the result
- * is only useful to compare strings and should never be displayed to the
- * user.
- */
- ustring casefold() const;
-
-//! @}
-//! @name Message formatting.
-//! @{
-
- /* Returns fmt as is, but checks for invalid references in the format string.
- * @newin{2,18}
- */
- template <class T1>
- static inline
- ustring compose(const ustring& fmt);
-
- /*! Substitute placeholders in a format string with the referenced arguments.
- * The template string should be in <tt>qt-format</tt>, that is
- * <tt>"%1"</tt>, <tt>"%2"</tt>, ..., <tt>"%9"</tt> are used as placeholders
- * and <tt>"%%"</tt> denotes a literal <tt>"%"</tt>. Substitutions may be
- * reordered.
- * @par Example:
- * @code
- * using Glib::ustring;
- * const int percentage = 50;
- * const ustring text = ustring::compose("%1%% done", percentage);
- * @endcode
- * @param fmt A template string in <tt>qt-format</tt>.
- * @param a1 The argument to substitute for <tt>"%1"</tt>.
- * @return The substituted message string.
- * @throw Glib::ConvertError
- *
- * @newin{2,16}
- */
- template <class T1>
- static inline
- ustring compose(const ustring& fmt, const T1& a1);
-
- /* See the documentation for compose(const ustring& fmt, const T1& a1).
- * @newin{2,16}
- */
- template <class T1, class T2>
- static inline
- ustring compose(const ustring& fmt, const T1& a1, const T2& a2);
-
- /* See the documentation for compose(const ustring& fmt, const T1& a1).
- * @newin{2,16}
- */
- template <class T1, class T2, class T3>
- static inline
- ustring compose(const ustring& fmt,
- const T1& a1, const T2& a2, const T3& a3);
-
- /* See the documentation for compose(const ustring& fmt, const T1& a1).
- * @newin{2,16}
- */
- template <class T1, class T2, class T3, class T4>
- static inline
- ustring compose(const ustring& fmt,
- const T1& a1, const T2& a2, const T3& a3,
- const T4& a4);
-
- /* See the documentation for compose(const ustring& fmt, const T1& a1).
- * @newin{2,16}
- */
- template <class T1, class T2, class T3, class T4, class T5>
- static inline
- ustring compose(const ustring& fmt,
- const T1& a1, const T2& a2, const T3& a3,
- const T4& a4, const T5& a5);
-
- /* See the documentation for compose(const ustring& fmt, const T1& a1).
- * @newin{2,16}
- */
- template <class T1, class T2, class T3, class T4, class T5, class T6>
- static inline
- ustring compose(const ustring& fmt,
- const T1& a1, const T2& a2, const T3& a3,
- const T4& a4, const T5& a5, const T6& a6);
-
- /* See the documentation for compose(const ustring& fmt, const T1& a1).
- * @newin{2,16}
- */
- template <class T1, class T2, class T3, class T4, class T5, class T6, class T7>
- static inline
- ustring compose(const ustring& fmt,
- const T1& a1, const T2& a2, const T3& a3,
- const T4& a4, const T5& a5, const T6& a6,
- const T7& a7);
-
- /* See the documentation for compose(const ustring& fmt, const T1& a1).
- * @newin{2,16}
- */
- template <class T1, class T2, class T3, class T4,
- class T5, class T6, class T7, class T8>
- static inline
- ustring compose(const ustring& fmt,
- const T1& a1, const T2& a2, const T3& a3,
- const T4& a4, const T5& a5, const T6& a6,
- const T7& a7, const T8& a8);
-
- /* See the documentation for compose(const ustring& fmt, const T1& a1).
- * @newin{2,16}
- */
- template <class T1, class T2, class T3, class T4, class T5,
- class T6, class T7, class T8, class T9>
- static inline
- ustring compose(const ustring& fmt,
- const T1& a1, const T2& a2, const T3& a3,
- const T4& a4, const T5& a5, const T6& a6,
- const T7& a7, const T8& a8, const T9& a9);
-
- /*! Format the argument to its string representation.
- * Applies the arguments in order to an std::wostringstream and returns the
- * resulting string. I/O manipulators may also be used as arguments. This
- * greatly simplifies the common task of converting a number to a string, as
- * demonstrated by the example below. The format() methods can also be used
- * in conjunction with compose() to facilitate localization of user-visible
- * messages.
- * @code
- * using Glib::ustring;
- * double value = 22.0 / 7.0;
- * ustring text = ustring::format(std::fixed, std::setprecision(2), value);
- * @endcode
- * @note The use of a wide character stream in the implementation of format()
- * is almost completely transparent. However, one of the instances where the
- * use of wide streams becomes visible is when the std::setfill() stream
- * manipulator is used. In order for std::setfill() to work the argument
- * must be of type <tt>wchar_t</tt>. This can be achieved by using the
- * <tt>L</tt> prefix with a character literal, as shown in the example.
- * @code
- * using Glib::ustring;
- * // Insert leading zeroes to fill in at least six digits
- * ustring text = ustring::format(std::setfill(L'0'), std::setw(6), 123);
- * @endcode
- *
- * @param a1 A streamable value or an I/O manipulator.
- * @return The string representation of the argument stream.
- * @throw Glib::ConvertError
- *
- * @newin{2,16}
- */
- template <class T1>
- static inline
- ustring format(const T1& a1);
-
- /* See the documentation for format(const T1& a1).
- *
- * @newin{2,16}
- */
- template <class T1, class T2>
- static inline
- ustring format(const T1& a1, const T2& a2);
-
- /* See the documentation for format(const T1& a1).
- *
- * @newin{2,16}
- */
- template <class T1, class T2, class T3>
- static inline
- ustring format(const T1& a1, const T2& a2, const T3& a3);
-
- /* See the documentation for format(const T1& a1).
- *
- * @newin{2,16}
- */
- template <class T1, class T2, class T3, class T4>
- static inline
- ustring format(const T1& a1, const T2& a2, const T3& a3, const T4& a4);
-
- /* See the documentation for format(const T1& a1).
- *
- * @newin{2,16}
- */
- template <class T1, class T2, class T3, class T4, class T5>
- static inline
- ustring format(const T1& a1, const T2& a2, const T3& a3,
- const T4& a4, const T5& a5);
-
- /* See the documentation for format(const T1& a1).
- *
- * @newin{2,16}
- */
- template <class T1, class T2, class T3, class T4, class T5, class T6>
- static inline
- ustring format(const T1& a1, const T2& a2, const T3& a3,
- const T4& a4, const T5& a5, const T6& a6);
-
- /* See the documentation for format(const T1& a1).
- *
- * @newin{2,16}
- */
- template <class T1, class T2, class T3, class T4,
- class T5, class T6, class T7>
- static inline
- ustring format(const T1& a1, const T2& a2, const T3& a3, const T4& a4,
- const T5& a5, const T6& a6, const T7& a7);
-
- /* See the documentation for format(const T1& a1).
- *
- * @newin{2,16}
- */
- template <class T1, class T2, class T3, class T4,
- class T5, class T6, class T7, class T8>
- static inline
- ustring format(const T1& a1, const T2& a2, const T3& a3, const T4& a4,
- const T5& a5, const T6& a6, const T7& a7, const T8& a8);
-//! @}
-
-private:
-
-#ifndef DOXYGEN_SHOULD_SKIP_THIS
-
-#ifdef GLIBMM_HAVE_STD_ITERATOR_TRAITS
- template <class In, class ValueType = typename std::iterator_traits<In>::value_type>
-#else
- template <class In, class ValueType = typename Glib::IteratorTraits<In>::value_type>
-#endif
- struct SequenceToString;
-
- //The Tru64 compiler needs these partial specializations to be declared here,
- //as well as defined later. That's probably correct. murrayc.
- template <class In> struct SequenceToString<In, char>;
- template <class In> struct SequenceToString<In, gunichar>;
-
- template <class T> class Stringify;
- class FormatStream;
-
- static ustring compose_argv(const ustring& fmt, int argc, const ustring* const* argv);
-
-#endif /* DOXYGEN_SHOULD_SKIP_THIS */
-
- std::string string_;
-};
-
-
-#ifndef DOXYGEN_SHOULD_SKIP_THIS
-
-template <class In, class ValueType>
-struct ustring::SequenceToString
-{};
-
-template <class In>
-struct ustring::SequenceToString<In, char> : public std::string
-{
- SequenceToString(In pbegin, In pend);
-};
-
-template <class In>
-struct ustring::SequenceToString<In, gunichar> : public std::string
-{
- SequenceToString(In pbegin, In pend);
-};
-
-template <>
-struct ustring::SequenceToString<Glib::ustring::iterator, gunichar> : public std::string
-{
- SequenceToString(Glib::ustring::iterator pbegin, Glib::ustring::iterator pend);
-};
-
-template <>
-struct ustring::SequenceToString<Glib::ustring::const_iterator, gunichar> : public std::string
-{
- SequenceToString(Glib::ustring::const_iterator pbegin, Glib::ustring::const_iterator pend);
-};
-
-class ustring::FormatStream
-{
-private:
-#ifdef GLIBMM_HAVE_WIDE_STREAM
- typedef std::wostringstream StreamType;
-#else
- typedef std::ostringstream StreamType;
-#endif
- StreamType stream_;
-
- // noncopyable
- FormatStream(const ustring::FormatStream&);
- FormatStream& operator=(const ustring::FormatStream&);
-
-public:
- FormatStream();
- ~FormatStream();
-
- template <class T> inline void stream(const T& value);
-
- inline void stream(const char* value);
-
- //This overload exists to avoid the templated stream() being called for non-const char*.
- inline void stream(char* value);
-
- ustring to_string() const;
-};
-
-#endif /* DOXYGEN_SHOULD_SKIP_THIS */
-
-
-/** Stream input operator.
- * @relates Glib::ustring
- * @throw Glib::ConvertError
- */
-std::istream& operator>>(std::istream& is, Glib::ustring& utf8_string);
-
-/** Stream output operator.
- * @relates Glib::ustring
- * @throw Glib::ConvertError
- */
-std::ostream& operator<<(std::ostream& os, const Glib::ustring& utf8_string);
-
-#ifdef GLIBMM_HAVE_WIDE_STREAM
-
-/** Wide stream input operator.
- * @relates Glib::ustring
- * @throw Glib::ConvertError
- */
-std::wistream& operator>>(std::wistream& is, ustring& utf8_string);
-
-/** Wide stream output operator.
- * @relates Glib::ustring
- * @throw Glib::ConvertError
- */
-std::wostream& operator<<(std::wostream& os, const ustring& utf8_string);
-
-#endif /* GLIBMM_HAVE_WIDE_STREAM */
-
-/***************************************************************************/
-/* Inline implementation */
-/***************************************************************************/
-
-#ifndef DOXYGEN_SHOULD_SKIP_THIS
-
-/**** Glib::ustring_Iterator<> *********************************************/
-
-template <class T> inline
-ustring_Iterator<T>::ustring_Iterator(T pos)
-:
- pos_ (pos)
-{}
-
-template <class T> inline
-T ustring_Iterator<T>::base() const
-{
- return pos_;
-}
-
-template <class T> inline
-ustring_Iterator<T>::ustring_Iterator()
-:
- pos_ ()
-{}
-
-template <class T> inline
-ustring_Iterator<T>::ustring_Iterator(const ustring_Iterator<std::string::iterator>& other)
-:
- pos_ (other.base())
-{}
-
-template <class T> inline
-typename ustring_Iterator<T>::value_type ustring_Iterator<T>::operator*() const
-{
- return Glib::get_unichar_from_std_iterator(pos_);
-}
-
-template <class T> inline
-ustring_Iterator<T>& ustring_Iterator<T>::operator++()
-{
- pos_ += g_utf8_skip[static_cast<unsigned char>(*pos_)];
- return *this;
-}
-
-template <class T> inline
-const ustring_Iterator<T> ustring_Iterator<T>::operator++(int)
-{
- const ustring_Iterator<T> temp (*this);
- this->operator++();
- return temp;
-}
-
-template <class T> inline
-ustring_Iterator<T>& ustring_Iterator<T>::operator--()
-{
- do --pos_; while((static_cast<unsigned char>(*pos_) & 0xC0u) == 0x80);
- return *this;
-}
-
-template <class T> inline
-const ustring_Iterator<T> ustring_Iterator<T>::operator--(int)
-{
- const ustring_Iterator<T> temp (*this);
- this->operator--();
- return temp;
-}
-
-#endif /* DOXYGEN_SHOULD_SKIP_THIS */
-
-
-/** @relates Glib::ustring_Iterator */
-inline
-bool operator==(const Glib::ustring::const_iterator& lhs, const Glib::ustring::const_iterator& rhs)
-{
- return (lhs.base() == rhs.base());
-}
-
-/** @relates Glib::ustring_Iterator */
-inline
-bool operator!=(const Glib::ustring::const_iterator& lhs, const Glib::ustring::const_iterator& rhs)
-{
- return (lhs.base() != rhs.base());
-}
-
-/** @relates Glib::ustring_Iterator */
-inline
-bool operator<(const Glib::ustring::const_iterator& lhs, const Glib::ustring::const_iterator& rhs)
-{
- return (lhs.base() < rhs.base());
-}
-
-/** @relates Glib::ustring_Iterator */
-inline
-bool operator>(const Glib::ustring::const_iterator& lhs, const Glib::ustring::const_iterator& rhs)
-{
- return (lhs.base() > rhs.base());
-}
-
-/** @relates Glib::ustring_Iterator */
-inline
-bool operator<=(const Glib::ustring::const_iterator& lhs, const Glib::ustring::const_iterator& rhs)
-{
- return (lhs.base() <= rhs.base());
-}
-
-/** @relates Glib::ustring_Iterator */
-inline
-bool operator>=(const Glib::ustring::const_iterator& lhs, const Glib::ustring::const_iterator& rhs)
-{
- return (lhs.base() >= rhs.base());
-}
-
-
-#ifndef DOXYGEN_SHOULD_SKIP_THIS
-
-/**** Glib::ustring::SequenceToString **************************************/
-
-template <class In>
-ustring::SequenceToString<In,char>::SequenceToString(In pbegin, In pend)
-:
- std::string(pbegin, pend)
-{}
-
-template <class In>
-ustring::SequenceToString<In,gunichar>::SequenceToString(In pbegin, In pend)
-{
- char utf8_buf[6]; // stores a single UTF-8 character
-
- for(; pbegin != pend; ++pbegin)
- {
- const std::string::size_type utf8_len = g_unichar_to_utf8(*pbegin, utf8_buf);
- this->append(utf8_buf, utf8_len);
- }
-}
-
-/**** Glib::ustring::FormatStream ******************************************/
-
-template <class T> inline
-void ustring::FormatStream::stream(const T& value)
-{
- stream_ << value;
-}
-
-inline
-void ustring::FormatStream::stream(const char* value)
-{
- stream_ << ustring(value);
-}
-
-inline
-void ustring::FormatStream::stream(char* value)
-{
- stream_ << ustring(value);
-}
-
-/**** Glib::ustring ********************************************************/
-
-template <class In>
-ustring::ustring(In pbegin, In pend)
-:
- string_ (Glib::ustring::SequenceToString<In>(pbegin, pend))
-{}
-
-template <class In>
-ustring& ustring::assign(In pbegin, In pend)
-{
- Glib::ustring::SequenceToString<In> temp_string (pbegin, pend);
- string_.swap(temp_string); // constant-time operation
- return *this;
-}
-
-template <class In>
-ustring& ustring::append(In pbegin, In pend)
-{
- string_.append(Glib::ustring::SequenceToString<In>(pbegin, pend));
- return *this;
-}
-
-template <class In>
-void ustring::insert(ustring::iterator p, In pbegin, In pend)
-{
- string_.insert(p.base(), Glib::ustring::SequenceToString<In>(pbegin, pend));
-}
-
-template <class In>
-ustring& ustring::replace(ustring::iterator pbegin, ustring::iterator pend, In pbegin2, In pend2)
-{
- string_.replace(
- pbegin.base(), pend.base(),
- Glib::ustring::SequenceToString<In>(pbegin2, pend2));
- return *this;
-}
-
-// The ustring methods substr() and operator std::string() are inline,
-// so that the compiler has a fair chance to optimize the copy ctor away.
-
-inline
-ustring ustring::substr(ustring::size_type i, ustring::size_type n) const
-{
- return ustring(*this, i, n);
-}
-
-inline
-ustring::operator std::string() const
-{
- return string_;
-}
-
-inline
-const std::string& ustring::raw() const
-{
- return string_;
-}
-
-template <class T1>
-inline // static
-ustring ustring::format(const T1& a1)
-{
- ustring::FormatStream buf;
- buf.stream(a1);
- return buf.to_string();
-}
-
-template <class T1, class T2>
-inline // static
-ustring ustring::format(const T1& a1, const T2& a2)
-{
- ustring::FormatStream buf;
- buf.stream(a1);
- buf.stream(a2);
- return buf.to_string();
-}
-
-template <class T1, class T2, class T3>
-inline // static
-ustring ustring::format(const T1& a1, const T2& a2, const T3& a3)
-{
- ustring::FormatStream buf;
- buf.stream(a1);
- buf.stream(a2);
- buf.stream(a3);
- return buf.to_string();
-}
-
-template <class T1, class T2, class T3, class T4>
-inline // static
-ustring ustring::format(const T1& a1, const T2& a2, const T3& a3, const T4& a4)
-{
- ustring::FormatStream buf;
- buf.stream(a1);
- buf.stream(a2);
- buf.stream(a3);
- buf.stream(a4);
- return buf.to_string();
-}
-
-template <class T1, class T2, class T3, class T4, class T5>
-inline // static
-ustring ustring::format(const T1& a1, const T2& a2, const T3& a3,
- const T4& a4, const T5& a5)
-{
- ustring::FormatStream buf;
- buf.stream(a1);
- buf.stream(a2);
- buf.stream(a3);
- buf.stream(a4);
- buf.stream(a5);
- return buf.to_string();
-}
-
-template <class T1, class T2, class T3, class T4, class T5, class T6>
-inline // static
-ustring ustring::format(const T1& a1, const T2& a2, const T3& a3,
- const T4& a4, const T5& a5, const T6& a6)
-{
- ustring::FormatStream buf;
- buf.stream(a1);
- buf.stream(a2);
- buf.stream(a3);
- buf.stream(a4);
- buf.stream(a5);
- buf.stream(a6);
- return buf.to_string();
-}
-
-template <class T1, class T2, class T3, class T4,
- class T5, class T6, class T7>
-inline // static
-ustring ustring::format(const T1& a1, const T2& a2, const T3& a3, const T4& a4,
- const T5& a5, const T6& a6, const T7& a7)
-{
- ustring::FormatStream buf;
- buf.stream(a1);
- buf.stream(a2);
- buf.stream(a3);
- buf.stream(a4);
- buf.stream(a5);
- buf.stream(a6);
- buf.stream(a7);
- return buf.to_string();
-}
-
-template <class T1, class T2, class T3, class T4,
- class T5, class T6, class T7, class T8>
-inline // static
-ustring ustring::format(const T1& a1, const T2& a2, const T3& a3, const T4& a4,
- const T5& a5, const T6& a6, const T7& a7, const T8& a8)
-{
- ustring::FormatStream buf;
- buf.stream(a1);
- buf.stream(a2);
- buf.stream(a3);
- buf.stream(a4);
- buf.stream(a5);
- buf.stream(a6);
- buf.stream(a7);
- buf.stream(a8);
- return buf.to_string();
-}
-
-/** An inner class used by ustring.
- */
-template <class T>
-class ustring::Stringify
-{
-private:
- ustring string_;
-
- // noncopyable
- Stringify(const ustring::Stringify<T>&);
- Stringify<T>& operator=(const ustring::Stringify<T>&);
-
-public:
- explicit inline Stringify(const T& arg) : string_ (ustring::format(arg)) {}
-
- //TODO: Why is this here? See the template specialization:
- explicit inline Stringify(const char* arg) : string_(arg) {}
-
- inline const ustring* ptr() const { return &string_; }
-};
-
-/// A template specialization for Stringify<ustring>:
-template <>
-class ustring::Stringify<ustring>
-{
-private:
- const ustring& string_;
-
- // noncopyable
- Stringify(const ustring::Stringify<ustring>&);
- Stringify<ustring>& operator=(const ustring::Stringify<ustring>&);
-
-public:
- explicit inline Stringify(const ustring& arg) : string_(arg) {}
- inline const ustring* ptr() const { return &string_; }
-};
-
-/** A template specialization for Stringify<const char*>,
- * because the regular template has ambiguous constructor overloads for char*.
- */
-template <>
-class ustring::Stringify<const char*>
-{
-private:
- const ustring string_;
-
- // noncopyable
- Stringify(const ustring::Stringify<const char*>&);
- Stringify<ustring>& operator=(const ustring::Stringify<const char*>&);
-
-public:
- explicit inline Stringify(const char* arg) : string_(arg) {}
- inline const ustring* ptr() const { return &string_; }
-};
-
-/** A template specialization for Stringify<char[N]> (for string literals),
- * because the regular template has ambiguous constructor overloads for char*.
- */
-template <std::size_t N>
-class ustring::Stringify<char[N]>
-{
-private:
- const ustring string_;
-
- // noncopyable
- Stringify(const ustring::Stringify<char[N]>&);
- Stringify<ustring>& operator=(const ustring::Stringify<char[N]>&);
-
-public:
- explicit inline Stringify(const char arg[N]) : string_(arg) {}
- inline const ustring* ptr() const { return &string_; }
-};
-
-template <class T1>
-inline // static
-ustring ustring::compose(const ustring& fmt)
-{
- return ustring::compose_argv(fmt, 0, 0);
-}
-
-template <class T1>
-inline // static
-ustring ustring::compose(const ustring& fmt, const T1& a1)
-{
- const ustring::Stringify<T1> s1(a1);
-
- const ustring *const argv[] = { s1.ptr() };
- return ustring::compose_argv(fmt, G_N_ELEMENTS(argv), argv);
-}
-
-template <class T1, class T2>
-inline // static
-ustring ustring::compose(const ustring& fmt, const T1& a1, const T2& a2)
-{
- const ustring::Stringify<T1> s1(a1);
- const ustring::Stringify<T2> s2(a2);
-
- const ustring *const argv[] = { s1.ptr(), s2.ptr() };
- return ustring::compose_argv(fmt, G_N_ELEMENTS(argv), argv);
-}
-
-template <class T1, class T2, class T3>
-inline // static
-ustring ustring::compose(const ustring& fmt,
- const T1& a1, const T2& a2, const T3& a3)
-{
- const ustring::Stringify<T1> s1(a1);
- const ustring::Stringify<T2> s2(a2);
- const ustring::Stringify<T3> s3(a3);
-
- const ustring *const argv[] = { s1.ptr(), s2.ptr(), s3.ptr() };
- return ustring::compose_argv(fmt, G_N_ELEMENTS(argv), argv);
-}
-
-template <class T1, class T2, class T3, class T4>
-inline // static
-ustring ustring::compose(const ustring& fmt,
- const T1& a1, const T2& a2, const T3& a3, const T4& a4)
-{
- const ustring::Stringify<T1> s1(a1);
- const ustring::Stringify<T2> s2(a2);
- const ustring::Stringify<T3> s3(a3);
- const ustring::Stringify<T4> s4(a4);
-
- const ustring *const argv[] = { s1.ptr(), s2.ptr(), s3.ptr(), s4.ptr() };
- return ustring::compose_argv(fmt, G_N_ELEMENTS(argv), argv);
-}
-
-template <class T1, class T2, class T3, class T4, class T5>
-inline // static
-ustring ustring::compose(const ustring& fmt,
- const T1& a1, const T2& a2, const T3& a3,
- const T4& a4, const T5& a5)
-{
- const ustring::Stringify<T1> s1(a1);
- const ustring::Stringify<T2> s2(a2);
- const ustring::Stringify<T3> s3(a3);
- const ustring::Stringify<T4> s4(a4);
- const ustring::Stringify<T5> s5(a5);
-
- const ustring *const argv[] = { s1.ptr(), s2.ptr(), s3.ptr(), s4.ptr(), s5.ptr() };
- return ustring::compose_argv(fmt, G_N_ELEMENTS(argv), argv);
-}
-
-template <class T1, class T2, class T3, class T4, class T5, class T6>
-inline // static
-ustring ustring::compose(const ustring& fmt,
- const T1& a1, const T2& a2, const T3& a3,
- const T4& a4, const T5& a5, const T6& a6)
-{
- const ustring::Stringify<T1> s1(a1);
- const ustring::Stringify<T2> s2(a2);
- const ustring::Stringify<T3> s3(a3);
- const ustring::Stringify<T4> s4(a4);
- const ustring::Stringify<T5> s5(a5);
- const ustring::Stringify<T6> s6(a6);
-
- const ustring *const argv[] = { s1.ptr(), s2.ptr(), s3.ptr(), s4.ptr(),
- s5.ptr(), s6.ptr() };
- return ustring::compose_argv(fmt, G_N_ELEMENTS(argv), argv);
-}
-
-template <class T1, class T2, class T3, class T4, class T5, class T6, class T7>
-inline // static
-ustring ustring::compose(const ustring& fmt,
- const T1& a1, const T2& a2, const T3& a3,
- const T4& a4, const T5& a5, const T6& a6, const T7& a7)
-{
- const ustring::Stringify<T1> s1(a1);
- const ustring::Stringify<T2> s2(a2);
- const ustring::Stringify<T3> s3(a3);
- const ustring::Stringify<T4> s4(a4);
- const ustring::Stringify<T5> s5(a5);
- const ustring::Stringify<T6> s6(a6);
- const ustring::Stringify<T7> s7(a7);
-
- const ustring *const argv[] = { s1.ptr(), s2.ptr(), s3.ptr(), s4.ptr(),
- s5.ptr(), s6.ptr(), s7.ptr() };
- return ustring::compose_argv(fmt, G_N_ELEMENTS(argv), argv);
-}
-
-template <class T1, class T2, class T3, class T4,
- class T5, class T6, class T7, class T8>
-inline // static
-ustring ustring::compose(const ustring& fmt,
- const T1& a1, const T2& a2, const T3& a3,
- const T4& a4, const T5& a5, const T6& a6,
- const T7& a7, const T8& a8)
-{
- const ustring::Stringify<T1> s1(a1);
- const ustring::Stringify<T2> s2(a2);
- const ustring::Stringify<T3> s3(a3);
- const ustring::Stringify<T4> s4(a4);
- const ustring::Stringify<T5> s5(a5);
- const ustring::Stringify<T6> s6(a6);
- const ustring::Stringify<T7> s7(a7);
- const ustring::Stringify<T8> s8(a8);
-
- const ustring *const argv[] = { s1.ptr(), s2.ptr(), s3.ptr(), s4.ptr(),
- s5.ptr(), s6.ptr(), s7.ptr(), s8.ptr() };
- return ustring::compose_argv(fmt, G_N_ELEMENTS(argv), argv);
-}
-
-template <class T1, class T2, class T3, class T4, class T5,
- class T6, class T7, class T8, class T9>
-inline // static
-ustring ustring::compose(const ustring& fmt,
- const T1& a1, const T2& a2, const T3& a3,
- const T4& a4, const T5& a5, const T6& a6,
- const T7& a7, const T8& a8, const T9& a9)
-{
- const ustring::Stringify<T1> s1(a1);
- const ustring::Stringify<T2> s2(a2);
- const ustring::Stringify<T3> s3(a3);
- const ustring::Stringify<T4> s4(a4);
- const ustring::Stringify<T5> s5(a5);
- const ustring::Stringify<T6> s6(a6);
- const ustring::Stringify<T7> s7(a7);
- const ustring::Stringify<T8> s8(a8);
- const ustring::Stringify<T9> s9(a9);
-
- const ustring *const argv[] = { s1.ptr(), s2.ptr(), s3.ptr(), s4.ptr(),
- s5.ptr(), s6.ptr(), s7.ptr(), s8.ptr(), s9.ptr() };
- return ustring::compose_argv(fmt, G_N_ELEMENTS(argv), argv);
-}
-
-#endif /* DOXYGEN_SHOULD_SKIP_THIS */
-
-
-/** @relates Glib::ustring */
-inline
-void swap(ustring& lhs, ustring& rhs)
-{
- lhs.swap(rhs);
-}
-
-
-/**** Glib::ustring -- comparison operators ********************************/
-
-/** @relates Glib::ustring */
-inline bool operator==(const ustring& lhs, const ustring& rhs)
- { return (lhs.compare(rhs) == 0); }
-
-/** @relates Glib::ustring */
-inline bool operator==(const ustring& lhs, const char* rhs)
- { return (lhs.compare(rhs) == 0); }
-
-/** @relates Glib::ustring */
-inline bool operator==(const char* lhs, const ustring& rhs)
- { return (rhs.compare(lhs) == 0); }
-
-
-/** @relates Glib::ustring */
-inline bool operator!=(const ustring& lhs, const ustring& rhs)
- { return (lhs.compare(rhs) != 0); }
-
-/** @relates Glib::ustring */
-inline bool operator!=(const ustring& lhs, const char* rhs)
- { return (lhs.compare(rhs) != 0); }
-
-/** @relates Glib::ustring */
-inline bool operator!=(const char* lhs, const ustring& rhs)
- { return (rhs.compare(lhs) != 0); }
-
-
-/** @relates Glib::ustring */
-inline bool operator<(const ustring& lhs, const ustring& rhs)
- { return (lhs.compare(rhs) < 0); }
-
-/** @relates Glib::ustring */
-inline bool operator<(const ustring& lhs, const char* rhs)
- { return (lhs.compare(rhs) < 0); }
-
-/** @relates Glib::ustring */
-inline bool operator<(const char* lhs, const ustring& rhs)
- { return (rhs.compare(lhs) > 0); }
-
-
-/** @relates Glib::ustring */
-inline bool operator>(const ustring& lhs, const ustring& rhs)
- { return (lhs.compare(rhs) > 0); }
-
-/** @relates Glib::ustring */
-inline bool operator>(const ustring& lhs, const char* rhs)
- { return (lhs.compare(rhs) > 0); }
-
-/** @relates Glib::ustring */
-inline bool operator>(const char* lhs, const ustring& rhs)
- { return (rhs.compare(lhs) < 0); }
-
-
-/** @relates Glib::ustring */
-inline bool operator<=(const ustring& lhs, const ustring& rhs)
- { return (lhs.compare(rhs) <= 0); }
-
-/** @relates Glib::ustring */
-inline bool operator<=(const ustring& lhs, const char* rhs)
- { return (lhs.compare(rhs) <= 0); }
-
-/** @relates Glib::ustring */
-inline bool operator<=(const char* lhs, const ustring& rhs)
- { return (rhs.compare(lhs) >= 0); }
-
-
-/** @relates Glib::ustring */
-inline bool operator>=(const ustring& lhs, const ustring& rhs)
- { return (lhs.compare(rhs) >= 0); }
-
-/** @relates Glib::ustring */
-inline bool operator>=(const ustring& lhs, const char* rhs)
- { return (lhs.compare(rhs) >= 0); }
-
-/** @relates Glib::ustring */
-inline bool operator>=(const char* lhs, const ustring& rhs)
- { return (rhs.compare(lhs) <= 0); }
-
-
-/**** Glib::ustring -- concatenation operators *****************************/
-
-/** @relates Glib::ustring */
-inline ustring operator+(const ustring& lhs, const ustring& rhs)
-{
- ustring temp(lhs);
- temp += rhs;
- return temp;
-}
-
-/** @relates Glib::ustring */
-inline ustring operator+(const ustring& lhs, const char* rhs)
-{
- ustring temp(lhs);
- temp += rhs;
- return temp;
-}
-
-/** @relates Glib::ustring */
-inline ustring operator+(const char* lhs, const ustring& rhs)
-{
- ustring temp(lhs);
- temp += rhs;
- return temp;
-}
-
-/** @relates Glib::ustring */
-inline ustring operator+(const ustring& lhs, gunichar rhs)
-{
- ustring temp(lhs);
- temp += rhs;
- return temp;
-}
-
-/** @relates Glib::ustring */
-inline ustring operator+(gunichar lhs, const ustring& rhs)
-{
- ustring temp(1, lhs);
- temp += rhs;
- return temp;
-}
-
-/** @relates Glib::ustring */
-inline ustring operator+(const ustring& lhs, char rhs)
-{
- ustring temp(lhs);
- temp += rhs;
- return temp;
-}
-
-/** @relates Glib::ustring */
-inline ustring operator+(char lhs, const ustring& rhs)
-{
- ustring temp(1, lhs);
- temp += rhs;
- return temp;
-}
-
-} // namespace Glib
-
-
-#endif /* _GLIBMM_USTRING_H */
Modified: trunk/tests/Makefile.am
===================================================================
--- trunk/tests/Makefile.am 2012-03-20 14:33:34 UTC (rev 212)
+++ trunk/tests/Makefile.am 2012-03-20 14:35:16 UTC (rev 213)
@@ -18,7 +18,7 @@
node/test_node.cc \
tree/test_tree.cc \
xmlwrappstring/test_xmlwrappstring_compose.cc \
- xmlwrappstring/test_xmlwrappstring_format.cc \
+ xmlwrappstring/test_xmlwrappstring_format.cc
if WITH_XSLT
LIBS += $(top_builddir)/src/libxsltwrapp.la
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tbr...@us...> - 2012-03-20 14:33:41
|
Revision: 212
http://xmlwrapp.svn.sourceforge.net/xmlwrapp/?rev=212&view=rev
Author: tbrowder2
Date: 2012-03-20 14:33:34 +0000 (Tue, 20 Mar 2012)
Log Message:
-----------
move to proper installtion dir
Added Paths:
-----------
trunk/include/xmlwrappstring/xmlwrappstring.h
Copied: trunk/include/xmlwrappstring/xmlwrappstring.h (from rev 205, trunk/src/libxmlwrappstring/xmlwrappstring.h)
===================================================================
--- trunk/include/xmlwrappstring/xmlwrappstring.h (rev 0)
+++ trunk/include/xmlwrappstring/xmlwrappstring.h 2012-03-20 14:33:34 UTC (rev 212)
@@ -0,0 +1,1615 @@
+// -*- c++ -*-
+#ifndef _GLIBMM_USTRING_H
+#define _GLIBMM_USTRING_H
+
+/* $Id$ */
+
+/* Copyright (C) 2002 The gtkmm Development Team
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <glibmmconfig.h>
+#include <glibmm/unicode.h>
+#include <glib.h>
+
+#include <iosfwd>
+#include <iterator>
+#include <sstream>
+#include <string>
+#ifndef GLIBMM_HAVE_STD_ITERATOR_TRAITS
+#include <cstddef> /* for ptrdiff_t */
+#endif
+
+namespace Glib
+{
+
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
+#ifndef GLIBMM_HAVE_STD_ITERATOR_TRAITS
+
+template <class T>
+struct IteratorTraits
+{
+ typedef typename T::iterator_category iterator_category;
+ typedef typename T::value_type value_type;
+ typedef typename T::difference_type difference_type;
+ typedef typename T::pointer pointer;
+ typedef typename T::reference reference;
+};
+
+template <class T>
+struct IteratorTraits<T*>
+{
+ typedef std::random_access_iterator_tag iterator_category;
+ typedef T value_type;
+ typedef ptrdiff_t difference_type;
+ typedef T* pointer;
+ typedef T& reference;
+};
+
+template <class T>
+struct IteratorTraits<const T*>
+{
+ typedef std::random_access_iterator_tag iterator_category;
+ typedef T value_type;
+ typedef ptrdiff_t difference_type;
+ typedef const T* pointer;
+ typedef const T& reference;
+};
+
+#endif /* GLIBMM_HAVE_STD_ITERATOR_TRAITS */
+#endif /* DOXYGEN_SHOULD_SKIP_THIS */
+
+
+/** The iterator type of Glib::ustring.
+ * Note this is not a random access iterator but a bidirectional one,
+ * since all index operations need to iterate over the UTF-8 data. Use
+ * std::advance() to move to a certain position. However, all of the
+ * relational operators are available:
+ * <tt>== != < > <= >=</tt>
+ *
+ * A writeable iterator isn't provided because: The number of bytes of
+ * the old UTF-8 character and the new one to write could be different.
+ * Therefore, any write operation would invalidate all other iterators
+ * pointing into the same string.
+ */
+template <class T>
+class ustring_Iterator
+{
+public:
+ typedef std::bidirectional_iterator_tag iterator_category;
+ typedef gunichar value_type;
+ typedef std::string::difference_type difference_type;
+ typedef value_type reference;
+ typedef void pointer;
+
+ inline ustring_Iterator();
+ inline ustring_Iterator(const ustring_Iterator<std::string::iterator>& other);
+
+ inline value_type operator*() const;
+
+ inline ustring_Iterator<T> & operator++();
+ inline const ustring_Iterator<T> operator++(int);
+ inline ustring_Iterator<T> & operator--();
+ inline const ustring_Iterator<T> operator--(int);
+
+ explicit inline ustring_Iterator(T pos);
+ inline T base() const;
+
+private:
+ T pos_;
+};
+
+
+/** Extract a UCS-4 character from UTF-8 data.
+ * Convert a single UTF-8 (multibyte) character starting at @p pos to
+ * a UCS-4 wide character. This may read up to 6 bytes after the start
+ * position, depending on the UTF-8 character width. You have to make
+ * sure the source contains at least one valid UTF-8 character.
+ *
+ * This is mainly used by the implementation of Glib::ustring::iterator,
+ * but it might be useful as utility function if you prefer using
+ * std::string even for UTF-8 encoding.
+ */
+gunichar get_unichar_from_std_iterator(std::string::const_iterator pos) G_GNUC_PURE;
+
+
+/** Glib::ustring has much the same interface as std::string, but contains
+ * %Unicode characters encoded as UTF-8.
+ *
+ * @par About UTF-8 and ASCII
+ * @par
+ * The standard character set ANSI_X3.4-1968 -- more commonly known as
+ * ASCII -- is a subset of UTF-8. So, if you want to, you can use
+ * Glib::ustring without even thinking about UTF-8.
+ * @par
+ * Whenever ASCII is mentioned in this manual, we mean the @em real ASCII
+ * (i.e. as defined in ANSI_X3.4-1968), which contains only 7-bit characters.
+ * Glib::ustring can @em not be used with ASCII-compatible extended 8-bit
+ * charsets like ISO-8859-1. It's a good idea to avoid string literals
+ * containing non-ASCII characters (e.g. German umlauts) in source code,
+ * or at least you should use UTF-8 literals.
+ * @par
+ * You can find a detailed UTF-8 and %Unicode FAQ here:
+ * http://www.cl.cam.ac.uk/~mgk25/unicode.html
+ *
+ * @par Glib::ustring vs. std::string
+ * @par
+ * Glib::ustring has implicit type conversions to and from std::string.
+ * These conversions do @em not convert to/from the current locale (see
+ * Glib::locale_from_utf8() and Glib::locale_to_utf8() if you need that). You
+ * can always use std::string instead of Glib::ustring -- however, using
+ * std::string with multi-byte characters is quite hard. For instance,
+ * <tt>std::string::operator[]</tt> might return a byte in the middle of a
+ * character, and <tt>std::string::length()</tt> returns the number of bytes
+ * rather than characters. So don't do that without a good reason.
+ * @par
+ * In a perfect world the C++ Standard Library would contain a UTF-8 string
+ * class. Unfortunately, the C++ standard doesn't mention UTF-8 at all. Note
+ * that std::wstring is not a UTF-8 string class because it contains only
+ * fixed-width characters (where width could be 32, 16, or even 8 bits).
+ *
+ * @par Glib::ustring and stream input/output
+ * @par
+ * The stream I/O operators, that is operator<<() and operator>>(), perform
+ * implicit charset conversion to/from the current locale. If that's not
+ * what you intented (e.g. when writing to a configuration file that should
+ * always be UTF-8 encoded) use ustring::raw() to override this behaviour.
+ * @par
+ * If you're using std::ostringstream to build strings for display in the
+ * user interface, you must convert the result back to UTF-8 as shown below:
+ * @code
+ * std::ostringstream output;
+ * output.imbue(std::locale("")); // use the user's locale for this stream
+ * output << percentage << " % done";
+ * label->set_text(Glib::locale_to_utf8(output.str()));
+ * @endcode
+ *
+ * @par Formatted output and internationalization
+ * @par
+ * The methods ustring::compose() and ustring::format() provide a convenient
+ * and powerful alternative to string streams, as shown in the example below.
+ * Refer to the method documentation of compose() and format() for details.
+ * @code
+ * using Glib::ustring;
+ *
+ * ustring message = ustring::compose("%1 is lower than 0x%2.",
+ * 12, ustring::format(std::hex, 16));
+ * @endcode
+ *
+ * @par Implementation notes
+ * @par
+ * Glib::ustring does not inherit from std::string, because std::string was
+ * intended to be a final class. For instance, it does not have a virtual
+ * destructor. Also, a HAS-A relationship is more appropriate because
+ * ustring can't just enhance the std::string interface. Rather, it has to
+ * reimplement the interface so that all operations are based on characters
+ * instead of bytes.
+ */
+class ustring
+{
+public:
+ typedef std::string::size_type size_type;
+ typedef std::string::difference_type difference_type;
+
+ typedef gunichar value_type;
+ typedef gunichar & reference;
+ typedef const gunichar & const_reference;
+
+ typedef ustring_Iterator<std::string::iterator> iterator;
+ typedef ustring_Iterator<std::string::const_iterator> const_iterator;
+
+#ifndef GLIBMM_HAVE_SUN_REVERSE_ITERATOR
+
+ typedef std::reverse_iterator<iterator> reverse_iterator;
+ typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
+
+#else
+
+ typedef std::reverse_iterator<iterator,
+ iterator::iterator_category,
+ iterator::value_type,
+ iterator::reference,
+ iterator::pointer,
+ iterator::difference_type> reverse_iterator;
+ typedef std::reverse_iterator<const_iterator,
+ const_iterator::iterator_category,
+ const_iterator::value_type,
+ const_iterator::reference,
+ const_iterator::pointer,
+ const_iterator::difference_type> const_reverse_iterator;
+
+#endif /* GLIBMM_HAVE_SUN_REVERSE_ITERATOR */
+
+#ifdef GLIBMM_HAVE_ALLOWS_STATIC_INLINE_NPOS
+ static GLIBMM_API const size_type npos = std::string::npos;
+#else
+ //The IRIX MipsPro compiler says "The indicated constant value is not known",
+ //so we need to initalize the static member data elsewhere.
+ static GLIBMM_API const size_type npos;
+#endif
+
+ /*! Default constructor, which creates an empty string.
+ */
+ ustring();
+
+ ~ustring();
+
+ /*! Construct a ustring as a copy of another ustring.
+ * @param other A source string.
+ */
+ ustring(const ustring& other);
+
+ /*! Assign the value of another string to this string.
+ * @param other A source string.
+ */
+ ustring& operator=(const ustring& other);
+
+ /*! Swap contents with another string.
+ * @param other String to swap with.
+ */
+ void swap(ustring& other);
+
+ /*! Construct a ustring as a copy of another std::string.
+ * @param src A source <tt>std::string</tt> containing text encoded as UTF-8.
+ */
+ ustring(const std::string& src);
+
+ /*! Construct a ustring as a copy of a substring.
+ * @param src %Source ustring.
+ * @param i Index of first character to copy from.
+ * @param n Number of UTF-8 characters to copy (defaults to copying the remainder).
+ */
+ ustring(const ustring& src, size_type i, size_type n=npos);
+
+ /*! Construct a ustring as a partial copy of a C string.
+ * @param src %Source C string encoded as UTF-8.
+ * @param n Number of UTF-8 characters to copy.
+ */
+ ustring(const char* src, size_type n);
+
+ /*! Construct a ustring as a copy of a C string.
+ * @param src %Source C string encoded as UTF-8.
+ */
+ ustring(const char* src);
+
+ /*! Construct a ustring as multiple characters.
+ * @param n Number of characters.
+ * @param uc UCS-4 code point to use.
+ */
+ ustring(size_type n, gunichar uc);
+
+ /*! Construct a ustring as multiple characters.
+ * @param n Number of characters.
+ * @param c ASCII character to use.
+ */
+ ustring(size_type n, char c);
+
+ /*! Construct a ustring as a copy of a range.
+ * @param pbegin Start of range.
+ * @param pend End of range.
+ */
+ template <class In> ustring(In pbegin, In pend);
+
+
+//! @name Assign new contents.
+//! @{
+
+ ustring& operator=(const std::string& src);
+ ustring& operator=(const char* src);
+ ustring& operator=(gunichar uc);
+ ustring& operator=(char c);
+
+ ustring& assign(const ustring& src);
+ ustring& assign(const ustring& src, size_type i, size_type n);
+ ustring& assign(const char* src, size_type n);
+ ustring& assign(const char* src);
+ ustring& assign(size_type n, gunichar uc);
+ ustring& assign(size_type n, char c);
+ template <class In> ustring& assign(In pbegin, In pend);
+
+//! @}
+//! @name Append to the string.
+//! @{
+
+ ustring& operator+=(const ustring& src);
+ ustring& operator+=(const char* src);
+ ustring& operator+=(gunichar uc);
+ ustring& operator+=(char c);
+ void push_back(gunichar uc);
+ void push_back(char c);
+
+ ustring& append(const ustring& src);
+ ustring& append(const ustring& src, size_type i, size_type n);
+ ustring& append(const char* src, size_type n);
+ ustring& append(const char* src);
+ ustring& append(size_type n, gunichar uc);
+ ustring& append(size_type n, char c);
+ template <class In> ustring& append(In pbegin, In pend);
+
+//! @}
+//! @name Insert into the string.
+//! @{
+
+ ustring& insert(size_type i, const ustring& src);
+ ustring& insert(size_type i, const ustring& src, size_type i2, size_type n);
+ ustring& insert(size_type i, const char* src, size_type n);
+ ustring& insert(size_type i, const char* src);
+ ustring& insert(size_type i, size_type n, gunichar uc);
+ ustring& insert(size_type i, size_type n, char c);
+
+ iterator insert(iterator p, gunichar uc);
+ iterator insert(iterator p, char c);
+ void insert(iterator p, size_type n, gunichar uc);
+ void insert(iterator p, size_type n, char c);
+ template <class In> void insert(iterator p, In pbegin, In pend);
+
+//! @}
+//! @name Replace sub-strings.
+//! @{
+
+ ustring& replace(size_type i, size_type n, const ustring& src);
+ ustring& replace(size_type i, size_type n, const ustring& src, size_type i2, size_type n2);
+ ustring& replace(size_type i, size_type n, const char* src, size_type n2);
+ ustring& replace(size_type i, size_type n, const char* src);
+ ustring& replace(size_type i, size_type n, size_type n2, gunichar uc);
+ ustring& replace(size_type i, size_type n, size_type n2, char c);
+
+ ustring& replace(iterator pbegin, iterator pend, const ustring& src);
+ ustring& replace(iterator pbegin, iterator pend, const char* src, size_type n);
+ ustring& replace(iterator pbegin, iterator pend, const char* src);
+ ustring& replace(iterator pbegin, iterator pend, size_type n, gunichar uc);
+ ustring& replace(iterator pbegin, iterator pend, size_type n, char c);
+ template <class In> ustring& replace(iterator pbegin, iterator pend, In pbegin2, In pend2);
+
+//! @}
+//! @name Erase sub-strings.
+//! @{
+
+ void clear();
+ ustring& erase(size_type i, size_type n=npos);
+ ustring& erase();
+ iterator erase(iterator p);
+ iterator erase(iterator pbegin, iterator pend);
+
+//! @}
+//! @name Compare and collate.
+//! @{
+
+ int compare(const ustring& rhs) const;
+ int compare(const char* rhs) const;
+ int compare(size_type i, size_type n, const ustring& rhs) const;
+ int compare(size_type i, size_type n, const ustring& rhs, size_type i2, size_type n2) const;
+ int compare(size_type i, size_type n, const char* rhs, size_type n2) const;
+ int compare(size_type i, size_type n, const char* rhs) const;
+
+ /*! Create a unique sorting key for the UTF-8 string. If you need to
+ * compare UTF-8 strings regularly, e.g. for sorted containers such as
+ * <tt>std::set<></tt>, you should consider creating a collate key first
+ * and compare this key instead of the actual string.
+ *
+ * The ustring::compare() methods as well as the relational operators
+ * <tt>== != < > <= >=</tt> are quite costly
+ * because they have to deal with %Unicode and the collation rules defined by
+ * the current locale. Converting both operands to UCS-4 is just the first
+ * of several costly steps involved when comparing ustrings. So be careful.
+ */
+ std::string collate_key() const;
+
+ /*! Create a unique key for the UTF-8 string that can be used for caseless
+ * sorting. <tt>ustr.casefold_collate_key()</tt> results in the same string
+ * as <tt>ustr.casefold().collate_key()</tt>, but the former is likely more
+ * efficient.
+ */
+ std::string casefold_collate_key() const;
+
+//! @}
+//! @name Extract characters and sub-strings.
+//! @{
+
+ /*! No reference return; use replace() to write characters. */
+ value_type operator[](size_type i) const;
+
+ /*! No reference return; use replace() to write characters. @throw std::out_of_range */
+ value_type at(size_type i) const;
+
+ inline ustring substr(size_type i=0, size_type n=npos) const;
+
+//! @}
+//! @name Access a sequence of characters.
+//! @{
+
+ iterator begin();
+ iterator end();
+ const_iterator begin() const;
+ const_iterator end() const;
+ reverse_iterator rbegin();
+ reverse_iterator rend();
+ const_reverse_iterator rbegin() const;
+ const_reverse_iterator rend() const;
+
+//! @}
+//! @name Find sub-strings.
+//! @{
+
+ size_type find(const ustring& str, size_type i=0) const;
+ size_type find(const char* str, size_type i, size_type n) const;
+ size_type find(const char* str, size_type i=0) const;
+ size_type find(gunichar uc, size_type i=0) const;
+ size_type find(char c, size_type i=0) const;
+
+ size_type rfind(const ustring& str, size_type i=npos) const;
+ size_type rfind(const char* str, size_type i, size_type n) const;
+ size_type rfind(const char* str, size_type i=npos) const;
+ size_type rfind(gunichar uc, size_type i=npos) const;
+ size_type rfind(char c, size_type i=npos) const;
+
+//! @}
+//! @name Match against a set of characters.
+//! @{
+
+ size_type find_first_of(const ustring& match, size_type i=0) const;
+ size_type find_first_of(const char* match, size_type i, size_type n) const;
+ size_type find_first_of(const char* match, size_type i=0) const;
+ size_type find_first_of(gunichar uc, size_type i=0) const;
+ size_type find_first_of(char c, size_type i=0) const;
+
+ size_type find_last_of(const ustring& match, size_type i=npos) const;
+ size_type find_last_of(const char* match, size_type i, size_type n) const;
+ size_type find_last_of(const char* match, size_type i=npos) const;
+ size_type find_last_of(gunichar uc, size_type i=npos) const;
+ size_type find_last_of(char c, size_type i=npos) const;
+
+ size_type find_first_not_of(const ustring& match, size_type i=0) const;
+ size_type find_first_not_of(const char* match, size_type i, size_type n) const;
+ size_type find_first_not_of(const char* match, size_type i=0) const;
+ size_type find_first_not_of(gunichar uc, size_type i=0) const;
+ size_type find_first_not_of(char c, size_type i=0) const;
+
+ size_type find_last_not_of(const ustring& match, size_type i=npos) const;
+ size_type find_last_not_of(const char* match, size_type i, size_type n) const;
+ size_type find_last_not_of(const char* match, size_type i=npos) const;
+ size_type find_last_not_of(gunichar uc, size_type i=npos) const;
+ size_type find_last_not_of(char c, size_type i=npos) const;
+
+//! @}
+//! @name Retrieve the string's size.
+//! @{
+
+ /** Returns true if the string is empty. Equivalent to *this == "".
+ * @result Whether the string is empty.
+ */
+ bool empty() const;
+
+ /** Returns the number of characters in the string, not including any null-termination.
+ * @result The number of UTF-8 characters.
+ *
+ * @see bytes(), empty()
+ */
+ size_type size() const;
+
+ //We have length() as well as size(), because std::string has both.
+
+ /** This is the same as size().
+ */
+ size_type length() const;
+
+ /** Returns the number of bytes in the string, not including any null-termination.
+ * @result The number of bytes.
+ *
+ * @see size(), empty()
+ */
+ size_type bytes() const;
+
+//! @}
+//! @name Change the string's size.
+//! @{
+
+ void resize(size_type n, gunichar uc);
+ void resize(size_type n, char c='\0');
+
+//! @}
+//! @name Control the allocated memory.
+//! @{
+
+ size_type capacity() const;
+ size_type max_size() const;
+ void reserve(size_type n=0);
+
+//! @}
+//! @name Get a per-byte representation of the string.
+//! @{
+
+ inline operator std::string() const; // e.g. std::string str = ustring();
+ inline const std::string& raw() const;
+
+ // Not necessarily an ASCII char*. Use g_utf8_*() where necessary.
+ const char* data() const;
+ const char* c_str() const;
+
+ /*! @return Number of copied @em bytes, not characters. */
+ size_type copy(char* dest, size_type n, size_type i=0) const;
+
+//! @}
+//! @name UTF-8 utilities.
+//! @{
+
+ /*! Check whether the string is valid UTF-8. */
+ bool validate() const;
+
+ /*! Check whether the string is valid UTF-8. */
+ bool validate(iterator& first_invalid);
+
+ /*! Check whether the string is valid UTF-8. */
+ bool validate(const_iterator& first_invalid) const;
+
+ /*! Check whether the string is plain 7-bit ASCII. @par
+ * Unlike any other ustring method, is_ascii() is safe to use on invalid
+ * UTF-8 strings. If the string isn't valid UTF-8, it cannot be valid
+ * ASCII either, therefore is_ascii() will just return @c false then.
+ * @return Whether the string contains only ASCII characters.
+ */
+ bool is_ascii() const;
+
+ /*! "Normalize" the %Unicode character representation of the string. */
+ ustring normalize(NormalizeMode mode = NORMALIZE_DEFAULT_COMPOSE) const;
+
+//! @}
+//! @name Character case conversion.
+//! @{
+
+ /*! Returns a new UTF-8 string with all characters characters converted to
+ * their uppercase equivalent, while honoring the current locale. The
+ * resulting string may change in the number of bytes as well as in the
+ * number of characters. For instance, the German sharp s
+ * <tt>"ß"</tt> will be replaced by two characters
+ * <tt>"SS"</tt> because there is no capital <tt>"ß"</tt>.
+ */
+ ustring uppercase() const;
+
+ /*! Returns a new UTF-8 string with all characters characters converted to
+ * their lowercase equivalent, while honoring the current locale. The
+ * resulting string may change in the number of bytes as well as in the
+ * number of characters.
+ */
+ ustring lowercase() const;
+
+ /*! Returns a caseless representation of the UTF-8 string. The resulting
+ * string doesn't correspond to any particular case, therefore the result
+ * is only useful to compare strings and should never be displayed to the
+ * user.
+ */
+ ustring casefold() const;
+
+//! @}
+//! @name Message formatting.
+//! @{
+
+ /* Returns fmt as is, but checks for invalid references in the format string.
+ * @newin{2,18}
+ */
+ template <class T1>
+ static inline
+ ustring compose(const ustring& fmt);
+
+ /*! Substitute placeholders in a format string with the referenced arguments.
+ * The template string should be in <tt>qt-format</tt>, that is
+ * <tt>"%1"</tt>, <tt>"%2"</tt>, ..., <tt>"%9"</tt> are used as placeholders
+ * and <tt>"%%"</tt> denotes a literal <tt>"%"</tt>. Substitutions may be
+ * reordered.
+ * @par Example:
+ * @code
+ * using Glib::ustring;
+ * const int percentage = 50;
+ * const ustring text = ustring::compose("%1%% done", percentage);
+ * @endcode
+ * @param fmt A template string in <tt>qt-format</tt>.
+ * @param a1 The argument to substitute for <tt>"%1"</tt>.
+ * @return The substituted message string.
+ * @throw Glib::ConvertError
+ *
+ * @newin{2,16}
+ */
+ template <class T1>
+ static inline
+ ustring compose(const ustring& fmt, const T1& a1);
+
+ /* See the documentation for compose(const ustring& fmt, const T1& a1).
+ * @newin{2,16}
+ */
+ template <class T1, class T2>
+ static inline
+ ustring compose(const ustring& fmt, const T1& a1, const T2& a2);
+
+ /* See the documentation for compose(const ustring& fmt, const T1& a1).
+ * @newin{2,16}
+ */
+ template <class T1, class T2, class T3>
+ static inline
+ ustring compose(const ustring& fmt,
+ const T1& a1, const T2& a2, const T3& a3);
+
+ /* See the documentation for compose(const ustring& fmt, const T1& a1).
+ * @newin{2,16}
+ */
+ template <class T1, class T2, class T3, class T4>
+ static inline
+ ustring compose(const ustring& fmt,
+ const T1& a1, const T2& a2, const T3& a3,
+ const T4& a4);
+
+ /* See the documentation for compose(const ustring& fmt, const T1& a1).
+ * @newin{2,16}
+ */
+ template <class T1, class T2, class T3, class T4, class T5>
+ static inline
+ ustring compose(const ustring& fmt,
+ const T1& a1, const T2& a2, const T3& a3,
+ const T4& a4, const T5& a5);
+
+ /* See the documentation for compose(const ustring& fmt, const T1& a1).
+ * @newin{2,16}
+ */
+ template <class T1, class T2, class T3, class T4, class T5, class T6>
+ static inline
+ ustring compose(const ustring& fmt,
+ const T1& a1, const T2& a2, const T3& a3,
+ const T4& a4, const T5& a5, const T6& a6);
+
+ /* See the documentation for compose(const ustring& fmt, const T1& a1).
+ * @newin{2,16}
+ */
+ template <class T1, class T2, class T3, class T4, class T5, class T6, class T7>
+ static inline
+ ustring compose(const ustring& fmt,
+ const T1& a1, const T2& a2, const T3& a3,
+ const T4& a4, const T5& a5, const T6& a6,
+ const T7& a7);
+
+ /* See the documentation for compose(const ustring& fmt, const T1& a1).
+ * @newin{2,16}
+ */
+ template <class T1, class T2, class T3, class T4,
+ class T5, class T6, class T7, class T8>
+ static inline
+ ustring compose(const ustring& fmt,
+ const T1& a1, const T2& a2, const T3& a3,
+ const T4& a4, const T5& a5, const T6& a6,
+ const T7& a7, const T8& a8);
+
+ /* See the documentation for compose(const ustring& fmt, const T1& a1).
+ * @newin{2,16}
+ */
+ template <class T1, class T2, class T3, class T4, class T5,
+ class T6, class T7, class T8, class T9>
+ static inline
+ ustring compose(const ustring& fmt,
+ const T1& a1, const T2& a2, const T3& a3,
+ const T4& a4, const T5& a5, const T6& a6,
+ const T7& a7, const T8& a8, const T9& a9);
+
+ /*! Format the argument to its string representation.
+ * Applies the arguments in order to an std::wostringstream and returns the
+ * resulting string. I/O manipulators may also be used as arguments. This
+ * greatly simplifies the common task of converting a number to a string, as
+ * demonstrated by the example below. The format() methods can also be used
+ * in conjunction with compose() to facilitate localization of user-visible
+ * messages.
+ * @code
+ * using Glib::ustring;
+ * double value = 22.0 / 7.0;
+ * ustring text = ustring::format(std::fixed, std::setprecision(2), value);
+ * @endcode
+ * @note The use of a wide character stream in the implementation of format()
+ * is almost completely transparent. However, one of the instances where the
+ * use of wide streams becomes visible is when the std::setfill() stream
+ * manipulator is used. In order for std::setfill() to work the argument
+ * must be of type <tt>wchar_t</tt>. This can be achieved by using the
+ * <tt>L</tt> prefix with a character literal, as shown in the example.
+ * @code
+ * using Glib::ustring;
+ * // Insert leading zeroes to fill in at least six digits
+ * ustring text = ustring::format(std::setfill(L'0'), std::setw(6), 123);
+ * @endcode
+ *
+ * @param a1 A streamable value or an I/O manipulator.
+ * @return The string representation of the argument stream.
+ * @throw Glib::ConvertError
+ *
+ * @newin{2,16}
+ */
+ template <class T1>
+ static inline
+ ustring format(const T1& a1);
+
+ /* See the documentation for format(const T1& a1).
+ *
+ * @newin{2,16}
+ */
+ template <class T1, class T2>
+ static inline
+ ustring format(const T1& a1, const T2& a2);
+
+ /* See the documentation for format(const T1& a1).
+ *
+ * @newin{2,16}
+ */
+ template <class T1, class T2, class T3>
+ static inline
+ ustring format(const T1& a1, const T2& a2, const T3& a3);
+
+ /* See the documentation for format(const T1& a1).
+ *
+ * @newin{2,16}
+ */
+ template <class T1, class T2, class T3, class T4>
+ static inline
+ ustring format(const T1& a1, const T2& a2, const T3& a3, const T4& a4);
+
+ /* See the documentation for format(const T1& a1).
+ *
+ * @newin{2,16}
+ */
+ template <class T1, class T2, class T3, class T4, class T5>
+ static inline
+ ustring format(const T1& a1, const T2& a2, const T3& a3,
+ const T4& a4, const T5& a5);
+
+ /* See the documentation for format(const T1& a1).
+ *
+ * @newin{2,16}
+ */
+ template <class T1, class T2, class T3, class T4, class T5, class T6>
+ static inline
+ ustring format(const T1& a1, const T2& a2, const T3& a3,
+ const T4& a4, const T5& a5, const T6& a6);
+
+ /* See the documentation for format(const T1& a1).
+ *
+ * @newin{2,16}
+ */
+ template <class T1, class T2, class T3, class T4,
+ class T5, class T6, class T7>
+ static inline
+ ustring format(const T1& a1, const T2& a2, const T3& a3, const T4& a4,
+ const T5& a5, const T6& a6, const T7& a7);
+
+ /* See the documentation for format(const T1& a1).
+ *
+ * @newin{2,16}
+ */
+ template <class T1, class T2, class T3, class T4,
+ class T5, class T6, class T7, class T8>
+ static inline
+ ustring format(const T1& a1, const T2& a2, const T3& a3, const T4& a4,
+ const T5& a5, const T6& a6, const T7& a7, const T8& a8);
+//! @}
+
+private:
+
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
+
+#ifdef GLIBMM_HAVE_STD_ITERATOR_TRAITS
+ template <class In, class ValueType = typename std::iterator_traits<In>::value_type>
+#else
+ template <class In, class ValueType = typename Glib::IteratorTraits<In>::value_type>
+#endif
+ struct SequenceToString;
+
+ //The Tru64 compiler needs these partial specializations to be declared here,
+ //as well as defined later. That's probably correct. murrayc.
+ template <class In> struct SequenceToString<In, char>;
+ template <class In> struct SequenceToString<In, gunichar>;
+
+ template <class T> class Stringify;
+ class FormatStream;
+
+ static ustring compose_argv(const ustring& fmt, int argc, const ustring* const* argv);
+
+#endif /* DOXYGEN_SHOULD_SKIP_THIS */
+
+ std::string string_;
+};
+
+
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
+
+template <class In, class ValueType>
+struct ustring::SequenceToString
+{};
+
+template <class In>
+struct ustring::SequenceToString<In, char> : public std::string
+{
+ SequenceToString(In pbegin, In pend);
+};
+
+template <class In>
+struct ustring::SequenceToString<In, gunichar> : public std::string
+{
+ SequenceToString(In pbegin, In pend);
+};
+
+template <>
+struct ustring::SequenceToString<Glib::ustring::iterator, gunichar> : public std::string
+{
+ SequenceToString(Glib::ustring::iterator pbegin, Glib::ustring::iterator pend);
+};
+
+template <>
+struct ustring::SequenceToString<Glib::ustring::const_iterator, gunichar> : public std::string
+{
+ SequenceToString(Glib::ustring::const_iterator pbegin, Glib::ustring::const_iterator pend);
+};
+
+class ustring::FormatStream
+{
+private:
+#ifdef GLIBMM_HAVE_WIDE_STREAM
+ typedef std::wostringstream StreamType;
+#else
+ typedef std::ostringstream StreamType;
+#endif
+ StreamType stream_;
+
+ // noncopyable
+ FormatStream(const ustring::FormatStream&);
+ FormatStream& operator=(const ustring::FormatStream&);
+
+public:
+ FormatStream();
+ ~FormatStream();
+
+ template <class T> inline void stream(const T& value);
+
+ inline void stream(const char* value);
+
+ //This overload exists to avoid the templated stream() being called for non-const char*.
+ inline void stream(char* value);
+
+ ustring to_string() const;
+};
+
+#endif /* DOXYGEN_SHOULD_SKIP_THIS */
+
+
+/** Stream input operator.
+ * @relates Glib::ustring
+ * @throw Glib::ConvertError
+ */
+std::istream& operator>>(std::istream& is, Glib::ustring& utf8_string);
+
+/** Stream output operator.
+ * @relates Glib::ustring
+ * @throw Glib::ConvertError
+ */
+std::ostream& operator<<(std::ostream& os, const Glib::ustring& utf8_string);
+
+#ifdef GLIBMM_HAVE_WIDE_STREAM
+
+/** Wide stream input operator.
+ * @relates Glib::ustring
+ * @throw Glib::ConvertError
+ */
+std::wistream& operator>>(std::wistream& is, ustring& utf8_string);
+
+/** Wide stream output operator.
+ * @relates Glib::ustring
+ * @throw Glib::ConvertError
+ */
+std::wostream& operator<<(std::wostream& os, const ustring& utf8_string);
+
+#endif /* GLIBMM_HAVE_WIDE_STREAM */
+
+/***************************************************************************/
+/* Inline implementation */
+/***************************************************************************/
+
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
+
+/**** Glib::ustring_Iterator<> *********************************************/
+
+template <class T> inline
+ustring_Iterator<T>::ustring_Iterator(T pos)
+:
+ pos_ (pos)
+{}
+
+template <class T> inline
+T ustring_Iterator<T>::base() const
+{
+ return pos_;
+}
+
+template <class T> inline
+ustring_Iterator<T>::ustring_Iterator()
+:
+ pos_ ()
+{}
+
+template <class T> inline
+ustring_Iterator<T>::ustring_Iterator(const ustring_Iterator<std::string::iterator>& other)
+:
+ pos_ (other.base())
+{}
+
+template <class T> inline
+typename ustring_Iterator<T>::value_type ustring_Iterator<T>::operator*() const
+{
+ return Glib::get_unichar_from_std_iterator(pos_);
+}
+
+template <class T> inline
+ustring_Iterator<T>& ustring_Iterator<T>::operator++()
+{
+ pos_ += g_utf8_skip[static_cast<unsigned char>(*pos_)];
+ return *this;
+}
+
+template <class T> inline
+const ustring_Iterator<T> ustring_Iterator<T>::operator++(int)
+{
+ const ustring_Iterator<T> temp (*this);
+ this->operator++();
+ return temp;
+}
+
+template <class T> inline
+ustring_Iterator<T>& ustring_Iterator<T>::operator--()
+{
+ do --pos_; while((static_cast<unsigned char>(*pos_) & 0xC0u) == 0x80);
+ return *this;
+}
+
+template <class T> inline
+const ustring_Iterator<T> ustring_Iterator<T>::operator--(int)
+{
+ const ustring_Iterator<T> temp (*this);
+ this->operator--();
+ return temp;
+}
+
+#endif /* DOXYGEN_SHOULD_SKIP_THIS */
+
+
+/** @relates Glib::ustring_Iterator */
+inline
+bool operator==(const Glib::ustring::const_iterator& lhs, const Glib::ustring::const_iterator& rhs)
+{
+ return (lhs.base() == rhs.base());
+}
+
+/** @relates Glib::ustring_Iterator */
+inline
+bool operator!=(const Glib::ustring::const_iterator& lhs, const Glib::ustring::const_iterator& rhs)
+{
+ return (lhs.base() != rhs.base());
+}
+
+/** @relates Glib::ustring_Iterator */
+inline
+bool operator<(const Glib::ustring::const_iterator& lhs, const Glib::ustring::const_iterator& rhs)
+{
+ return (lhs.base() < rhs.base());
+}
+
+/** @relates Glib::ustring_Iterator */
+inline
+bool operator>(const Glib::ustring::const_iterator& lhs, const Glib::ustring::const_iterator& rhs)
+{
+ return (lhs.base() > rhs.base());
+}
+
+/** @relates Glib::ustring_Iterator */
+inline
+bool operator<=(const Glib::ustring::const_iterator& lhs, const Glib::ustring::const_iterator& rhs)
+{
+ return (lhs.base() <= rhs.base());
+}
+
+/** @relates Glib::ustring_Iterator */
+inline
+bool operator>=(const Glib::ustring::const_iterator& lhs, const Glib::ustring::const_iterator& rhs)
+{
+ return (lhs.base() >= rhs.base());
+}
+
+
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
+
+/**** Glib::ustring::SequenceToString **************************************/
+
+template <class In>
+ustring::SequenceToString<In,char>::SequenceToString(In pbegin, In pend)
+:
+ std::string(pbegin, pend)
+{}
+
+template <class In>
+ustring::SequenceToString<In,gunichar>::SequenceToString(In pbegin, In pend)
+{
+ char utf8_buf[6]; // stores a single UTF-8 character
+
+ for(; pbegin != pend; ++pbegin)
+ {
+ const std::string::size_type utf8_len = g_unichar_to_utf8(*pbegin, utf8_buf);
+ this->append(utf8_buf, utf8_len);
+ }
+}
+
+/**** Glib::ustring::FormatStream ******************************************/
+
+template <class T> inline
+void ustring::FormatStream::stream(const T& value)
+{
+ stream_ << value;
+}
+
+inline
+void ustring::FormatStream::stream(const char* value)
+{
+ stream_ << ustring(value);
+}
+
+inline
+void ustring::FormatStream::stream(char* value)
+{
+ stream_ << ustring(value);
+}
+
+/**** Glib::ustring ********************************************************/
+
+template <class In>
+ustring::ustring(In pbegin, In pend)
+:
+ string_ (Glib::ustring::SequenceToString<In>(pbegin, pend))
+{}
+
+template <class In>
+ustring& ustring::assign(In pbegin, In pend)
+{
+ Glib::ustring::SequenceToString<In> temp_string (pbegin, pend);
+ string_.swap(temp_string); // constant-time operation
+ return *this;
+}
+
+template <class In>
+ustring& ustring::append(In pbegin, In pend)
+{
+ string_.append(Glib::ustring::SequenceToString<In>(pbegin, pend));
+ return *this;
+}
+
+template <class In>
+void ustring::insert(ustring::iterator p, In pbegin, In pend)
+{
+ string_.insert(p.base(), Glib::ustring::SequenceToString<In>(pbegin, pend));
+}
+
+template <class In>
+ustring& ustring::replace(ustring::iterator pbegin, ustring::iterator pend, In pbegin2, In pend2)
+{
+ string_.replace(
+ pbegin.base(), pend.base(),
+ Glib::ustring::SequenceToString<In>(pbegin2, pend2));
+ return *this;
+}
+
+// The ustring methods substr() and operator std::string() are inline,
+// so that the compiler has a fair chance to optimize the copy ctor away.
+
+inline
+ustring ustring::substr(ustring::size_type i, ustring::size_type n) const
+{
+ return ustring(*this, i, n);
+}
+
+inline
+ustring::operator std::string() const
+{
+ return string_;
+}
+
+inline
+const std::string& ustring::raw() const
+{
+ return string_;
+}
+
+template <class T1>
+inline // static
+ustring ustring::format(const T1& a1)
+{
+ ustring::FormatStream buf;
+ buf.stream(a1);
+ return buf.to_string();
+}
+
+template <class T1, class T2>
+inline // static
+ustring ustring::format(const T1& a1, const T2& a2)
+{
+ ustring::FormatStream buf;
+ buf.stream(a1);
+ buf.stream(a2);
+ return buf.to_string();
+}
+
+template <class T1, class T2, class T3>
+inline // static
+ustring ustring::format(const T1& a1, const T2& a2, const T3& a3)
+{
+ ustring::FormatStream buf;
+ buf.stream(a1);
+ buf.stream(a2);
+ buf.stream(a3);
+ return buf.to_string();
+}
+
+template <class T1, class T2, class T3, class T4>
+inline // static
+ustring ustring::format(const T1& a1, const T2& a2, const T3& a3, const T4& a4)
+{
+ ustring::FormatStream buf;
+ buf.stream(a1);
+ buf.stream(a2);
+ buf.stream(a3);
+ buf.stream(a4);
+ return buf.to_string();
+}
+
+template <class T1, class T2, class T3, class T4, class T5>
+inline // static
+ustring ustring::format(const T1& a1, const T2& a2, const T3& a3,
+ const T4& a4, const T5& a5)
+{
+ ustring::FormatStream buf;
+ buf.stream(a1);
+ buf.stream(a2);
+ buf.stream(a3);
+ buf.stream(a4);
+ buf.stream(a5);
+ return buf.to_string();
+}
+
+template <class T1, class T2, class T3, class T4, class T5, class T6>
+inline // static
+ustring ustring::format(const T1& a1, const T2& a2, const T3& a3,
+ const T4& a4, const T5& a5, const T6& a6)
+{
+ ustring::FormatStream buf;
+ buf.stream(a1);
+ buf.stream(a2);
+ buf.stream(a3);
+ buf.stream(a4);
+ buf.stream(a5);
+ buf.stream(a6);
+ return buf.to_string();
+}
+
+template <class T1, class T2, class T3, class T4,
+ class T5, class T6, class T7>
+inline // static
+ustring ustring::format(const T1& a1, const T2& a2, const T3& a3, const T4& a4,
+ const T5& a5, const T6& a6, const T7& a7)
+{
+ ustring::FormatStream buf;
+ buf.stream(a1);
+ buf.stream(a2);
+ buf.stream(a3);
+ buf.stream(a4);
+ buf.stream(a5);
+ buf.stream(a6);
+ buf.stream(a7);
+ return buf.to_string();
+}
+
+template <class T1, class T2, class T3, class T4,
+ class T5, class T6, class T7, class T8>
+inline // static
+ustring ustring::format(const T1& a1, const T2& a2, const T3& a3, const T4& a4,
+ const T5& a5, const T6& a6, const T7& a7, const T8& a8)
+{
+ ustring::FormatStream buf;
+ buf.stream(a1);
+ buf.stream(a2);
+ buf.stream(a3);
+ buf.stream(a4);
+ buf.stream(a5);
+ buf.stream(a6);
+ buf.stream(a7);
+ buf.stream(a8);
+ return buf.to_string();
+}
+
+/** An inner class used by ustring.
+ */
+template <class T>
+class ustring::Stringify
+{
+private:
+ ustring string_;
+
+ // noncopyable
+ Stringify(const ustring::Stringify<T>&);
+ Stringify<T>& operator=(const ustring::Stringify<T>&);
+
+public:
+ explicit inline Stringify(const T& arg) : string_ (ustring::format(arg)) {}
+
+ //TODO: Why is this here? See the template specialization:
+ explicit inline Stringify(const char* arg) : string_(arg) {}
+
+ inline const ustring* ptr() const { return &string_; }
+};
+
+/// A template specialization for Stringify<ustring>:
+template <>
+class ustring::Stringify<ustring>
+{
+private:
+ const ustring& string_;
+
+ // noncopyable
+ Stringify(const ustring::Stringify<ustring>&);
+ Stringify<ustring>& operator=(const ustring::Stringify<ustring>&);
+
+public:
+ explicit inline Stringify(const ustring& arg) : string_(arg) {}
+ inline const ustring* ptr() const { return &string_; }
+};
+
+/** A template specialization for Stringify<const char*>,
+ * because the regular template has ambiguous constructor overloads for char*.
+ */
+template <>
+class ustring::Stringify<const char*>
+{
+private:
+ const ustring string_;
+
+ // noncopyable
+ Stringify(const ustring::Stringify<const char*>&);
+ Stringify<ustring>& operator=(const ustring::Stringify<const char*>&);
+
+public:
+ explicit inline Stringify(const char* arg) : string_(arg) {}
+ inline const ustring* ptr() const { return &string_; }
+};
+
+/** A template specialization for Stringify<char[N]> (for string literals),
+ * because the regular template has ambiguous constructor overloads for char*.
+ */
+template <std::size_t N>
+class ustring::Stringify<char[N]>
+{
+private:
+ const ustring string_;
+
+ // noncopyable
+ Stringify(const ustring::Stringify<char[N]>&);
+ Stringify<ustring>& operator=(const ustring::Stringify<char[N]>&);
+
+public:
+ explicit inline Stringify(const char arg[N]) : string_(arg) {}
+ inline const ustring* ptr() const { return &string_; }
+};
+
+template <class T1>
+inline // static
+ustring ustring::compose(const ustring& fmt)
+{
+ return ustring::compose_argv(fmt, 0, 0);
+}
+
+template <class T1>
+inline // static
+ustring ustring::compose(const ustring& fmt, const T1& a1)
+{
+ const ustring::Stringify<T1> s1(a1);
+
+ const ustring *const argv[] = { s1.ptr() };
+ return ustring::compose_argv(fmt, G_N_ELEMENTS(argv), argv);
+}
+
+template <class T1, class T2>
+inline // static
+ustring ustring::compose(const ustring& fmt, const T1& a1, const T2& a2)
+{
+ const ustring::Stringify<T1> s1(a1);
+ const ustring::Stringify<T2> s2(a2);
+
+ const ustring *const argv[] = { s1.ptr(), s2.ptr() };
+ return ustring::compose_argv(fmt, G_N_ELEMENTS(argv), argv);
+}
+
+template <class T1, class T2, class T3>
+inline // static
+ustring ustring::compose(const ustring& fmt,
+ const T1& a1, const T2& a2, const T3& a3)
+{
+ const ustring::Stringify<T1> s1(a1);
+ const ustring::Stringify<T2> s2(a2);
+ const ustring::Stringify<T3> s3(a3);
+
+ const ustring *const argv[] = { s1.ptr(), s2.ptr(), s3.ptr() };
+ return ustring::compose_argv(fmt, G_N_ELEMENTS(argv), argv);
+}
+
+template <class T1, class T2, class T3, class T4>
+inline // static
+ustring ustring::compose(const ustring& fmt,
+ const T1& a1, const T2& a2, const T3& a3, const T4& a4)
+{
+ const ustring::Stringify<T1> s1(a1);
+ const ustring::Stringify<T2> s2(a2);
+ const ustring::Stringify<T3> s3(a3);
+ const ustring::Stringify<T4> s4(a4);
+
+ const ustring *const argv[] = { s1.ptr(), s2.ptr(), s3.ptr(), s4.ptr() };
+ return ustring::compose_argv(fmt, G_N_ELEMENTS(argv), argv);
+}
+
+template <class T1, class T2, class T3, class T4, class T5>
+inline // static
+ustring ustring::compose(const ustring& fmt,
+ const T1& a1, const T2& a2, const T3& a3,
+ const T4& a4, const T5& a5)
+{
+ const ustring::Stringify<T1> s1(a1);
+ const ustring::Stringify<T2> s2(a2);
+ const ustring::Stringify<T3> s3(a3);
+ const ustring::Stringify<T4> s4(a4);
+ const ustring::Stringify<T5> s5(a5);
+
+ const ustring *const argv[] = { s1.ptr(), s2.ptr(), s3.ptr(), s4.ptr(), s5.ptr() };
+ return ustring::compose_argv(fmt, G_N_ELEMENTS(argv), argv);
+}
+
+template <class T1, class T2, class T3, class T4, class T5, class T6>
+inline // static
+ustring ustring::compose(const ustring& fmt,
+ const T1& a1, const T2& a2, const T3& a3,
+ const T4& a4, const T5& a5, const T6& a6)
+{
+ const ustring::Stringify<T1> s1(a1);
+ const ustring::Stringify<T2> s2(a2);
+ const ustring::Stringify<T3> s3(a3);
+ const ustring::Stringify<T4> s4(a4);
+ const ustring::Stringify<T5> s5(a5);
+ const ustring::Stringify<T6> s6(a6);
+
+ const ustring *const argv[] = { s1.ptr(), s2.ptr(), s3.ptr(), s4.ptr(),
+ s5.ptr(), s6.ptr() };
+ return ustring::compose_argv(fmt, G_N_ELEMENTS(argv), argv);
+}
+
+template <class T1, class T2, class T3, class T4, class T5, class T6, class T7>
+inline // static
+ustring ustring::compose(const ustring& fmt,
+ const T1& a1, const T2& a2, const T3& a3,
+ const T4& a4, const T5& a5, const T6& a6, const T7& a7)
+{
+ const ustring::Stringify<T1> s1(a1);
+ const ustring::Stringify<T2> s2(a2);
+ const ustring::Stringify<T3> s3(a3);
+ const ustring::Stringify<T4> s4(a4);
+ const ustring::Stringify<T5> s5(a5);
+ const ustring::Stringify<T6> s6(a6);
+ const ustring::Stringify<T7> s7(a7);
+
+ const ustring *const argv[] = { s1.ptr(), s2.ptr(), s3.ptr(), s4.ptr(),
+ s5.ptr(), s6.ptr(), s7.ptr() };
+ return ustring::compose_argv(fmt, G_N_ELEMENTS(argv), argv);
+}
+
+template <class T1, class T2, class T3, class T4,
+ class T5, class T6, class T7, class T8>
+inline // static
+ustring ustring::compose(const ustring& fmt,
+ const T1& a1, const T2& a2, const T3& a3,
+ const T4& a4, const T5& a5, const T6& a6,
+ const T7& a7, const T8& a8)
+{
+ const ustring::Stringify<T1> s1(a1);
+ const ustring::Stringify<T2> s2(a2);
+ const ustring::Stringify<T3> s3(a3);
+ const ustring::Stringify<T4> s4(a4);
+ const ustring::Stringify<T5> s5(a5);
+ const ustring::Stringify<T6> s6(a6);
+ const ustring::Stringify<T7> s7(a7);
+ const ustring::Stringify<T8> s8(a8);
+
+ const ustring *const argv[] = { s1.ptr(), s2.ptr(), s3.ptr(), s4.ptr(),
+ s5.ptr(), s6.ptr(), s7.ptr(), s8.ptr() };
+ return ustring::compose_argv(fmt, G_N_ELEMENTS(argv), argv);
+}
+
+template <class T1, class T2, class T3, class T4, class T5,
+ class T6, class T7, class T8, class T9>
+inline // static
+ustring ustring::compose(const ustring& fmt,
+ const T1& a1, const T2& a2, const T3& a3,
+ const T4& a4, const T5& a5, const T6& a6,
+ const T7& a7, const T8& a8, const T9& a9)
+{
+ const ustring::Stringify<T1> s1(a1);
+ const ustring::Stringify<T2> s2(a2);
+ const ustring::Stringify<T3> s3(a3);
+ const ustring::Stringify<T4> s4(a4);
+ const ustring::Stringify<T5> s5(a5);
+ const ustring::Stringify<T6> s6(a6);
+ const ustring::Stringify<T7> s7(a7);
+ const ustring::Stringify<T8> s8(a8);
+ const ustring::Stringify<T9> s9(a9);
+
+ const ustring *const argv[] = { s1.ptr(), s2.ptr(), s3.ptr(), s4.ptr(),
+ s5.ptr(), s6.ptr(), s7.ptr(), s8.ptr(), s9.ptr() };
+ return ustring::compose_argv(fmt, G_N_ELEMENTS(argv), argv);
+}
+
+#endif /* DOXYGEN_SHOULD_SKIP_THIS */
+
+
+/** @relates Glib::ustring */
+inline
+void swap(ustring& lhs, ustring& rhs)
+{
+ lhs.swap(rhs);
+}
+
+
+/**** Glib::ustring -- comparison operators ********************************/
+
+/** @relates Glib::ustring */
+inline bool operator==(const ustring& lhs, const ustring& rhs)
+ { return (lhs.compare(rhs) == 0); }
+
+/** @relates Glib::ustring */
+inline bool operator==(const ustring& lhs, const char* rhs)
+ { return (lhs.compare(rhs) == 0); }
+
+/** @relates Glib::ustring */
+inline bool operator==(const char* lhs, const ustring& rhs)
+ { return (rhs.compare(lhs) == 0); }
+
+
+/** @relates Glib::ustring */
+inline bool operator!=(const ustring& lhs, const ustring& rhs)
+ { return (lhs.compare(rhs) != 0); }
+
+/** @relates Glib::ustring */
+inline bool operator!=(const ustring& lhs, const char* rhs)
+ { return (lhs.compare(rhs) != 0); }
+
+/** @relates Glib::ustring */
+inline bool operator!=(const char* lhs, const ustring& rhs)
+ { return (rhs.compare(lhs) != 0); }
+
+
+/** @relates Glib::ustring */
+inline bool operator<(const ustring& lhs, const ustring& rhs)
+ { return (lhs.compare(rhs) < 0); }
+
+/** @relates Glib::ustring */
+inline bool operator<(const ustring& lhs, const char* rhs)
+ { return (lhs.compare(rhs) < 0); }
+
+/** @relates Glib::ustring */
+inline bool operator<(const char* lhs, const ustring& rhs)
+ { return (rhs.compare(lhs) > 0); }
+
+
+/** @relates Glib::ustring */
+inline bool operator>(const ustring& lhs, const ustring& rhs)
+ { return (lhs.compare(rhs) > 0); }
+
+/** @relates Glib::ustring */
+inline bool operator>(const ustring& lhs, const char* rhs)
+ { return (lhs.compare(rhs) > 0); }
+
+/** @relates Glib::ustring */
+inline bool operator>(const char* lhs, const ustring& rhs)
+ { return (rhs.compare(lhs) < 0); }
+
+
+/** @relates Glib::ustring */
+inline bool operator<=(const ustring& lhs, const ustring& rhs)
+ { return (lhs.compare(rhs) <= 0); }
+
+/** @relates Glib::ustring */
+inline bool operator<=(const ustring& lhs, const char* rhs)
+ { return (lhs.compare(rhs) <= 0); }
+
+/** @relates Glib::ustring */
+inline bool operator<=(const char* lhs, const ustring& rhs)
+ { return (rhs.compare(lhs) >= 0); }
+
+
+/** @relates Glib::ustring */
+inline bool operator>=(const ustring& lhs, const ustring& rhs)
+ { return (lhs.compare(rhs) >= 0); }
+
+/** @relates Glib::ustring */
+inline bool operator>=(const ustring& lhs, const char* rhs)
+ { return (lhs.compare(rhs) >= 0); }
+
+/** @relates Glib::ustring */
+inline bool operator>=(const char* lhs, const ustring& rhs)
+ { return (rhs.compare(lhs) <= 0); }
+
+
+/**** Glib::ustring -- concatenation operators *****************************/
+
+/** @relates Glib::ustring */
+inline ustring operator+(const ustring& lhs, const ustring& rhs)
+{
+ ustring temp(lhs);
+ temp += rhs;
+ return temp;
+}
+
+/** @relates Glib::ustring */
+inline ustring operator+(const ustring& lhs, const char* rhs)
+{
+ ustring temp(lhs);
+ temp += rhs;
+ return temp;
+}
+
+/** @relates Glib::ustring */
+inline ustring operator+(const char* lhs, const ustring& rhs)
+{
+ ustring temp(lhs);
+ temp += rhs;
+ return temp;
+}
+
+/** @relates Glib::ustring */
+inline ustring operator+(const ustring& lhs, gunichar rhs)
+{
+ ustring temp(lhs);
+ temp += rhs;
+ return temp;
+}
+
+/** @relates Glib::ustring */
+inline ustring operator+(gunichar lhs, const ustring& rhs)
+{
+ ustring temp(1, lhs);
+ temp += rhs;
+ return temp;
+}
+
+/** @relates Glib::ustring */
+inline ustring operator+(const ustring& lhs, char rhs)
+{
+ ustring temp(lhs);
+ temp += rhs;
+ return temp;
+}
+
+/** @relates Glib::ustring */
+inline ustring operator+(char lhs, const ustring& rhs)
+{
+ ustring temp(1, lhs);
+ temp += rhs;
+ return temp;
+}
+
+} // namespace Glib
+
+
+#endif /* _GLIBMM_USTRING_H */
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tbr...@us...> - 2012-03-20 14:32:22
|
Revision: 211
http://xmlwrapp.svn.sourceforge.net/xmlwrapp/?rev=211&view=rev
Author: tbrowder2
Date: 2012-03-20 14:32:13 +0000 (Tue, 20 Mar 2012)
Log Message:
-----------
add dir for installation
Added Paths:
-----------
trunk/include/xmlwrappstring/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tbr...@us...> - 2012-03-20 14:25:34
|
Revision: 210
http://xmlwrapp.svn.sourceforge.net/xmlwrapp/?rev=210&view=rev
Author: tbrowder2
Date: 2012-03-20 14:25:23 +0000 (Tue, 20 Mar 2012)
Log Message:
-----------
renaming ustring
Modified Paths:
--------------
trunk/src/Makefile.am
Modified: trunk/src/Makefile.am
===================================================================
--- trunk/src/Makefile.am 2012-03-20 14:22:14 UTC (rev 209)
+++ trunk/src/Makefile.am 2012-03-20 14:25:23 UTC (rev 210)
@@ -2,18 +2,18 @@
AM_CPPFLAGS = -I$(top_srcdir)/include $(CXXFLAGS_VISIBILITY)
if WITH_XSLT
-lib_LTLIBRARIES = libxmlwrapp.la libxsltwrapp.la libustring.la
+lib_LTLIBRARIES = libxmlwrapp.la libxsltwrapp.la libxmlwrappstring.la
else
-lib_LTLIBRARIES = libxmlwrapp.la libustring.la
+lib_LTLIBRARIES = libxmlwrapp.la libxmlwrappstring.la
endif
-libustring_la_CPPFLAGS = $(AM_CPPFLAGS) $(LIBXML_CFLAGS)
-libustring_la_LIBADD = $(LIBXML_LIBS)
-libustring_la_LDFLAGS = -version-info 6:0:1 -no-undefined
+libxmlwrappstring_la_CPPFLAGS = $(AM_CPPFLAGS) $(LIBXML_CFLAGS)
+libxmlwrappstring_la_LIBADD = $(LIBXML_LIBS)
+libxmlwrappstring_la_LDFLAGS = -version-info 6:0:1 -no-undefined
-libustring_la_SOURCES = \
- libustring/ustring.cc \
- libustring/ustring.h \
+libxmlwrappstring_la_SOURCES = \
+ libxmlwrappstring/xmlwrappstring.cc \
+ libxmlwrappstring/xmlwrappstring.h \
libxmlwrapp_la_CPPFLAGS = $(AM_CPPFLAGS) $(LIBXML_CFLAGS)
libxmlwrapp_la_LIBADD = $(LIBXML_LIBS)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tbr...@us...> - 2012-03-20 14:22:25
|
Revision: 209
http://xmlwrapp.svn.sourceforge.net/xmlwrapp/?rev=209&view=rev
Author: tbrowder2
Date: 2012-03-20 14:22:14 +0000 (Tue, 20 Mar 2012)
Log Message:
-----------
renaming for clarity
Added Paths:
-----------
trunk/tests/xmlwrappstring/test_xmlwrappstring_compose.cc
trunk/tests/xmlwrappstring/test_xmlwrappstring_format.cc
Removed Paths:
-------------
trunk/tests/xmlwrappstring/test_ustring_compose.cc
trunk/tests/xmlwrappstring/test_ustring_format.cc
Deleted: trunk/tests/xmlwrappstring/test_ustring_compose.cc
===================================================================
--- trunk/tests/xmlwrappstring/test_ustring_compose.cc 2012-03-20 14:21:06 UTC (rev 208)
+++ trunk/tests/xmlwrappstring/test_ustring_compose.cc 2012-03-20 14:22:14 UTC (rev 209)
@@ -1,36 +0,0 @@
-#include <glibmm.h>
-
-#include <iostream>
-
-//Use this line if you want debug output:
-//std::ostream& ostr = std::cout;
-
-//This seems nicer and more useful than putting an ifdef around the use of ostr:
-std::stringstream debug;
-std::ostream& ostr = debug;
-
-int main(int, char**)
-{
- Glib::init();
-
- //TODO: Check the output?
- const char *constant_string = "constant string";
- ostr << Glib::ustring::compose("Compose strings: %1", constant_string) << std::endl;
- ostr << Glib::ustring::compose("Compose strings: %1 and %2", constant_string, "string_literal") << std::endl;
-
- ostr << Glib::ustring::compose("Compose strings: %1 and %2", 123, 123.4567) << std::endl;
-
- ostr << Glib::ustring::compose("Compose strings: %1 and %2", (int)123, (float)123.4567) << std::endl;
-
- ostr << Glib::ustring::compose("Compose strings: %1 and %2", Glib::ustring("foo"), std::string("goo")) << std::endl;
-
- int i = 1;
- ostr << Glib::ustring::compose("Compose strings: %1 and %2", 'f', &i) << std::endl;
-
- ostr << Glib::ustring::compose("%1 is lower than 0x%2.", 12, Glib::ustring::format(std::hex, 16)) << std::endl;
-
- //TODO: More tests.
-
- return EXIT_SUCCESS;
-}
-
Deleted: trunk/tests/xmlwrappstring/test_ustring_format.cc
===================================================================
--- trunk/tests/xmlwrappstring/test_ustring_format.cc 2012-03-20 14:21:06 UTC (rev 208)
+++ trunk/tests/xmlwrappstring/test_ustring_format.cc 2012-03-20 14:22:14 UTC (rev 209)
@@ -1,30 +0,0 @@
-#include <glibmm.h>
-
-#include <iostream>
-
-int main(int, char**)
-{
- Glib::init();
-
- char carr[10] = "Užduotys";
- char * const cptr = carr;
-
- /*
- std::wostringstream wsout;
- wsout << carr;
- const std::wstring& wstr = wsout.str();
- const gunichar * const data = reinterpret_cast<const gunichar *>(
- wstr.data());
-
- for(int i = 0; wstr.size() > i; ++i)
- std::cout << data[i] << std::endl;
- */
-
- //Check both the const char* and char* versions.
- Glib::ustring::format(carr);
-
- //This threw an exception before we added a ustring::FormatStream::stream(char*) overload.
- Glib::ustring::format(cptr);
-
- return EXIT_SUCCESS;
-}
Copied: trunk/tests/xmlwrappstring/test_xmlwrappstring_compose.cc (from rev 208, trunk/tests/xmlwrappstring/test_ustring_compose.cc)
===================================================================
--- trunk/tests/xmlwrappstring/test_xmlwrappstring_compose.cc (rev 0)
+++ trunk/tests/xmlwrappstring/test_xmlwrappstring_compose.cc 2012-03-20 14:22:14 UTC (rev 209)
@@ -0,0 +1,36 @@
+#include <glibmm.h>
+
+#include <iostream>
+
+//Use this line if you want debug output:
+//std::ostream& ostr = std::cout;
+
+//This seems nicer and more useful than putting an ifdef around the use of ostr:
+std::stringstream debug;
+std::ostream& ostr = debug;
+
+int main(int, char**)
+{
+ Glib::init();
+
+ //TODO: Check the output?
+ const char *constant_string = "constant string";
+ ostr << Glib::ustring::compose("Compose strings: %1", constant_string) << std::endl;
+ ostr << Glib::ustring::compose("Compose strings: %1 and %2", constant_string, "string_literal") << std::endl;
+
+ ostr << Glib::ustring::compose("Compose strings: %1 and %2", 123, 123.4567) << std::endl;
+
+ ostr << Glib::ustring::compose("Compose strings: %1 and %2", (int)123, (float)123.4567) << std::endl;
+
+ ostr << Glib::ustring::compose("Compose strings: %1 and %2", Glib::ustring("foo"), std::string("goo")) << std::endl;
+
+ int i = 1;
+ ostr << Glib::ustring::compose("Compose strings: %1 and %2", 'f', &i) << std::endl;
+
+ ostr << Glib::ustring::compose("%1 is lower than 0x%2.", 12, Glib::ustring::format(std::hex, 16)) << std::endl;
+
+ //TODO: More tests.
+
+ return EXIT_SUCCESS;
+}
+
Copied: trunk/tests/xmlwrappstring/test_xmlwrappstring_format.cc (from rev 208, trunk/tests/xmlwrappstring/test_ustring_format.cc)
===================================================================
--- trunk/tests/xmlwrappstring/test_xmlwrappstring_format.cc (rev 0)
+++ trunk/tests/xmlwrappstring/test_xmlwrappstring_format.cc 2012-03-20 14:22:14 UTC (rev 209)
@@ -0,0 +1,30 @@
+#include <glibmm.h>
+
+#include <iostream>
+
+int main(int, char**)
+{
+ Glib::init();
+
+ char carr[10] = "Užduotys";
+ char * const cptr = carr;
+
+ /*
+ std::wostringstream wsout;
+ wsout << carr;
+ const std::wstring& wstr = wsout.str();
+ const gunichar * const data = reinterpret_cast<const gunichar *>(
+ wstr.data());
+
+ for(int i = 0; wstr.size() > i; ++i)
+ std::cout << data[i] << std::endl;
+ */
+
+ //Check both the const char* and char* versions.
+ Glib::ustring::format(carr);
+
+ //This threw an exception before we added a ustring::FormatStream::stream(char*) overload.
+ Glib::ustring::format(cptr);
+
+ return EXIT_SUCCESS;
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tbr...@us...> - 2012-03-20 14:21:17
|
Revision: 208
http://xmlwrapp.svn.sourceforge.net/xmlwrapp/?rev=208&view=rev
Author: tbrowder2
Date: 2012-03-20 14:21:06 +0000 (Tue, 20 Mar 2012)
Log Message:
-----------
renaming for clarity
Modified Paths:
--------------
trunk/tests/Makefile.am
Added Paths:
-----------
trunk/tests/xmlwrappstring/
Removed Paths:
-------------
trunk/tests/ustring/
Modified: trunk/tests/Makefile.am
===================================================================
--- trunk/tests/Makefile.am 2012-03-20 14:16:52 UTC (rev 207)
+++ trunk/tests/Makefile.am 2012-03-20 14:21:06 UTC (rev 208)
@@ -3,7 +3,7 @@
AM_CPPFLAGS = -I$(top_srcdir)/include
LIBS = $(top_builddir)/src/libxmlwrapp.la \
- $(top_builddir)/src/libustring.la \
+ $(top_builddir)/src/libxmlwrappstring.la \
$(BOOST_UNIT_TEST_FRAMEWORK_LIBS) $(BOOST_UNIT_TEST_FRAMEWORK_LDFLAGS) \
$(BOOST_IOSTREAMS_LIBS) $(BOOST_IOSTREAMS_LDFLAGS)
@@ -17,8 +17,8 @@
event/test_event.cc \
node/test_node.cc \
tree/test_tree.cc \
- ustring/test_ustring_compose.cc \
- ustring/test_ustring_format.cc \
+ xmlwrappstring/test_xmlwrappstring_compose.cc \
+ xmlwrappstring/test_xmlwrappstring_format.cc \
if WITH_XSLT
LIBS += $(top_builddir)/src/libxsltwrapp.la
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tbr...@us...> - 2012-03-20 14:16:58
|
Revision: 207
http://xmlwrapp.svn.sourceforge.net/xmlwrapp/?rev=207&view=rev
Author: tbrowder2
Date: 2012-03-20 14:16:52 +0000 (Tue, 20 Mar 2012)
Log Message:
-----------
remove empty dir
Removed Paths:
-------------
trunk/src/libustring/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tbr...@us...> - 2012-03-20 14:16:27
|
Revision: 206
http://xmlwrapp.svn.sourceforge.net/xmlwrapp/?rev=206&view=rev
Author: tbrowder2
Date: 2012-03-20 14:16:16 +0000 (Tue, 20 Mar 2012)
Log Message:
-----------
provisions for new string class
Modified Paths:
--------------
trunk/Makefile.am
Added Paths:
-----------
trunk/xmlwrappstring.pc.in
Modified: trunk/Makefile.am
===================================================================
--- trunk/Makefile.am 2012-03-20 14:10:29 UTC (rev 205)
+++ trunk/Makefile.am 2012-03-20 14:16:16 UTC (rev 206)
@@ -4,9 +4,9 @@
pkgconfigdir=$(libdir)/pkgconfig
if WITH_XSLT
-pkgconfig_DATA = xmlwrapp.pc xsltwrapp.pc
+pkgconfig_DATA = xmlwrapp.pc xmlwrappstring.pc xsltwrapp.pc
else
-pkgconfig_DATA = xmlwrapp.pc
+pkgconfig_DATA = xmlwrapp.pc xmlwrappstring.pc
endif
bin_SCRIPTS = xmlwrapp-config
Added: trunk/xmlwrappstring.pc.in
===================================================================
--- trunk/xmlwrappstring.pc.in (rev 0)
+++ trunk/xmlwrappstring.pc.in 2012-03-20 14:16:16 UTC (rev 206)
@@ -0,0 +1,11 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+Name: xmlwrappstring
+Version: @VERSION@
+Description: A C++ UTF-8 string class
+Requires: xmlwrapp = @VERSION@
+Libs: -L${libdir} -lxmlwrapp
+Cflags: -I${includedir}
Property changes on: trunk/xmlwrappstring.pc.in
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:eol-style
+ native
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tbr...@us...> - 2012-03-20 14:10:42
|
Revision: 205
http://xmlwrapp.svn.sourceforge.net/xmlwrapp/?rev=205&view=rev
Author: tbrowder2
Date: 2012-03-20 14:10:29 +0000 (Tue, 20 Mar 2012)
Log Message:
-----------
rename for clarity
Added Paths:
-----------
trunk/src/libxmlwrappstring/
trunk/src/libxmlwrappstring/xmlwrappstring.cc
trunk/src/libxmlwrappstring/xmlwrappstring.h
Removed Paths:
-------------
trunk/src/libustring/xmlwrappstring.cc
trunk/src/libustring/xmlwrappstring.h
trunk/src/libxmlwrappstring/ustring.cc
trunk/src/libxmlwrappstring/ustring.h
Deleted: trunk/src/libustring/xmlwrappstring.cc
===================================================================
--- trunk/src/libustring/xmlwrappstring.cc 2012-03-20 14:05:34 UTC (rev 204)
+++ trunk/src/libustring/xmlwrappstring.cc 2012-03-20 14:10:29 UTC (rev 205)
@@ -1,1418 +0,0 @@
-// -*- c++ -*-
-/* $Id$ */
-
-/* Copyright (C) 2002 The gtkmm Development Team
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free
- * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#include <glibmmconfig.h>
-#include <glibmm/ustring.h>
-#include <glibmm/convert.h>
-#include <glibmm/error.h>
-#include <glibmm/utility.h>
-
-#include <algorithm>
-#include <iostream>
-#include <cstring>
-# include <stdexcept>
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-namespace
-{
-
-using Glib::ustring;
-
-// Little helper to make the conversion from gunichar to UTF-8 a one-liner.
-//
-struct UnicharToUtf8
-{
- char buf[6];
- ustring::size_type len;
-
- explicit UnicharToUtf8(gunichar uc)
- : len (g_unichar_to_utf8(uc, buf)) {}
-};
-
-
-// All utf8_*_offset() functions return npos if offset is out of range.
-// The caller should decide if npos is a valid argument and just marks
-// the whole string, or if it is not allowed (e.g. for start positions).
-// In the latter case std::out_of_range should be thrown, but usually
-// std::string will do that for us.
-
-// First overload: stop on '\0' character.
-static
-ustring::size_type utf8_byte_offset(const char* str, ustring::size_type offset)
-{
- if(offset == ustring::npos)
- return ustring::npos;
-
- const char *const utf8_skip = g_utf8_skip;
- const char* p = str;
-
- for(; offset != 0; --offset)
- {
- const unsigned int c = static_cast<unsigned char>(*p);
-
- if(c == 0)
- return ustring::npos;
-
- p += utf8_skip[c];
- }
-
- return (p - str);
-}
-
-// Second overload: stop when reaching maxlen.
-static
-ustring::size_type utf8_byte_offset(const char* str, ustring::size_type offset,
- ustring::size_type maxlen)
-{
- if(offset == ustring::npos)
- return ustring::npos;
-
- const char *const utf8_skip = g_utf8_skip;
- const char *const pend = str + maxlen;
- const char* p = str;
-
- for(; offset != 0; --offset)
- {
- if(p >= pend)
- return ustring::npos;
-
- p += utf8_skip[static_cast<unsigned char>(*p)];
- }
-
- return (p - str);
-}
-
-// Third overload: stop when reaching str.size().
-//
-inline
-ustring::size_type utf8_byte_offset(const std::string& str, ustring::size_type offset)
-{
- return utf8_byte_offset(str.data(), offset, str.size());
-}
-
-// Takes UTF-8 character offset and count in ci and cn.
-// Returns the byte offset and count in i and n.
-//
-struct Utf8SubstrBounds
-{
- ustring::size_type i;
- ustring::size_type n;
-
- Utf8SubstrBounds(const std::string& str, ustring::size_type ci, ustring::size_type cn)
- :
- i (utf8_byte_offset(str, ci)),
- n (ustring::npos)
- {
- if(i != ustring::npos)
- n = utf8_byte_offset(str.data() + i, cn, str.size() - i);
- }
-};
-
-// Converts byte offset to UTF-8 character offset.
-inline
-ustring::size_type utf8_char_offset(const std::string& str, ustring::size_type offset)
-{
- if(offset == ustring::npos)
- return ustring::npos;
-
- const char *const pdata = str.data();
- return g_utf8_pointer_to_offset(pdata, pdata + offset);
-}
-
-
-// Helper to implement ustring::find_first_of() and find_first_not_of().
-// Returns the UTF-8 character offset, or ustring::npos if not found.
-static
-ustring::size_type utf8_find_first_of(const std::string& str, ustring::size_type offset,
- const char* utf8_match, long utf8_match_size,
- bool find_not_of)
-{
- const ustring::size_type byte_offset = utf8_byte_offset(str, offset);
- if(byte_offset == ustring::npos)
- return ustring::npos;
-
- long ucs4_match_size = 0;
- const Glib::ScopedPtr<gunichar> ucs4_match
- (g_utf8_to_ucs4_fast(utf8_match, utf8_match_size, &ucs4_match_size));
-
- const gunichar *const match_begin = ucs4_match.get();
- const gunichar *const match_end = match_begin + ucs4_match_size;
-
- const char *const str_begin = str.data();
- const char *const str_end = str_begin + str.size();
-
- for(const char* pstr = str_begin + byte_offset;
- pstr < str_end;
- pstr = g_utf8_next_char(pstr))
- {
- const gunichar *const pfound = std::find(match_begin, match_end, g_utf8_get_char(pstr));
-
- if((pfound != match_end) != find_not_of)
- return offset;
-
- ++offset;
- }
-
- return ustring::npos;
-}
-
-// Helper to implement ustring::find_last_of() and find_last_not_of().
-// Returns the UTF-8 character offset, or ustring::npos if not found.
-static
-ustring::size_type utf8_find_last_of(const std::string& str, ustring::size_type offset,
- const char* utf8_match, long utf8_match_size,
- bool find_not_of)
-{
- long ucs4_match_size = 0;
- const Glib::ScopedPtr<gunichar> ucs4_match
- (g_utf8_to_ucs4_fast(utf8_match, utf8_match_size, &ucs4_match_size));
-
- const gunichar *const match_begin = ucs4_match.get();
- const gunichar *const match_end = match_begin + ucs4_match_size;
-
- const char *const str_begin = str.data();
- const char* pstr = str_begin;
-
- // Set pstr one byte beyond the actual start position.
- const ustring::size_type byte_offset = utf8_byte_offset(str, offset);
- pstr += (byte_offset < str.size()) ? byte_offset + 1 : str.size();
-
- while(pstr > str_begin)
- {
- // Move to previous character.
- do
- --pstr;
- while((static_cast<unsigned char>(*pstr) & 0xC0u) == 0x80);
-
- const gunichar *const pfound = std::find(match_begin, match_end, g_utf8_get_char(pstr));
-
- if((pfound != match_end) != find_not_of)
- return g_utf8_pointer_to_offset(str_begin, pstr);
- }
-
- return ustring::npos;
-}
-
-} // anonymous namespace
-
-
-namespace Glib
-{
-
-#ifndef GLIBMM_HAVE_ALLOWS_STATIC_INLINE_NPOS
-// Initialize static member here,
-// because the compiler did not allow us do it inline.
-const ustring::size_type ustring::npos = std::string::npos;
-#endif
-
-/*
- * We need our own version of g_utf8_get_char(), because the std::string
- * iterator is not necessarily a plain pointer (it's in fact not in GCC's
- * libstdc++-v3). Copying the UTF-8 data into a temporary buffer isn't an
- * option since this operation is quite time critical. The implementation
- * is quite different from g_utf8_get_char() -- both more generic and likely
- * faster.
- *
- * By looking at the first byte of a UTF-8 character one can determine the
- * number of bytes used. GLib offers the g_utf8_skip[] array for this purpose,
- * but accessing this global variable would, on IA32 at least, introduce
- * a function call to fetch the Global Offset Table, plus two levels of
- * indirection in order to read the value. Even worse, fetching the GOT is
- * always done right at the start of the function instead of the branch that
- * actually uses the variable.
- *
- * Fortunately, there's a better way to get the byte count. As this table
- * shows, there's a nice regular pattern in the UTF-8 encoding scheme:
- *
- * 0x00000000 - 0x0000007F: 0xxxxxxx
- * 0x00000080 - 0x000007FF: 110xxxxx 10xxxxxx
- * 0x00000800 - 0x0000FFFF: 1110xxxx 10xxxxxx 10xxxxxx
- * 0x00010000 - 0x001FFFFF: 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
- * 0x00200000 - 0x03FFFFFF: 111110xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
- * 0x04000000 - 0x7FFFFFFF: 1111110x 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
- *
- * Except for the single byte case, the number of leading 1-bits equals the
- * byte count. All that is needed is to shift the first byte to the left
- * until bit 7 becomes 0. Naturally, doing so requires a loop -- but since
- * we already have one, no additional cost is introduced. This shifting can
- * further be combined with the computation of the bitmask needed to eliminate
- * the leading length bits, thus saving yet another register.
- *
- * Note: If you change this code, it is advisable to also review what the
- * compiler makes of it in the assembler output. Except for some pointless
- * register moves, the generated code is sufficiently close to the optimum
- * with GCC 4.1.2 on x86_64.
- */
-gunichar get_unichar_from_std_iterator(std::string::const_iterator pos)
-{
- unsigned int result = static_cast<unsigned char>(*pos);
-
- if((result & 0x80) != 0)
- {
- unsigned int mask = 0x40;
-
- do
- {
- result <<= 6;
- const unsigned int c = static_cast<unsigned char>(*++pos);
- mask <<= 5;
- result += c - 0x80;
- }
- while((result & mask) != 0);
-
- result &= mask - 1;
- }
-
- return result;
-}
-
-
-/**** Glib::ustring ********************************************************/
-
-ustring::ustring()
-:
- string_ ()
-{}
-
-ustring::ustring(const ustring& other)
-:
- string_ (other.string_)
-{}
-
-ustring::ustring(const ustring& src, ustring::size_type i, ustring::size_type n)
-:
- string_ ()
-{
- const Utf8SubstrBounds bounds (src.string_, i, n);
- string_.assign(src.string_, bounds.i, bounds.n);
-}
-
-ustring::ustring(const char* src, ustring::size_type n)
-:
- string_ (src, utf8_byte_offset(src, n))
-{}
-
-ustring::ustring(const char* src)
-:
- string_ (src)
-{}
-
-ustring::ustring(ustring::size_type n, gunichar uc)
-:
- string_ ()
-{
- if(uc < 0x80)
- {
- // Optimize the probably most common case.
- string_.assign(n, static_cast<char>(uc));
- }
- else
- {
- const UnicharToUtf8 conv (uc);
- string_.reserve(n * conv.len);
-
- for(; n > 0; --n)
- string_.append(conv.buf, conv.len);
- }
-}
-
-ustring::ustring(ustring::size_type n, char c)
-:
- string_ (n, c)
-{}
-
-ustring::ustring(const std::string& src)
-:
- string_ (src)
-{}
-
-ustring::~ustring()
-{}
-
-void ustring::swap(ustring& other)
-{
- string_.swap(other.string_);
-}
-
-
-/**** Glib::ustring::operator=() *******************************************/
-
-ustring& ustring::operator=(const ustring& other)
-{
- string_ = other.string_;
- return *this;
-}
-
-ustring& ustring::operator=(const std::string& src)
-{
- string_ = src;
- return *this;
-}
-
-ustring& ustring::operator=(const char* src)
-{
- string_ = src;
- return *this;
-}
-
-ustring& ustring::operator=(gunichar uc)
-{
- const UnicharToUtf8 conv (uc);
- string_.assign(conv.buf, conv.len);
- return *this;
-}
-
-ustring& ustring::operator=(char c)
-{
- string_ = c;
- return *this;
-}
-
-
-/**** Glib::ustring::assign() **********************************************/
-
-ustring& ustring::assign(const ustring& src)
-{
- string_ = src.string_;
- return *this;
-}
-
-ustring& ustring::assign(const ustring& src, ustring::size_type i, ustring::size_type n)
-{
- const Utf8SubstrBounds bounds (src.string_, i, n);
- string_.assign(src.string_, bounds.i, bounds.n);
- return *this;
-}
-
-ustring& ustring::assign(const char* src, ustring::size_type n)
-{
- string_.assign(src, utf8_byte_offset(src, n));
- return *this;
-}
-
-ustring& ustring::assign(const char* src)
-{
- string_ = src;
- return *this;
-}
-
-ustring& ustring::assign(ustring::size_type n, gunichar uc)
-{
- ustring temp (n, uc);
- string_.swap(temp.string_);
- return *this;
-}
-
-ustring& ustring::assign(ustring::size_type n, char c)
-{
- string_.assign(n, c);
- return *this;
-}
-
-
-/**** Glib::ustring::operator+=() ******************************************/
-
-ustring& ustring::operator+=(const ustring& src)
-{
- string_ += src.string_;
- return *this;
-}
-
-ustring& ustring::operator+=(const char* src)
-{
- string_ += src;
- return *this;
-}
-
-ustring& ustring::operator+=(gunichar uc)
-{
- const UnicharToUtf8 conv (uc);
- string_.append(conv.buf, conv.len);
- return *this;
-}
-
-ustring& ustring::operator+=(char c)
-{
- string_ += c;
- return *this;
-}
-
-
-/**** Glib::ustring::push_back() *******************************************/
-
-void ustring::push_back(gunichar uc)
-{
- const UnicharToUtf8 conv (uc);
- string_.append(conv.buf, conv.len);
-}
-
-void ustring::push_back(char c)
-{
- string_ += c;
-}
-
-
-/**** Glib::ustring::append() **********************************************/
-
-ustring& ustring::append(const ustring& src)
-{
- string_ += src.string_;
- return *this;
-}
-
-ustring& ustring::append(const ustring& src, ustring::size_type i, ustring::size_type n)
-{
- const Utf8SubstrBounds bounds (src.string_, i, n);
- string_.append(src.string_, bounds.i, bounds.n);
- return *this;
-}
-
-ustring& ustring::append(const char* src, ustring::size_type n)
-{
- string_.append(src, utf8_byte_offset(src, n));
- return *this;
-}
-
-ustring& ustring::append(const char* src)
-{
- string_ += src;
- return *this;
-}
-
-ustring& ustring::append(ustring::size_type n, gunichar uc)
-{
- string_.append(ustring(n, uc).string_);
- return *this;
-}
-
-ustring& ustring::append(ustring::size_type n, char c)
-{
- string_.append(n, c);
- return *this;
-}
-
-
-/**** Glib::ustring::insert() **********************************************/
-
-ustring& ustring::insert(ustring::size_type i, const ustring& src)
-{
- string_.insert(utf8_byte_offset(string_, i), src.string_);
- return *this;
-}
-
-ustring& ustring::insert(ustring::size_type i, const ustring& src,
- ustring::size_type i2, ustring::size_type n)
-{
- const Utf8SubstrBounds bounds2 (src.string_, i2, n);
- string_.insert(utf8_byte_offset(string_, i), src.string_, bounds2.i, bounds2.n);
- return *this;
-}
-
-ustring& ustring::insert(ustring::size_type i, const char* src, ustring::size_type n)
-{
- string_.insert(utf8_byte_offset(string_, i), src, utf8_byte_offset(src, n));
- return *this;
-}
-
-ustring& ustring::insert(ustring::size_type i, const char* src)
-{
- string_.insert(utf8_byte_offset(string_, i), src);
- return *this;
-}
-
-ustring& ustring::insert(ustring::size_type i, ustring::size_type n, gunichar uc)
-{
- string_.insert(utf8_byte_offset(string_, i), ustring(n, uc).string_);
- return *this;
-}
-
-ustring& ustring::insert(ustring::size_type i, ustring::size_type n, char c)
-{
- string_.insert(utf8_byte_offset(string_, i), n, c);
- return *this;
-}
-
-ustring::iterator ustring::insert(ustring::iterator p, gunichar uc)
-{
- const size_type offset = p.base() - string_.begin();
- const UnicharToUtf8 conv (uc);
- string_.insert(offset, conv.buf, conv.len);
- return iterator(string_.begin() + offset);
-}
-
-ustring::iterator ustring::insert(ustring::iterator p, char c)
-{
- return iterator(string_.insert(p.base(), c));
-}
-
-void ustring::insert(ustring::iterator p, ustring::size_type n, gunichar uc)
-{
- string_.insert(p.base() - string_.begin(), ustring(n, uc).string_);
-}
-
-void ustring::insert(ustring::iterator p, ustring::size_type n, char c)
-{
- string_.insert(p.base(), n, c);
-}
-
-
-/**** Glib::ustring::replace() *********************************************/
-
-ustring& ustring::replace(ustring::size_type i, ustring::size_type n, const ustring& src)
-{
- const Utf8SubstrBounds bounds (string_, i, n);
- string_.replace(bounds.i, bounds.n, src.string_);
- return *this;
-}
-
-ustring& ustring::replace(ustring::size_type i, ustring::size_type n,
- const ustring& src, ustring::size_type i2, ustring::size_type n2)
-{
- const Utf8SubstrBounds bounds (string_, i, n);
- const Utf8SubstrBounds bounds2 (src.string_, i2, n2);
- string_.replace(bounds.i, bounds.n, src.string_, bounds2.i, bounds2.n);
- return *this;
-}
-
-ustring& ustring::replace(ustring::size_type i, ustring::size_type n,
- const char* src, ustring::size_type n2)
-{
- const Utf8SubstrBounds bounds (string_, i, n);
- string_.replace(bounds.i, bounds.n, src, utf8_byte_offset(src, n2));
- return *this;
-}
-
-ustring& ustring::replace(ustring::size_type i, ustring::size_type n, const char* src)
-{
- const Utf8SubstrBounds bounds (string_, i, n);
- string_.replace(bounds.i, bounds.n, src);
- return *this;
-}
-
-ustring& ustring::replace(ustring::size_type i, ustring::size_type n,
- ustring::size_type n2, gunichar uc)
-{
- const Utf8SubstrBounds bounds (string_, i, n);
- string_.replace(bounds.i, bounds.n, ustring(n2, uc).string_);
- return *this;
-}
-
-ustring& ustring::replace(ustring::size_type i, ustring::size_type n,
- ustring::size_type n2, char c)
-{
- const Utf8SubstrBounds bounds (string_, i, n);
- string_.replace(bounds.i, bounds.n, n2, c);
- return *this;
-}
-
-ustring& ustring::replace(ustring::iterator pbegin, ustring::iterator pend, const ustring& src)
-{
- string_.replace(pbegin.base(), pend.base(), src.string_);
- return *this;
-}
-
-ustring& ustring::replace(ustring::iterator pbegin, ustring::iterator pend,
- const char* src, ustring::size_type n)
-{
- string_.replace(pbegin.base(), pend.base(), src, utf8_byte_offset(src, n));
- return *this;
-}
-
-ustring& ustring::replace(ustring::iterator pbegin, ustring::iterator pend, const char* src)
-{
- string_.replace(pbegin.base(), pend.base(), src);
- return *this;
-}
-
-ustring& ustring::replace(ustring::iterator pbegin, ustring::iterator pend,
- ustring::size_type n, gunichar uc)
-{
- string_.replace(pbegin.base(), pend.base(), ustring(n, uc).string_);
- return *this;
-}
-
-ustring& ustring::replace(ustring::iterator pbegin, ustring::iterator pend,
- ustring::size_type n, char c)
-{
- string_.replace(pbegin.base(), pend.base(), n, c);
- return *this;
-}
-
-
-/**** Glib::ustring::erase() ***********************************************/
-
-void ustring::clear()
-{
- string_.erase();
-}
-
-ustring& ustring::erase(ustring::size_type i, ustring::size_type n)
-{
- const Utf8SubstrBounds bounds (string_, i, n);
- string_.erase(bounds.i, bounds.n);
- return *this;
-}
-
-ustring& ustring::erase()
-{
- string_.erase();
- return *this;
-}
-
-ustring::iterator ustring::erase(ustring::iterator p)
-{
- ustring::iterator iter_end = p;
- ++iter_end;
-
- return iterator(string_.erase(p.base(), iter_end.base()));
-}
-
-ustring::iterator ustring::erase(ustring::iterator pbegin, ustring::iterator pend)
-{
- return iterator(string_.erase(pbegin.base(), pend.base()));
-}
-
-
-/**** Glib::ustring::compare() *********************************************/
-
-int ustring::compare(const ustring& rhs) const
-{
- return g_utf8_collate(string_.c_str(), rhs.string_.c_str());
-}
-
-int ustring::compare(const char* rhs) const
-{
- return g_utf8_collate(string_.c_str(), rhs);
-}
-
-int ustring::compare(ustring::size_type i, ustring::size_type n, const ustring& rhs) const
-{
- return ustring(*this, i, n).compare(rhs);
-}
-
-int ustring::compare(ustring::size_type i, ustring::size_type n,
- const ustring& rhs, ustring::size_type i2, ustring::size_type n2) const
-{
- return ustring(*this, i, n).compare(ustring(rhs, i2, n2));
-}
-
-int ustring::compare(ustring::size_type i, ustring::size_type n,
- const char* rhs, ustring::size_type n2) const
-{
- return ustring(*this, i, n).compare(ustring(rhs, n2));
-}
-
-int ustring::compare(ustring::size_type i, ustring::size_type n, const char* rhs) const
-{
- return ustring(*this, i, n).compare(rhs);
-}
-
-
-/**** Glib::ustring -- index access ****************************************/
-
-ustring::value_type ustring::operator[](ustring::size_type i) const
-{
- return g_utf8_get_char(g_utf8_offset_to_pointer(string_.data(), i));
-}
-
-ustring::value_type ustring::at(ustring::size_type i) const
-{
- const size_type byte_offset = utf8_byte_offset(string_, i);
-
- // Throws std::out_of_range if the index is invalid.
- return g_utf8_get_char(&string_.at(byte_offset));
-}
-
-
-/**** Glib::ustring -- iterator access *************************************/
-
-ustring::iterator ustring::begin()
-{
- return iterator(string_.begin());
-}
-
-ustring::iterator ustring::end()
-{
- return iterator(string_.end());
-}
-
-ustring::const_iterator ustring::begin() const
-{
- return const_iterator(string_.begin());
-}
-
-ustring::const_iterator ustring::end() const
-{
- return const_iterator(string_.end());
-}
-
-ustring::reverse_iterator ustring::rbegin()
-{
- return reverse_iterator(iterator(string_.end()));
-}
-
-ustring::reverse_iterator ustring::rend()
-{
- return reverse_iterator(iterator(string_.begin()));
-}
-
-ustring::const_reverse_iterator ustring::rbegin() const
-{
- return const_reverse_iterator(const_iterator(string_.end()));
-}
-
-ustring::const_reverse_iterator ustring::rend() const
-{
- return const_reverse_iterator(const_iterator(string_.begin()));
-}
-
-
-/**** Glib::ustring::find() ************************************************/
-
-ustring::size_type ustring::find(const ustring& str, ustring::size_type i) const
-{
- return utf8_char_offset(string_, string_.find(str.string_, utf8_byte_offset(string_, i)));
-}
-
-ustring::size_type ustring::find(const char* str, ustring::size_type i, ustring::size_type n) const
-{
- return utf8_char_offset(string_, string_.find(str, utf8_byte_offset(string_, i),
- utf8_byte_offset(str, n)));
-}
-
-ustring::size_type ustring::find(const char* str, ustring::size_type i) const
-{
- return utf8_char_offset(string_, string_.find(str, utf8_byte_offset(string_, i)));
-}
-
-ustring::size_type ustring::find(gunichar uc, ustring::size_type i) const
-{
- const UnicharToUtf8 conv (uc);
- return utf8_char_offset(string_, string_.find(conv.buf, utf8_byte_offset(string_, i), conv.len));
-}
-
-ustring::size_type ustring::find(char c, ustring::size_type i) const
-{
- return utf8_char_offset(string_, string_.find(c, utf8_byte_offset(string_, i)));
-}
-
-
-/**** Glib::ustring::rfind() ***********************************************/
-
-ustring::size_type ustring::rfind(const ustring& str, ustring::size_type i) const
-{
- return utf8_char_offset(string_, string_.rfind(str.string_, utf8_byte_offset(string_, i)));
-}
-
-ustring::size_type ustring::rfind(const char* str, ustring::size_type i,
- ustring::size_type n) const
-{
- return utf8_char_offset(string_, string_.rfind(str, utf8_byte_offset(string_, i),
- utf8_byte_offset(str, n)));
-}
-
-ustring::size_type ustring::rfind(const char* str, ustring::size_type i) const
-{
- return utf8_char_offset(string_, string_.rfind(str, utf8_byte_offset(string_, i)));
-}
-
-ustring::size_type ustring::rfind(gunichar uc, ustring::size_type i) const
-{
- const UnicharToUtf8 conv (uc);
- return utf8_char_offset(string_, string_.rfind(conv.buf, utf8_byte_offset(string_, i), conv.len));
-}
-
-ustring::size_type ustring::rfind(char c, ustring::size_type i) const
-{
- return utf8_char_offset(string_, string_.rfind(c, utf8_byte_offset(string_, i)));
-}
-
-
-/**** Glib::ustring::find_first_of() ***************************************/
-
-ustring::size_type ustring::find_first_of(const ustring& match, ustring::size_type i) const
-{
- return utf8_find_first_of(string_, i, match.string_.data(), match.string_.size(), false);
-}
-
-ustring::size_type ustring::find_first_of(const char* match,
- ustring::size_type i, ustring::size_type n) const
-{
- return utf8_find_first_of(string_, i, match, n, false);
-}
-
-ustring::size_type ustring::find_first_of(const char* match, ustring::size_type i) const
-{
- return utf8_find_first_of(string_, i, match, -1, false);
-}
-
-ustring::size_type ustring::find_first_of(gunichar uc, ustring::size_type i) const
-{
- return find(uc, i);
-}
-
-ustring::size_type ustring::find_first_of(char c, ustring::size_type i) const
-{
- return find(c, i);
-}
-
-
-/**** Glib::ustring::find_last_of() ****************************************/
-
-ustring::size_type ustring::find_last_of(const ustring& match, ustring::size_type i) const
-{
- return utf8_find_last_of(string_, i, match.string_.data(), match.string_.size(), false);
-}
-
-ustring::size_type ustring::find_last_of(const char* match,
- ustring::size_type i, ustring::size_type n) const
-{
- return utf8_find_last_of(string_, i, match, n, false);
-}
-
-ustring::size_type ustring::find_last_of(const char* match, ustring::size_type i) const
-{
- return utf8_find_last_of(string_, i, match, -1, false);
-}
-
-ustring::size_type ustring::find_last_of(gunichar uc, ustring::size_type i) const
-{
- return rfind(uc, i);
-}
-
-ustring::size_type ustring::find_last_of(char c, ustring::size_type i) const
-{
- return rfind(c, i);
-}
-
-
-/**** Glib::ustring::find_first_not_of() ***********************************/
-
-ustring::size_type ustring::find_first_not_of(const ustring& match, ustring::size_type i) const
-{
- return utf8_find_first_of(string_, i, match.string_.data(), match.string_.size(), true);
-}
-
-ustring::size_type ustring::find_first_not_of(const char* match,
- ustring::size_type i, ustring::size_type n) const
-{
- return utf8_find_first_of(string_, i, match, n, true);
-}
-
-ustring::size_type ustring::find_first_not_of(const char* match, ustring::size_type i) const
-{
- return utf8_find_first_of(string_, i, match, -1, true);
-}
-
-// Unfortunately, all of the find_*_not_of() methods for single
-// characters need their own special implementation.
-//
-ustring::size_type ustring::find_first_not_of(gunichar uc, ustring::size_type i) const
-{
- const size_type bi = utf8_byte_offset(string_, i);
- if(bi != npos)
- {
- const char *const pbegin = string_.data();
- const char *const pend = pbegin + string_.size();
-
- for(const char* p = pbegin + bi;
- p < pend;
- p = g_utf8_next_char(p), ++i)
- {
- if(g_utf8_get_char(p) != uc)
- return i;
- }
- }
- return npos;
-}
-
-ustring::size_type ustring::find_first_not_of(char c, ustring::size_type i) const
-{
- const size_type bi = utf8_byte_offset(string_, i);
- if(bi != npos)
- {
- const char *const pbegin = string_.data();
- const char *const pend = pbegin + string_.size();
-
- for(const char* p = pbegin + bi;
- p < pend;
- p = g_utf8_next_char(p), ++i)
- {
- if(*p != c)
- return i;
- }
- }
- return npos;
-}
-
-
-/**** Glib::ustring::find_last_not_of() ************************************/
-
-ustring::size_type ustring::find_last_not_of(const ustring& match, ustring::size_type i) const
-{
- return utf8_find_last_of(string_, i, match.string_.data(), match.string_.size(), true);
-}
-
-ustring::size_type ustring::find_last_not_of(const char* match,
- ustring::size_type i, ustring::size_type n) const
-{
- return utf8_find_last_of(string_, i, match, n, true);
-}
-
-ustring::size_type ustring::find_last_not_of(const char* match, ustring::size_type i) const
-{
- return utf8_find_last_of(string_, i, match, -1, true);
-}
-
-// Unfortunately, all of the find_*_not_of() methods for single
-// characters need their own special implementation.
-//
-ustring::size_type ustring::find_last_not_of(gunichar uc, ustring::size_type i) const
-{
- const char *const pbegin = string_.data();
- const char *const pend = pbegin + string_.size();
- size_type i_cur = 0;
- size_type i_found = npos;
-
- for(const char* p = pbegin;
- p < pend && i_cur <= i;
- p = g_utf8_next_char(p), ++i_cur)
- {
- if(g_utf8_get_char(p) != uc)
- i_found = i_cur;
- }
- return i_found;
-}
-
-ustring::size_type ustring::find_last_not_of(char c, ustring::size_type i) const
-{
- const char *const pbegin = string_.data();
- const char *const pend = pbegin + string_.size();
- size_type i_cur = 0;
- size_type i_found = npos;
-
- for(const char* p = pbegin;
- p < pend && i_cur <= i;
- p = g_utf8_next_char(p), ++i_cur)
- {
- if(*p != c)
- i_found = i_cur;
- }
- return i_found;
-}
-
-
-/**** Glib::ustring -- get size and resize *********************************/
-
-bool ustring::empty() const
-{
- return string_.empty();
-}
-
-ustring::size_type ustring::size() const
-{
- const char *const pdata = string_.data();
- return g_utf8_pointer_to_offset(pdata, pdata + string_.size());
-}
-
-ustring::size_type ustring::length() const
-{
- const char *const pdata = string_.data();
- return g_utf8_pointer_to_offset(pdata, pdata + string_.size());
-}
-
-ustring::size_type ustring::bytes() const
-{
- return string_.size();
-}
-
-ustring::size_type ustring::capacity() const
-{
- return string_.capacity();
-}
-
-ustring::size_type ustring::max_size() const
-{
- return string_.max_size();
-}
-
-void ustring::resize(ustring::size_type n, gunichar uc)
-{
- const size_type size_now = size();
- if(n < size_now)
- erase(n, npos);
- else if(n > size_now)
- append(n - size_now, uc);
-}
-
-void ustring::resize(ustring::size_type n, char c)
-{
- const size_type size_now = size();
- if(n < size_now)
- erase(n, npos);
- else if(n > size_now)
- string_.append(n - size_now, c);
-}
-
-void ustring::reserve(ustring::size_type n)
-{
- string_.reserve(n);
-}
-
-
-/**** Glib::ustring -- C string access *************************************/
-
-const char* ustring::data() const
-{
- return string_.data();
-}
-
-const char* ustring::c_str() const
-{
- return string_.c_str();
-}
-
-// Note that copy() requests UTF-8 character offsets as
-// parameters, but returns the number of copied bytes.
-//
-ustring::size_type ustring::copy(char* dest, ustring::size_type n, ustring::size_type i) const
-{
- const Utf8SubstrBounds bounds (string_, i, n);
- return string_.copy(dest, bounds.n, bounds.i);
-}
-
-
-/**** Glib::ustring -- UTF-8 utilities *************************************/
-
-bool ustring::validate() const
-{
- return (g_utf8_validate(string_.data(), string_.size(), 0) != 0);
-}
-
-bool ustring::validate(ustring::iterator& first_invalid)
-{
- const char *const pdata = string_.data();
- const char* valid_end = pdata;
- const int is_valid = g_utf8_validate(pdata, string_.size(), &valid_end);
-
- first_invalid = iterator(string_.begin() + (valid_end - pdata));
- return (is_valid != 0);
-}
-
-bool ustring::validate(ustring::const_iterator& first_invalid) const
-{
- const char *const pdata = string_.data();
- const char* valid_end = pdata;
- const int is_valid = g_utf8_validate(pdata, string_.size(), &valid_end);
-
- first_invalid = const_iterator(string_.begin() + (valid_end - pdata));
- return (is_valid != 0);
-}
-
-bool ustring::is_ascii() const
-{
- const char* p = string_.data();
- const char *const pend = p + string_.size();
-
- for(; p != pend; ++p)
- {
- if((static_cast<unsigned char>(*p) & 0x80u) != 0)
- return false;
- }
-
- return true;
-}
-
-ustring ustring::normalize(NormalizeMode mode) const
-{
- const ScopedPtr<char> buf (g_utf8_normalize(string_.data(), string_.size(),
- static_cast<GNormalizeMode>(int(mode))));
- return ustring(buf.get());
-}
-
-ustring ustring::uppercase() const
-{
- const ScopedPtr<char> buf (g_utf8_strup(string_.data(), string_.size()));
- return ustring(buf.get());
-}
-
-ustring ustring::lowercase() const
-{
- const ScopedPtr<char> buf (g_utf8_strdown(string_.data(), string_.size()));
- return ustring(buf.get());
-}
-
-ustring ustring::casefold() const
-{
- const ScopedPtr<char> buf (g_utf8_casefold(string_.data(), string_.size()));
- return ustring(buf.get());
-}
-
-std::string ustring::collate_key() const
-{
- const ScopedPtr<char> buf (g_utf8_collate_key(string_.data(), string_.size()));
- return std::string(buf.get());
-}
-
-std::string ustring::casefold_collate_key() const
-{
- char *const casefold_buf = g_utf8_casefold(string_.data(), string_.size());
- char *const key_buf = g_utf8_collate_key(casefold_buf, -1);
- g_free(casefold_buf);
- return std::string(ScopedPtr<char>(key_buf).get());
-}
-
-/**** Glib::ustring -- Message formatting **********************************/
-
-// static
-ustring ustring::compose_argv(const Glib::ustring& fmt, int argc, const ustring* const* argv)
-{
- std::string::size_type result_size = fmt.raw().size();
-
- // Guesstimate the final string size.
- for (int i = 0; i < argc; ++i)
- result_size += argv[i]->raw().size();
-
- std::string result;
- result.reserve(result_size);
-
- const char* const pfmt = fmt.raw().c_str();
- const char* start = pfmt;
-
- while (const char* const stop = std::strchr(start, '%'))
- {
- if (stop[1] == '%')
- {
- result.append(start, stop - start + 1);
- start = stop + 2;
- }
- else
- {
- const int index = Ascii::digit_value(stop[1]) - 1;
-
- if (index >= 0 && index < argc)
- {
- result.append(start, stop - start);
- result += argv[index]->raw();
- start = stop + 2;
- }
- else
- {
- const char* const next = (stop[1] != '\0') ? g_utf8_next_char(stop + 1) : (stop + 1);
-
- // Copy invalid substitutions literally to the output.
- result.append(start, next - start);
-
- g_warning("invalid substitution \"%s\" in fmt string \"%s\"",
- result.c_str() + result.size() - (next - stop), pfmt);
- start = next;
- }
- }
- }
-
- result.append(start, pfmt + fmt.raw().size() - start);
-
- return result;
-}
-
-/**** Glib::ustring::SequenceToString **************************************/
-
-ustring::SequenceToString<Glib::ustring::iterator,gunichar>
- ::SequenceToString(Glib::ustring::iterator pbegin, Glib::ustring::iterator pend)
-:
- std::string(pbegin.base(), pend.base())
-{}
-
-ustring::SequenceToString<Glib::ustring::const_iterator,gunichar>
- ::SequenceToString(Glib::ustring::const_iterator pbegin, Glib::ustring::const_iterator pend)
-:
- std::string(pbegin.base(), pend.base())
-{}
-
-/**** Glib::ustring::FormatStream ******************************************/
-
-ustring::FormatStream::FormatStream()
-:
- stream_ ()
-{}
-
-ustring::FormatStream::~FormatStream()
-{}
-
-ustring ustring::FormatStream::to_string() const
-{
- GError* error = 0;
-
-#ifdef GLIBMM_HAVE_WIDE_STREAM
- const std::wstring str = stream_.str();
-
-# if defined(__STDC_ISO_10646__) && SIZEOF_WCHAR_T == 4
- // Avoid going through iconv if wchar_t always contains UCS-4.
- glong n_bytes = 0;
- const ScopedPtr<char> buf (g_ucs4_to_utf8(reinterpret_cast<const gunichar*>(str.data()),
- str.size(), 0, &n_bytes, &error));
-# elif defined(G_OS_WIN32) && SIZEOF_WCHAR_T == 2
- // Avoid going through iconv if wchar_t always contains UTF-16.
- glong n_bytes = 0;
- const ScopedPtr<char> buf (g_utf16_to_utf8(reinterpret_cast<const gunichar2*>(str.data()),
- str.size(), 0, &n_bytes, &error));
-# else
- gsize n_bytes = 0;
- const ScopedPtr<char> buf (g_convert(reinterpret_cast<const char*>(str.data()),
- str.size() * sizeof(std::wstring::value_type),
- "UTF-8", "WCHAR_T", 0, &n_bytes, &error));
-# endif /* !(__STDC_ISO_10646__ || G_OS_WIN32) */
-
-#else /* !GLIBMM_HAVE_WIDE_STREAM */
- const std::string str = stream_.str();
-
- gsize n_bytes = 0;
- const ScopedPtr<char> buf (g_locale_to_utf8(str.data(), str.size(), 0, &n_bytes, &error));
-#endif /* !GLIBMM_HAVE_WIDE_STREAM */
-
- if (error)
- {
- Glib::Error::throw_exception(error);
- }
-
- return ustring(buf.get(), buf.get() + n_bytes);
-}
-
-/**** Glib::ustring -- stream I/O operators ********************************/
-
-std::istream& operator>>(std::istream& is, Glib::ustring& utf8_string)
-{
- std::string str;
- is >> str;
-
- GError* error = 0;
- gsize n_bytes = 0;
- const ScopedPtr<char> buf (g_locale_to_utf8(str.data(), str.size(), 0, &n_bytes, &error));
-
- if (error)
- {
- Glib::Error::throw_exception(error);
- }
-
- utf8_string.assign(buf.get(), buf.get() + n_bytes);
-
- return is;
-}
-
-std::ostream& operator<<(std::ostream& os, const Glib::ustring& utf8_string)
-{
- GError* error = 0;
- const ScopedPtr<char> buf (g_locale_from_utf8(utf8_string.raw().data(),
- utf8_string.raw().size(), 0, 0, &error));
- if (error)
- {
- Glib::Error::throw_exception(error);
- }
-
- // This won't work if the string contains NUL characters. Unfortunately,
- // std::ostream::write() ignores format flags, so we cannot use that.
- // The only option would be to create a temporary std::string. However,
- // even then GCC's libstdc++-v3 prints only the characters up to the first
- // NUL. Given this, there doesn't seem much of a point in allowing NUL in
- // formatted output. The semantics would be unclear anyway: what's the
- // screen width of a NUL?
- os << buf.get();
-
- return os;
-}
-
-#ifdef GLIBMM_HAVE_WIDE_STREAM
-
-std::wistream& operator>>(std::wistream& is, ustring& utf8_string)
-{
- GError* error = 0;
-
- std::wstring wstr;
- is >> wstr;
-
-#if defined(__STDC_ISO_10646__) && SIZEOF_WCHAR_T == 4
- // Avoid going through iconv if wchar_t always contains UCS-4.
- glong n_bytes = 0;
- const ScopedPtr<char> buf (g_ucs4_to_utf8(reinterpret_cast<const gunichar*>(wstr.data()),
- wstr.size(), 0, &n_bytes, &error));
-#elif defined(G_OS_WIN32) && SIZEOF_WCHAR_T == 2
- // Avoid going through iconv if wchar_t always contains UTF-16.
- glong n_bytes = 0;
- const ScopedPtr<char> buf (g_utf16_to_utf8(reinterpret_cast<const gunichar2*>(wstr.data()),
- wstr.size(), 0, &n_bytes, &error));
-#else
- gsize n_bytes = 0;
- const ScopedPtr<char> buf (g_convert(reinterpret_cast<const char*>(wstr.data()),
- wstr.size() * sizeof(std::wstring::value_type),
- "UTF-8", "WCHAR_T", 0, &n_bytes, &error));
-#endif // !(__STDC_ISO_10646__ || G_OS_WIN32)
-
- if (error)
- {
- Glib::Error::throw_exception(error);
- }
-
- utf8_string.assign(buf.get(), buf.get() + n_bytes);
-
- return is;
-}
-
-std::wostream& operator<<(std::wostream& os, const ustring& utf8_string)
-{
- GError* error = 0;
-
-#if defined(__STDC_ISO_10646__) && SIZEOF_WCHAR_T == 4
- // Avoid going through iconv if wchar_t always contains UCS-4.
- const ScopedPtr<gunichar> buf (g_utf8_to_ucs4(utf8_string.raw().data(),
- utf8_string.raw().size(), 0, 0, &error));
-#elif defined(G_OS_WIN32) && SIZEOF_WCHAR_T == 2
- // Avoid going through iconv if wchar_t always contains UTF-16.
- const ScopedPtr<gunichar2> buf (g_utf8_to_utf16(utf8_string.raw().data(),
- utf8_string.raw().size(), 0, 0, &error));
-#else
- // TODO: For some reason the conversion from UTF-8 to WCHAR_T doesn't work
- // with g_convert(), while iconv on the command line handles it just fine.
- // Maybe a bug in GLib?
- const ScopedPtr<char> buf (g_convert(utf8_string.raw().data(), utf8_string.raw().size(),
- "WCHAR_T", "UTF-8", 0, 0, &error));
-#endif // !(__STDC_ISO_10646__ || G_OS_WIN32)
-
- if (error)
- {
- Glib::Error::throw_exception(error);
- }
-
- // This won't work if the string contains NUL characters. Unfortunately,
- // std::wostream::write() ignores format flags, so we cannot use that.
- // The only option would be to create a temporary std::wstring. However,
- // even then GCC's libstdc++-v3 prints only the characters up to the first
- // NUL. Given this, there doesn't seem much of a point in allowing NUL in
- // formatted output. The semantics would be unclear anyway: what's the
- // screen width of a NUL?
- os << reinterpret_cast<wchar_t*>(buf.get());
-
- return os;
-}
-
-#endif /* GLIBMM_HAVE_WIDE_STREAM */
-
-} // namespace Glib
Deleted: trunk/src/libustring/xmlwrappstring.h
===================================================================
--- trunk/src/libustring/xmlwrappstring.h 2012-03-20 14:05:34 UTC (rev 204)
+++ trunk/src/libustring/xmlwrappstring.h 2012-03-20 14:10:29 UTC (rev 205)
@@ -1,1615 +0,0 @@
-// -*- c++ -*-
-#ifndef _GLIBMM_USTRING_H
-#define _GLIBMM_USTRING_H
-
-/* $Id$ */
-
-/* Copyright (C) 2002 The gtkmm Development Team
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free
- * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#include <glibmmconfig.h>
-#include <glibmm/unicode.h>
-#include <glib.h>
-
-#include <iosfwd>
-#include <iterator>
-#include <sstream>
-#include <string>
-#ifndef GLIBMM_HAVE_STD_ITERATOR_TRAITS
-#include <cstddef> /* for ptrdiff_t */
-#endif
-
-namespace Glib
-{
-
-#ifndef DOXYGEN_SHOULD_SKIP_THIS
-#ifndef GLIBMM_HAVE_STD_ITERATOR_TRAITS
-
-template <class T>
-struct IteratorTraits
-{
- typedef typename T::iterator_category iterator_category;
- typedef typename T::value_type value_type;
- typedef typename T::difference_type difference_type;
- typedef typename T::pointer pointer;
- typedef typename T::reference reference;
-};
-
-template <class T>
-struct IteratorTraits<T*>
-{
- typedef std::random_access_iterator_tag iterator_category;
- typedef T value_type;
- typedef ptrdiff_t difference_type;
- typedef T* pointer;
- typedef T& reference;
-};
-
-template <class T>
-struct IteratorTraits<const T*>
-{
- typedef std::random_access_iterator_tag iterator_category;
- typedef T value_type;
- typedef ptrdiff_t difference_type;
- typedef const T* pointer;
- typedef const T& reference;
-};
-
-#endif /* GLIBMM_HAVE_STD_ITERATOR_TRAITS */
-#endif /* DOXYGEN_SHOULD_SKIP_THIS */
-
-
-/** The iterator type of Glib::ustring.
- * Note this is not a random access iterator but a bidirectional one,
- * since all index operations need to iterate over the UTF-8 data. Use
- * std::advance() to move to a certain position. However, all of the
- * relational operators are available:
- * <tt>== != < > <= >=</tt>
- *
- * A writeable iterator isn't provided because: The number of bytes of
- * the old UTF-8 character and the new one to write could be different.
- * Therefore, any write operation would invalidate all other iterators
- * pointing into the same string.
- */
-template <class T>
-class ustring_Iterator
-{
-public:
- typedef std::bidirectional_iterator_tag iterator_category;
- typedef gunichar value_type;
- typedef std::string::difference_type difference_type;
- typedef value_type reference;
- typedef void pointer;
-
- inline ustring_Iterator();
- inline ustring_Iterator(const ustring_Iterator<std::string::iterator>& other);
-
- inline value_type operator*() const;
-
- inline ustring_Iterator<T> & operator++();
- inline const ustring_Iterator<T> operator++(int);
- inline ustring_Iterator<T> & operator--();
- inline const ustring_Iterator<T> operator--(int);
-
- explicit inline ustring_Iterator(T pos);
- inline T base() const;
-
-private:
- T pos_;
-};
-
-
-/** Extract a UCS-4 character from UTF-8 data.
- * Convert a single UTF-8 (multibyte) character starting at @p pos to
- * a UCS-4 wide character. This may read up to 6 bytes after the start
- * position, depending on the UTF-8 character width. You have to make
- * sure the source contains at least one valid UTF-8 character.
- *
- * This is mainly used by the implementation of Glib::ustring::iterator,
- * but it might be useful as utility function if you prefer using
- * std::string even for UTF-8 encoding.
- */
-gunichar get_unichar_from_std_iterator(std::string::const_iterator pos) G_GNUC_PURE;
-
-
-/** Glib::ustring has much the same interface as std::string, but contains
- * %Unicode characters encoded as UTF-8.
- *
- * @par About UTF-8 and ASCII
- * @par
- * The standard character set ANSI_X3.4-1968 -- more commonly known as
- * ASCII -- is a subset of UTF-8. So, if you want to, you can use
- * Glib::ustring without even thinking about UTF-8.
- * @par
- * Whenever ASCII is mentioned in this manual, we mean the @em real ASCII
- * (i.e. as defined in ANSI_X3.4-1968), which contains only 7-bit characters.
- * Glib::ustring can @em not be used with ASCII-compatible extended 8-bit
- * charsets like ISO-8859-1. It's a good idea to avoid string literals
- * containing non-ASCII characters (e.g. German umlauts) in source code,
- * or at least you should use UTF-8 literals.
- * @par
- * You can find a detailed UTF-8 and %Unicode FAQ here:
- * http://www.cl.cam.ac.uk/~mgk25/unicode.html
- *
- * @par Glib::ustring vs. std::string
- * @par
- * Glib::ustring has implicit type conversions to and from std::string.
- * These conversions do @em not convert to/from the current locale (see
- * Glib::locale_from_utf8() and Glib::locale_to_utf8() if you need that). You
- * can always use std::string instead of Glib::ustring -- however, using
- * std::string with multi-byte characters is quite hard. For instance,
- * <tt>std::string::operator[]</tt> might return a byte in the middle of a
- * character, and <tt>std::string::length()</tt> returns the number of bytes
- * rather than characters. So don't do that without a good reason.
- * @par
- * In a perfect world the C++ Standard Library would contain a UTF-8 string
- * class. Unfortunately, the C++ standard doesn't mention UTF-8 at all. Note
- * that std::wstring is not a UTF-8 string class because it contains only
- * fixed-width characters (where width could be 32, 16, or even 8 bits).
- *
- * @par Glib::ustring and stream input/output
- * @par
- * The stream I/O operators, that is operator<<() and operator>>(), perform
- * implicit charset conversion to/from the current locale. If that's not
- * what you intented (e.g. when writing to a configuration file that should
- * always be UTF-8 encoded) use ustring::raw() to override this behaviour.
- * @par
- * If you're using std::ostringstream to build strings for display in the
- * user interface, you must convert the result back to UTF-8 as shown below:
- * @code
- * std::ostringstream output;
- * output.imbue(std::locale("")); // use the user's locale for this stream
- * output << percentage << " % done";
- * label->set_text(Glib::locale_to_utf8(output.str()));
- * @endcode
- *
- * @par Formatted output and internationalization
- * @par
- * The methods ustring::compose() and ustring::format() provide a convenient
- * and powerful alternative to string streams, as shown in the example below.
- * Refer to the method documentation of compose() and format() for details.
- * @code
- * using Glib::ustring;
- *
- * ustring message = ustring::compose("%1 is lower than 0x%2.",
- * 12, ustring::format(std::hex, 16));
- * @endcode
- *
- * @par Implementation notes
- * @par
- * Glib::ustring does not inherit from std::string, because std::string was
- * intended to be a final class. For instance, it does not have a virtual
- * destructor. Also, a HAS-A relationship is more appropriate because
- * ustring can't just enhance the std::string interface. Rather, it has to
- * reimplement the interface so that all operations are based on characters
- * instead of bytes.
- */
-class ustring
-{
-public:
- typedef std::string::size_type size_type;
- typedef std::string::difference_type difference_type;
-
- typedef gunichar value_type;
- typedef gunichar & reference;
- typedef const gunichar & const_reference;
-
- typedef ustring_Iterator<std::string::iterator> iterator;
- typedef ustring_Iterator<std::string::const_iterator> const_iterator;
-
-#ifndef GLIBMM_HAVE_SUN_REVERSE_ITERATOR
-
- typedef std::reverse_iterator<iterator> reverse_iterator;
- typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
-
-#else
-
- typedef std::reverse_iterator<iterator,
- iterator::iterator_category,
- iterator::value_type,
- iterator::reference,
- iterator::pointer,
- iterator::difference_type> reverse_iterator;
- typedef std::reverse_iterator<const_iterator,
- const_iterator::iterator_category,
- const_iterator::value_type,
- const_iterator::reference,
- const_iterator::pointer,
- const_iterator::difference_type> const_reverse_iterator;
-
-#endif /* GLIBMM_HAVE_SUN_REVERSE_ITERATOR */
-
-#ifdef GLIBMM_HAVE_ALLOWS_STATIC_INLINE_NPOS
- static GLIBMM_API const size_type npos = std::string::npos;
-#else
- //The IRIX MipsPro compiler says "The indicated constant value is not known",
- //so we need to initalize the static member data elsewhere.
- static GLIBMM_API const size_type npos;
-#endif
-
- /*! Default constructor, which creates an empty string.
- */
- ustring();
-
- ~ustring();
-
- /*! Construct a ustring as a copy of another ustring.
- * @param other A source string.
- */
- ustring(const ustring& other);
-
- /*! Assign the value of another string to this string.
- * @param other A source string.
- */
- ustring& operator=(const ustring& other);
-
- /*! Swap contents with another string.
- * @param other String to swap with.
- */
- void swap(ustring& other);
-
- /*! Construct a ustring as a copy of another std::string.
- * @param src A source <tt>std::string</tt> containing text encoded as UTF-8.
- */
- ustring(const std::string& src);
-
- /*! Construct a ustring as a copy of a substring.
- * @param src %Source ustring.
- * @param i Index of first character to copy from.
- * @param n Number of UTF-8 characters to copy (defaults to copying the remainder).
- */
- ustring(const ustring& src, size_type i, size_type n=npos);
-
- /*! Construct a ustring as a partial copy of a C string.
- * @param src %Source C string encoded as UTF-8.
- * @param n Number of UTF-8 characters to copy.
- */
- ustring(const char* src, size_type n);
-
- /*! Construct a ustring as a copy of a C string.
- * @param src %Source C string encoded as UTF-8.
- */
- ustring(const char* src);
-
- /*! Construct a ustring as multiple characters.
- * @param n Number of characters.
- * @param uc UCS-4 code point to use.
- */
- ustring(size_type n, gunichar uc);
-
- /*! Construct a ustring as multiple characters.
- * @param n Number of characters.
- * @param c ASCII character to use.
- */
- ustring(size_type n, char c);
-
- /*! Construct a ustring as a copy of a range.
- * @param pbegin Start of range.
- * @param pend End of range.
- */
- template <class In> ustring(In pbegin, In pend);
-
-
-//! @name Assign new contents.
-//! @{
-
- ustring& operator=(const std::string& src);
- ustring& operator=(const char* src);
- ustring& operator=(gunichar uc);
- ustring& operator=(char c);
-
- ustring& assign(const ustring& src);
- ustring& assign(const ustring& src, size_type i, size_type n);
- ustring& assign(const char* src, size_type n);
- ustring& assign(const char* src);
- ustring& assign(size_type n, gunichar uc);
- ustring& assign(size_type n, char c);
- template <class In> ustring& assign(In pbegin, In pend);
-
-//! @}
-//! @name Append to the string.
-//! @{
-
- ustring& operator+=(const ustring& src);
- ustring& operator+=(const char* src);
- ustring& operator+=(gunichar uc);
- ustring& operator+=(char c);
- void push_back(gunichar uc);
- void push_back(char c);
-
- ustring& append(const ustring& src);
- ustring& append(const ustring& src, size_type i, size_type n);
- ustring& append(const char* src, size_type n);
- ustring& append(const char* src);
- ustring& append(size_type n, gunichar uc);
- ustring& append(size_type n, char c);
- template <class In> ustring& append(In pbegin, In pend);
-
-//! @}
-//! @name Insert into the string.
-//! @{
-
- ustring& insert(size_type i, const ustring& src);
- ustring& insert(size_type i, const ustring& src, size_type i2, size_type n);
- ustring& insert(size_type i, const char* src, size_type n);
- ustring& insert(size_type i, const char* src);
- ustring& insert(size_type i, size_type n, gunichar uc);
- ustring& insert(size_type i, size_type n, char c);
-
- iterator insert(iterator p, gunichar uc);
- iterator insert(iterator p, char c);
- void insert(iterator p, size_type n, gunichar uc);
- void insert(iterator p, size_type n, char c);
- template <class In> void insert(iterator p, In pbegin, In pend);
-
-//! @}
-//! @name Replace sub-strings.
-//! @{
-
- ustring& replace(size_type i, size_type n, const ustring& src);
- ustring& replace(size_type i, size_type n, const ustring& src, size_type i2, size_type n2);
- ustring& replace(size_type i, size_type n, const char* src, size_type n2);
- ustring& replace(size_type i, size_type n, const char* src);
- ustring& replace(size_type i, size_type n, size_type n2, gunichar uc);
- ustring& replace(size_type i, size_type n, size_type n2, char c);
-
- ustring& replace(iterator pbegin, iterator pend, const ustring& src);
- ustring& replace(iterator pbegin, iterator pend, const char* src, size_type n);
- ustring& replace(iterator pbegin, iterator pend, const char* src);
- ustring& replace(iterator pbegin, iterator pend, size_type n, gunichar uc);
- ustring& replace(iterator pbegin, iterator pend, size_type n, char c);
- template <class In> ustring& replace(iterator pbegin, iterator pend, In pbegin2, In pend2);
-
-//! @}
-//! @name Erase sub-strings.
-//! @{
-
- void clear();
- ustring& erase(size_type i, size_type n=npos);
- ustring& erase();
- iterator erase(iterator p);
- iterator erase(iterator pbegin, iterator pend);
-
-//! @}
-//! @name Compare and collate.
-//! @{
-
- int compare(const ustring& rhs) const;
- int compare(const char* rhs) const;
- int compare(size_type i, size_type n, const ustring& rhs) const;
- int compare(size_type i, size_type n, const ustring& rhs, size_type i2, size_type n2) const;
- int compare(size_type i, size_type n, const char* rhs, size_type n2) const;
- int compare(size_type i, size_type n, const char* rhs) const;
-
- /*! Create a unique sorting key for the UTF-8 string. If you need to
- * compare UTF-8 strings regularly, e.g. for sorted containers such as
- * <tt>std::set<></tt>, you should consider creating a collate key first
- * and compare this key instead of the actual string.
- *
- * The ustring::compare() methods as well as the relational operators
- * <tt>== != < > <= >=</tt> are quite costly
- * because they have to deal with %Unicode and the collation rules defined by
- * the current locale. Converting both operands to UCS-4 is just the first
- * of several costly steps involved when comparing ustrings. So be careful.
- */
- std::string collate_key() const;
-
- /*! Create a unique key for the UTF-8 string that can be used for caseless
- * sorting. <tt>ustr.casefold_collate_key()</tt> results in the same string
- * as <tt>ustr.casefold().collate_key()</tt>, but the former is likely more
- * efficient.
- */
- std::string casefold_collate_key() const;
-
-//! @}
-//! @name Extract characters and sub-strings.
-//! @{
-
- /*! No reference return; use replace() to write characters. */
- value_type operator[](size_type i) const;
-
- /*! No reference return; use replace() to write characters. @throw std::out_of_range */
- value_type at(size_type i) const;
-
- inline ustring substr(size_type i=0, size_type n=npos) const;
-
-//! @}
-//! @name Access a sequence of characters.
-//! @{
-
- iterator begin();
- iterator end();
- const_iterator begin() const;
- const_iterator end() const;
- reverse_iterator rbegin();
- reverse_iterator rend();
- const_reverse_iterator rbegin() const;
- const_reverse_iterator rend() const;
-
-//! @}
-//! @name Find sub-strings.
-//! @{
-
- size_type find(const ustring& str, size_type i=0) const;
- size_type find(const char* str, size_type i, size_type n) const;
- size_type find(const char* str, size_type i=0) const;
- size_type find(gunichar uc, size_type i=0) const;
- size_type find(char c, size_type i=0) const;
-
- size_type rfind(const ustring& str, size_type i=npos) const;
- size_type rfind(const char* str, size_type i, size_type n) const;
- size_type rfind(const char* str, size_type i=npos) const;
- size_type rfind(gunichar uc, size_type i=npos) const;
- size_type rfind(char c, size_type i=npos) const;
-
-//! @}
-//! @name Match against a set of characters.
-//! @{
-
- size_type find_first_of(const ustring& match, size_type i=0) const;
- size_type find_first_of(const char* match, size_type i, size_type n) const;
- size_type find_first_of(const char* match, size_type i=0) const;
- size_type find_first_of(gunichar uc, size_type i=0) const;
- size_type find_first_of(char c, size_type i=0) const;
-
- size_type find_last_of(const ustring& match, size_type i=npos) const;
- size_type find_last_of(const char* match, size_type i, size_type n) const;
- size_type find_last_of(const char* match, size_type i=npos) const;
- size_type find_last_of(gunichar uc, size_type i=npos) const;
- size_type find_last_of(char c, size_type i=npos) const;
-
- size_type find_first_not_of(const ustring& match, size_type i=0) const;
- size_type find_first_not_of(const char* match, size_type i, size_type n) const;
- size_type find_first_not_of(const char* match, size_type i=0) const;
- size_type find_first_not_of(gunichar uc, size_type i=0) const;
- size_type find_first_not_of(char c, size_type i=0) const;
-
- size_type find_last_not_of(const ustring& match, size_type i=npos) const;
- size_type find_last_not_of(const char* match, size_type i, size_type n) const;
- size_type find_last_not_of(const char* match, size_type i=npos) const;
- size_type find_last_not_of(gunichar uc, size_type i=npos) const;
- size_type find_last_not_of(char c, size_type i=npos) const;
-
-//! @}
-//! @name Retrieve the string's size.
-//! @{
-
- /** Returns true if the string is empty. Equivalent to *this =...
[truncated message content] |
|
From: <tbr...@us...> - 2012-03-20 14:05:47
|
Revision: 204
http://xmlwrapp.svn.sourceforge.net/xmlwrapp/?rev=204&view=rev
Author: tbrowder2
Date: 2012-03-20 14:05:34 +0000 (Tue, 20 Mar 2012)
Log Message:
-----------
rename for clarity
Added Paths:
-----------
trunk/src/libustring/xmlwrappstring.cc
trunk/src/libustring/xmlwrappstring.h
Removed Paths:
-------------
trunk/src/libustring/ustring.cc
trunk/src/libustring/ustring.h
Deleted: trunk/src/libustring/ustring.cc
===================================================================
--- trunk/src/libustring/ustring.cc 2012-03-20 13:49:06 UTC (rev 203)
+++ trunk/src/libustring/ustring.cc 2012-03-20 14:05:34 UTC (rev 204)
@@ -1,1418 +0,0 @@
-// -*- c++ -*-
-/* $Id$ */
-
-/* Copyright (C) 2002 The gtkmm Development Team
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free
- * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#include <glibmmconfig.h>
-#include <glibmm/ustring.h>
-#include <glibmm/convert.h>
-#include <glibmm/error.h>
-#include <glibmm/utility.h>
-
-#include <algorithm>
-#include <iostream>
-#include <cstring>
-# include <stdexcept>
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-namespace
-{
-
-using Glib::ustring;
-
-// Little helper to make the conversion from gunichar to UTF-8 a one-liner.
-//
-struct UnicharToUtf8
-{
- char buf[6];
- ustring::size_type len;
-
- explicit UnicharToUtf8(gunichar uc)
- : len (g_unichar_to_utf8(uc, buf)) {}
-};
-
-
-// All utf8_*_offset() functions return npos if offset is out of range.
-// The caller should decide if npos is a valid argument and just marks
-// the whole string, or if it is not allowed (e.g. for start positions).
-// In the latter case std::out_of_range should be thrown, but usually
-// std::string will do that for us.
-
-// First overload: stop on '\0' character.
-static
-ustring::size_type utf8_byte_offset(const char* str, ustring::size_type offset)
-{
- if(offset == ustring::npos)
- return ustring::npos;
-
- const char *const utf8_skip = g_utf8_skip;
- const char* p = str;
-
- for(; offset != 0; --offset)
- {
- const unsigned int c = static_cast<unsigned char>(*p);
-
- if(c == 0)
- return ustring::npos;
-
- p += utf8_skip[c];
- }
-
- return (p - str);
-}
-
-// Second overload: stop when reaching maxlen.
-static
-ustring::size_type utf8_byte_offset(const char* str, ustring::size_type offset,
- ustring::size_type maxlen)
-{
- if(offset == ustring::npos)
- return ustring::npos;
-
- const char *const utf8_skip = g_utf8_skip;
- const char *const pend = str + maxlen;
- const char* p = str;
-
- for(; offset != 0; --offset)
- {
- if(p >= pend)
- return ustring::npos;
-
- p += utf8_skip[static_cast<unsigned char>(*p)];
- }
-
- return (p - str);
-}
-
-// Third overload: stop when reaching str.size().
-//
-inline
-ustring::size_type utf8_byte_offset(const std::string& str, ustring::size_type offset)
-{
- return utf8_byte_offset(str.data(), offset, str.size());
-}
-
-// Takes UTF-8 character offset and count in ci and cn.
-// Returns the byte offset and count in i and n.
-//
-struct Utf8SubstrBounds
-{
- ustring::size_type i;
- ustring::size_type n;
-
- Utf8SubstrBounds(const std::string& str, ustring::size_type ci, ustring::size_type cn)
- :
- i (utf8_byte_offset(str, ci)),
- n (ustring::npos)
- {
- if(i != ustring::npos)
- n = utf8_byte_offset(str.data() + i, cn, str.size() - i);
- }
-};
-
-// Converts byte offset to UTF-8 character offset.
-inline
-ustring::size_type utf8_char_offset(const std::string& str, ustring::size_type offset)
-{
- if(offset == ustring::npos)
- return ustring::npos;
-
- const char *const pdata = str.data();
- return g_utf8_pointer_to_offset(pdata, pdata + offset);
-}
-
-
-// Helper to implement ustring::find_first_of() and find_first_not_of().
-// Returns the UTF-8 character offset, or ustring::npos if not found.
-static
-ustring::size_type utf8_find_first_of(const std::string& str, ustring::size_type offset,
- const char* utf8_match, long utf8_match_size,
- bool find_not_of)
-{
- const ustring::size_type byte_offset = utf8_byte_offset(str, offset);
- if(byte_offset == ustring::npos)
- return ustring::npos;
-
- long ucs4_match_size = 0;
- const Glib::ScopedPtr<gunichar> ucs4_match
- (g_utf8_to_ucs4_fast(utf8_match, utf8_match_size, &ucs4_match_size));
-
- const gunichar *const match_begin = ucs4_match.get();
- const gunichar *const match_end = match_begin + ucs4_match_size;
-
- const char *const str_begin = str.data();
- const char *const str_end = str_begin + str.size();
-
- for(const char* pstr = str_begin + byte_offset;
- pstr < str_end;
- pstr = g_utf8_next_char(pstr))
- {
- const gunichar *const pfound = std::find(match_begin, match_end, g_utf8_get_char(pstr));
-
- if((pfound != match_end) != find_not_of)
- return offset;
-
- ++offset;
- }
-
- return ustring::npos;
-}
-
-// Helper to implement ustring::find_last_of() and find_last_not_of().
-// Returns the UTF-8 character offset, or ustring::npos if not found.
-static
-ustring::size_type utf8_find_last_of(const std::string& str, ustring::size_type offset,
- const char* utf8_match, long utf8_match_size,
- bool find_not_of)
-{
- long ucs4_match_size = 0;
- const Glib::ScopedPtr<gunichar> ucs4_match
- (g_utf8_to_ucs4_fast(utf8_match, utf8_match_size, &ucs4_match_size));
-
- const gunichar *const match_begin = ucs4_match.get();
- const gunichar *const match_end = match_begin + ucs4_match_size;
-
- const char *const str_begin = str.data();
- const char* pstr = str_begin;
-
- // Set pstr one byte beyond the actual start position.
- const ustring::size_type byte_offset = utf8_byte_offset(str, offset);
- pstr += (byte_offset < str.size()) ? byte_offset + 1 : str.size();
-
- while(pstr > str_begin)
- {
- // Move to previous character.
- do
- --pstr;
- while((static_cast<unsigned char>(*pstr) & 0xC0u) == 0x80);
-
- const gunichar *const pfound = std::find(match_begin, match_end, g_utf8_get_char(pstr));
-
- if((pfound != match_end) != find_not_of)
- return g_utf8_pointer_to_offset(str_begin, pstr);
- }
-
- return ustring::npos;
-}
-
-} // anonymous namespace
-
-
-namespace Glib
-{
-
-#ifndef GLIBMM_HAVE_ALLOWS_STATIC_INLINE_NPOS
-// Initialize static member here,
-// because the compiler did not allow us do it inline.
-const ustring::size_type ustring::npos = std::string::npos;
-#endif
-
-/*
- * We need our own version of g_utf8_get_char(), because the std::string
- * iterator is not necessarily a plain pointer (it's in fact not in GCC's
- * libstdc++-v3). Copying the UTF-8 data into a temporary buffer isn't an
- * option since this operation is quite time critical. The implementation
- * is quite different from g_utf8_get_char() -- both more generic and likely
- * faster.
- *
- * By looking at the first byte of a UTF-8 character one can determine the
- * number of bytes used. GLib offers the g_utf8_skip[] array for this purpose,
- * but accessing this global variable would, on IA32 at least, introduce
- * a function call to fetch the Global Offset Table, plus two levels of
- * indirection in order to read the value. Even worse, fetching the GOT is
- * always done right at the start of the function instead of the branch that
- * actually uses the variable.
- *
- * Fortunately, there's a better way to get the byte count. As this table
- * shows, there's a nice regular pattern in the UTF-8 encoding scheme:
- *
- * 0x00000000 - 0x0000007F: 0xxxxxxx
- * 0x00000080 - 0x000007FF: 110xxxxx 10xxxxxx
- * 0x00000800 - 0x0000FFFF: 1110xxxx 10xxxxxx 10xxxxxx
- * 0x00010000 - 0x001FFFFF: 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
- * 0x00200000 - 0x03FFFFFF: 111110xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
- * 0x04000000 - 0x7FFFFFFF: 1111110x 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
- *
- * Except for the single byte case, the number of leading 1-bits equals the
- * byte count. All that is needed is to shift the first byte to the left
- * until bit 7 becomes 0. Naturally, doing so requires a loop -- but since
- * we already have one, no additional cost is introduced. This shifting can
- * further be combined with the computation of the bitmask needed to eliminate
- * the leading length bits, thus saving yet another register.
- *
- * Note: If you change this code, it is advisable to also review what the
- * compiler makes of it in the assembler output. Except for some pointless
- * register moves, the generated code is sufficiently close to the optimum
- * with GCC 4.1.2 on x86_64.
- */
-gunichar get_unichar_from_std_iterator(std::string::const_iterator pos)
-{
- unsigned int result = static_cast<unsigned char>(*pos);
-
- if((result & 0x80) != 0)
- {
- unsigned int mask = 0x40;
-
- do
- {
- result <<= 6;
- const unsigned int c = static_cast<unsigned char>(*++pos);
- mask <<= 5;
- result += c - 0x80;
- }
- while((result & mask) != 0);
-
- result &= mask - 1;
- }
-
- return result;
-}
-
-
-/**** Glib::ustring ********************************************************/
-
-ustring::ustring()
-:
- string_ ()
-{}
-
-ustring::ustring(const ustring& other)
-:
- string_ (other.string_)
-{}
-
-ustring::ustring(const ustring& src, ustring::size_type i, ustring::size_type n)
-:
- string_ ()
-{
- const Utf8SubstrBounds bounds (src.string_, i, n);
- string_.assign(src.string_, bounds.i, bounds.n);
-}
-
-ustring::ustring(const char* src, ustring::size_type n)
-:
- string_ (src, utf8_byte_offset(src, n))
-{}
-
-ustring::ustring(const char* src)
-:
- string_ (src)
-{}
-
-ustring::ustring(ustring::size_type n, gunichar uc)
-:
- string_ ()
-{
- if(uc < 0x80)
- {
- // Optimize the probably most common case.
- string_.assign(n, static_cast<char>(uc));
- }
- else
- {
- const UnicharToUtf8 conv (uc);
- string_.reserve(n * conv.len);
-
- for(; n > 0; --n)
- string_.append(conv.buf, conv.len);
- }
-}
-
-ustring::ustring(ustring::size_type n, char c)
-:
- string_ (n, c)
-{}
-
-ustring::ustring(const std::string& src)
-:
- string_ (src)
-{}
-
-ustring::~ustring()
-{}
-
-void ustring::swap(ustring& other)
-{
- string_.swap(other.string_);
-}
-
-
-/**** Glib::ustring::operator=() *******************************************/
-
-ustring& ustring::operator=(const ustring& other)
-{
- string_ = other.string_;
- return *this;
-}
-
-ustring& ustring::operator=(const std::string& src)
-{
- string_ = src;
- return *this;
-}
-
-ustring& ustring::operator=(const char* src)
-{
- string_ = src;
- return *this;
-}
-
-ustring& ustring::operator=(gunichar uc)
-{
- const UnicharToUtf8 conv (uc);
- string_.assign(conv.buf, conv.len);
- return *this;
-}
-
-ustring& ustring::operator=(char c)
-{
- string_ = c;
- return *this;
-}
-
-
-/**** Glib::ustring::assign() **********************************************/
-
-ustring& ustring::assign(const ustring& src)
-{
- string_ = src.string_;
- return *this;
-}
-
-ustring& ustring::assign(const ustring& src, ustring::size_type i, ustring::size_type n)
-{
- const Utf8SubstrBounds bounds (src.string_, i, n);
- string_.assign(src.string_, bounds.i, bounds.n);
- return *this;
-}
-
-ustring& ustring::assign(const char* src, ustring::size_type n)
-{
- string_.assign(src, utf8_byte_offset(src, n));
- return *this;
-}
-
-ustring& ustring::assign(const char* src)
-{
- string_ = src;
- return *this;
-}
-
-ustring& ustring::assign(ustring::size_type n, gunichar uc)
-{
- ustring temp (n, uc);
- string_.swap(temp.string_);
- return *this;
-}
-
-ustring& ustring::assign(ustring::size_type n, char c)
-{
- string_.assign(n, c);
- return *this;
-}
-
-
-/**** Glib::ustring::operator+=() ******************************************/
-
-ustring& ustring::operator+=(const ustring& src)
-{
- string_ += src.string_;
- return *this;
-}
-
-ustring& ustring::operator+=(const char* src)
-{
- string_ += src;
- return *this;
-}
-
-ustring& ustring::operator+=(gunichar uc)
-{
- const UnicharToUtf8 conv (uc);
- string_.append(conv.buf, conv.len);
- return *this;
-}
-
-ustring& ustring::operator+=(char c)
-{
- string_ += c;
- return *this;
-}
-
-
-/**** Glib::ustring::push_back() *******************************************/
-
-void ustring::push_back(gunichar uc)
-{
- const UnicharToUtf8 conv (uc);
- string_.append(conv.buf, conv.len);
-}
-
-void ustring::push_back(char c)
-{
- string_ += c;
-}
-
-
-/**** Glib::ustring::append() **********************************************/
-
-ustring& ustring::append(const ustring& src)
-{
- string_ += src.string_;
- return *this;
-}
-
-ustring& ustring::append(const ustring& src, ustring::size_type i, ustring::size_type n)
-{
- const Utf8SubstrBounds bounds (src.string_, i, n);
- string_.append(src.string_, bounds.i, bounds.n);
- return *this;
-}
-
-ustring& ustring::append(const char* src, ustring::size_type n)
-{
- string_.append(src, utf8_byte_offset(src, n));
- return *this;
-}
-
-ustring& ustring::append(const char* src)
-{
- string_ += src;
- return *this;
-}
-
-ustring& ustring::append(ustring::size_type n, gunichar uc)
-{
- string_.append(ustring(n, uc).string_);
- return *this;
-}
-
-ustring& ustring::append(ustring::size_type n, char c)
-{
- string_.append(n, c);
- return *this;
-}
-
-
-/**** Glib::ustring::insert() **********************************************/
-
-ustring& ustring::insert(ustring::size_type i, const ustring& src)
-{
- string_.insert(utf8_byte_offset(string_, i), src.string_);
- return *this;
-}
-
-ustring& ustring::insert(ustring::size_type i, const ustring& src,
- ustring::size_type i2, ustring::size_type n)
-{
- const Utf8SubstrBounds bounds2 (src.string_, i2, n);
- string_.insert(utf8_byte_offset(string_, i), src.string_, bounds2.i, bounds2.n);
- return *this;
-}
-
-ustring& ustring::insert(ustring::size_type i, const char* src, ustring::size_type n)
-{
- string_.insert(utf8_byte_offset(string_, i), src, utf8_byte_offset(src, n));
- return *this;
-}
-
-ustring& ustring::insert(ustring::size_type i, const char* src)
-{
- string_.insert(utf8_byte_offset(string_, i), src);
- return *this;
-}
-
-ustring& ustring::insert(ustring::size_type i, ustring::size_type n, gunichar uc)
-{
- string_.insert(utf8_byte_offset(string_, i), ustring(n, uc).string_);
- return *this;
-}
-
-ustring& ustring::insert(ustring::size_type i, ustring::size_type n, char c)
-{
- string_.insert(utf8_byte_offset(string_, i), n, c);
- return *this;
-}
-
-ustring::iterator ustring::insert(ustring::iterator p, gunichar uc)
-{
- const size_type offset = p.base() - string_.begin();
- const UnicharToUtf8 conv (uc);
- string_.insert(offset, conv.buf, conv.len);
- return iterator(string_.begin() + offset);
-}
-
-ustring::iterator ustring::insert(ustring::iterator p, char c)
-{
- return iterator(string_.insert(p.base(), c));
-}
-
-void ustring::insert(ustring::iterator p, ustring::size_type n, gunichar uc)
-{
- string_.insert(p.base() - string_.begin(), ustring(n, uc).string_);
-}
-
-void ustring::insert(ustring::iterator p, ustring::size_type n, char c)
-{
- string_.insert(p.base(), n, c);
-}
-
-
-/**** Glib::ustring::replace() *********************************************/
-
-ustring& ustring::replace(ustring::size_type i, ustring::size_type n, const ustring& src)
-{
- const Utf8SubstrBounds bounds (string_, i, n);
- string_.replace(bounds.i, bounds.n, src.string_);
- return *this;
-}
-
-ustring& ustring::replace(ustring::size_type i, ustring::size_type n,
- const ustring& src, ustring::size_type i2, ustring::size_type n2)
-{
- const Utf8SubstrBounds bounds (string_, i, n);
- const Utf8SubstrBounds bounds2 (src.string_, i2, n2);
- string_.replace(bounds.i, bounds.n, src.string_, bounds2.i, bounds2.n);
- return *this;
-}
-
-ustring& ustring::replace(ustring::size_type i, ustring::size_type n,
- const char* src, ustring::size_type n2)
-{
- const Utf8SubstrBounds bounds (string_, i, n);
- string_.replace(bounds.i, bounds.n, src, utf8_byte_offset(src, n2));
- return *this;
-}
-
-ustring& ustring::replace(ustring::size_type i, ustring::size_type n, const char* src)
-{
- const Utf8SubstrBounds bounds (string_, i, n);
- string_.replace(bounds.i, bounds.n, src);
- return *this;
-}
-
-ustring& ustring::replace(ustring::size_type i, ustring::size_type n,
- ustring::size_type n2, gunichar uc)
-{
- const Utf8SubstrBounds bounds (string_, i, n);
- string_.replace(bounds.i, bounds.n, ustring(n2, uc).string_);
- return *this;
-}
-
-ustring& ustring::replace(ustring::size_type i, ustring::size_type n,
- ustring::size_type n2, char c)
-{
- const Utf8SubstrBounds bounds (string_, i, n);
- string_.replace(bounds.i, bounds.n, n2, c);
- return *this;
-}
-
-ustring& ustring::replace(ustring::iterator pbegin, ustring::iterator pend, const ustring& src)
-{
- string_.replace(pbegin.base(), pend.base(), src.string_);
- return *this;
-}
-
-ustring& ustring::replace(ustring::iterator pbegin, ustring::iterator pend,
- const char* src, ustring::size_type n)
-{
- string_.replace(pbegin.base(), pend.base(), src, utf8_byte_offset(src, n));
- return *this;
-}
-
-ustring& ustring::replace(ustring::iterator pbegin, ustring::iterator pend, const char* src)
-{
- string_.replace(pbegin.base(), pend.base(), src);
- return *this;
-}
-
-ustring& ustring::replace(ustring::iterator pbegin, ustring::iterator pend,
- ustring::size_type n, gunichar uc)
-{
- string_.replace(pbegin.base(), pend.base(), ustring(n, uc).string_);
- return *this;
-}
-
-ustring& ustring::replace(ustring::iterator pbegin, ustring::iterator pend,
- ustring::size_type n, char c)
-{
- string_.replace(pbegin.base(), pend.base(), n, c);
- return *this;
-}
-
-
-/**** Glib::ustring::erase() ***********************************************/
-
-void ustring::clear()
-{
- string_.erase();
-}
-
-ustring& ustring::erase(ustring::size_type i, ustring::size_type n)
-{
- const Utf8SubstrBounds bounds (string_, i, n);
- string_.erase(bounds.i, bounds.n);
- return *this;
-}
-
-ustring& ustring::erase()
-{
- string_.erase();
- return *this;
-}
-
-ustring::iterator ustring::erase(ustring::iterator p)
-{
- ustring::iterator iter_end = p;
- ++iter_end;
-
- return iterator(string_.erase(p.base(), iter_end.base()));
-}
-
-ustring::iterator ustring::erase(ustring::iterator pbegin, ustring::iterator pend)
-{
- return iterator(string_.erase(pbegin.base(), pend.base()));
-}
-
-
-/**** Glib::ustring::compare() *********************************************/
-
-int ustring::compare(const ustring& rhs) const
-{
- return g_utf8_collate(string_.c_str(), rhs.string_.c_str());
-}
-
-int ustring::compare(const char* rhs) const
-{
- return g_utf8_collate(string_.c_str(), rhs);
-}
-
-int ustring::compare(ustring::size_type i, ustring::size_type n, const ustring& rhs) const
-{
- return ustring(*this, i, n).compare(rhs);
-}
-
-int ustring::compare(ustring::size_type i, ustring::size_type n,
- const ustring& rhs, ustring::size_type i2, ustring::size_type n2) const
-{
- return ustring(*this, i, n).compare(ustring(rhs, i2, n2));
-}
-
-int ustring::compare(ustring::size_type i, ustring::size_type n,
- const char* rhs, ustring::size_type n2) const
-{
- return ustring(*this, i, n).compare(ustring(rhs, n2));
-}
-
-int ustring::compare(ustring::size_type i, ustring::size_type n, const char* rhs) const
-{
- return ustring(*this, i, n).compare(rhs);
-}
-
-
-/**** Glib::ustring -- index access ****************************************/
-
-ustring::value_type ustring::operator[](ustring::size_type i) const
-{
- return g_utf8_get_char(g_utf8_offset_to_pointer(string_.data(), i));
-}
-
-ustring::value_type ustring::at(ustring::size_type i) const
-{
- const size_type byte_offset = utf8_byte_offset(string_, i);
-
- // Throws std::out_of_range if the index is invalid.
- return g_utf8_get_char(&string_.at(byte_offset));
-}
-
-
-/**** Glib::ustring -- iterator access *************************************/
-
-ustring::iterator ustring::begin()
-{
- return iterator(string_.begin());
-}
-
-ustring::iterator ustring::end()
-{
- return iterator(string_.end());
-}
-
-ustring::const_iterator ustring::begin() const
-{
- return const_iterator(string_.begin());
-}
-
-ustring::const_iterator ustring::end() const
-{
- return const_iterator(string_.end());
-}
-
-ustring::reverse_iterator ustring::rbegin()
-{
- return reverse_iterator(iterator(string_.end()));
-}
-
-ustring::reverse_iterator ustring::rend()
-{
- return reverse_iterator(iterator(string_.begin()));
-}
-
-ustring::const_reverse_iterator ustring::rbegin() const
-{
- return const_reverse_iterator(const_iterator(string_.end()));
-}
-
-ustring::const_reverse_iterator ustring::rend() const
-{
- return const_reverse_iterator(const_iterator(string_.begin()));
-}
-
-
-/**** Glib::ustring::find() ************************************************/
-
-ustring::size_type ustring::find(const ustring& str, ustring::size_type i) const
-{
- return utf8_char_offset(string_, string_.find(str.string_, utf8_byte_offset(string_, i)));
-}
-
-ustring::size_type ustring::find(const char* str, ustring::size_type i, ustring::size_type n) const
-{
- return utf8_char_offset(string_, string_.find(str, utf8_byte_offset(string_, i),
- utf8_byte_offset(str, n)));
-}
-
-ustring::size_type ustring::find(const char* str, ustring::size_type i) const
-{
- return utf8_char_offset(string_, string_.find(str, utf8_byte_offset(string_, i)));
-}
-
-ustring::size_type ustring::find(gunichar uc, ustring::size_type i) const
-{
- const UnicharToUtf8 conv (uc);
- return utf8_char_offset(string_, string_.find(conv.buf, utf8_byte_offset(string_, i), conv.len));
-}
-
-ustring::size_type ustring::find(char c, ustring::size_type i) const
-{
- return utf8_char_offset(string_, string_.find(c, utf8_byte_offset(string_, i)));
-}
-
-
-/**** Glib::ustring::rfind() ***********************************************/
-
-ustring::size_type ustring::rfind(const ustring& str, ustring::size_type i) const
-{
- return utf8_char_offset(string_, string_.rfind(str.string_, utf8_byte_offset(string_, i)));
-}
-
-ustring::size_type ustring::rfind(const char* str, ustring::size_type i,
- ustring::size_type n) const
-{
- return utf8_char_offset(string_, string_.rfind(str, utf8_byte_offset(string_, i),
- utf8_byte_offset(str, n)));
-}
-
-ustring::size_type ustring::rfind(const char* str, ustring::size_type i) const
-{
- return utf8_char_offset(string_, string_.rfind(str, utf8_byte_offset(string_, i)));
-}
-
-ustring::size_type ustring::rfind(gunichar uc, ustring::size_type i) const
-{
- const UnicharToUtf8 conv (uc);
- return utf8_char_offset(string_, string_.rfind(conv.buf, utf8_byte_offset(string_, i), conv.len));
-}
-
-ustring::size_type ustring::rfind(char c, ustring::size_type i) const
-{
- return utf8_char_offset(string_, string_.rfind(c, utf8_byte_offset(string_, i)));
-}
-
-
-/**** Glib::ustring::find_first_of() ***************************************/
-
-ustring::size_type ustring::find_first_of(const ustring& match, ustring::size_type i) const
-{
- return utf8_find_first_of(string_, i, match.string_.data(), match.string_.size(), false);
-}
-
-ustring::size_type ustring::find_first_of(const char* match,
- ustring::size_type i, ustring::size_type n) const
-{
- return utf8_find_first_of(string_, i, match, n, false);
-}
-
-ustring::size_type ustring::find_first_of(const char* match, ustring::size_type i) const
-{
- return utf8_find_first_of(string_, i, match, -1, false);
-}
-
-ustring::size_type ustring::find_first_of(gunichar uc, ustring::size_type i) const
-{
- return find(uc, i);
-}
-
-ustring::size_type ustring::find_first_of(char c, ustring::size_type i) const
-{
- return find(c, i);
-}
-
-
-/**** Glib::ustring::find_last_of() ****************************************/
-
-ustring::size_type ustring::find_last_of(const ustring& match, ustring::size_type i) const
-{
- return utf8_find_last_of(string_, i, match.string_.data(), match.string_.size(), false);
-}
-
-ustring::size_type ustring::find_last_of(const char* match,
- ustring::size_type i, ustring::size_type n) const
-{
- return utf8_find_last_of(string_, i, match, n, false);
-}
-
-ustring::size_type ustring::find_last_of(const char* match, ustring::size_type i) const
-{
- return utf8_find_last_of(string_, i, match, -1, false);
-}
-
-ustring::size_type ustring::find_last_of(gunichar uc, ustring::size_type i) const
-{
- return rfind(uc, i);
-}
-
-ustring::size_type ustring::find_last_of(char c, ustring::size_type i) const
-{
- return rfind(c, i);
-}
-
-
-/**** Glib::ustring::find_first_not_of() ***********************************/
-
-ustring::size_type ustring::find_first_not_of(const ustring& match, ustring::size_type i) const
-{
- return utf8_find_first_of(string_, i, match.string_.data(), match.string_.size(), true);
-}
-
-ustring::size_type ustring::find_first_not_of(const char* match,
- ustring::size_type i, ustring::size_type n) const
-{
- return utf8_find_first_of(string_, i, match, n, true);
-}
-
-ustring::size_type ustring::find_first_not_of(const char* match, ustring::size_type i) const
-{
- return utf8_find_first_of(string_, i, match, -1, true);
-}
-
-// Unfortunately, all of the find_*_not_of() methods for single
-// characters need their own special implementation.
-//
-ustring::size_type ustring::find_first_not_of(gunichar uc, ustring::size_type i) const
-{
- const size_type bi = utf8_byte_offset(string_, i);
- if(bi != npos)
- {
- const char *const pbegin = string_.data();
- const char *const pend = pbegin + string_.size();
-
- for(const char* p = pbegin + bi;
- p < pend;
- p = g_utf8_next_char(p), ++i)
- {
- if(g_utf8_get_char(p) != uc)
- return i;
- }
- }
- return npos;
-}
-
-ustring::size_type ustring::find_first_not_of(char c, ustring::size_type i) const
-{
- const size_type bi = utf8_byte_offset(string_, i);
- if(bi != npos)
- {
- const char *const pbegin = string_.data();
- const char *const pend = pbegin + string_.size();
-
- for(const char* p = pbegin + bi;
- p < pend;
- p = g_utf8_next_char(p), ++i)
- {
- if(*p != c)
- return i;
- }
- }
- return npos;
-}
-
-
-/**** Glib::ustring::find_last_not_of() ************************************/
-
-ustring::size_type ustring::find_last_not_of(const ustring& match, ustring::size_type i) const
-{
- return utf8_find_last_of(string_, i, match.string_.data(), match.string_.size(), true);
-}
-
-ustring::size_type ustring::find_last_not_of(const char* match,
- ustring::size_type i, ustring::size_type n) const
-{
- return utf8_find_last_of(string_, i, match, n, true);
-}
-
-ustring::size_type ustring::find_last_not_of(const char* match, ustring::size_type i) const
-{
- return utf8_find_last_of(string_, i, match, -1, true);
-}
-
-// Unfortunately, all of the find_*_not_of() methods for single
-// characters need their own special implementation.
-//
-ustring::size_type ustring::find_last_not_of(gunichar uc, ustring::size_type i) const
-{
- const char *const pbegin = string_.data();
- const char *const pend = pbegin + string_.size();
- size_type i_cur = 0;
- size_type i_found = npos;
-
- for(const char* p = pbegin;
- p < pend && i_cur <= i;
- p = g_utf8_next_char(p), ++i_cur)
- {
- if(g_utf8_get_char(p) != uc)
- i_found = i_cur;
- }
- return i_found;
-}
-
-ustring::size_type ustring::find_last_not_of(char c, ustring::size_type i) const
-{
- const char *const pbegin = string_.data();
- const char *const pend = pbegin + string_.size();
- size_type i_cur = 0;
- size_type i_found = npos;
-
- for(const char* p = pbegin;
- p < pend && i_cur <= i;
- p = g_utf8_next_char(p), ++i_cur)
- {
- if(*p != c)
- i_found = i_cur;
- }
- return i_found;
-}
-
-
-/**** Glib::ustring -- get size and resize *********************************/
-
-bool ustring::empty() const
-{
- return string_.empty();
-}
-
-ustring::size_type ustring::size() const
-{
- const char *const pdata = string_.data();
- return g_utf8_pointer_to_offset(pdata, pdata + string_.size());
-}
-
-ustring::size_type ustring::length() const
-{
- const char *const pdata = string_.data();
- return g_utf8_pointer_to_offset(pdata, pdata + string_.size());
-}
-
-ustring::size_type ustring::bytes() const
-{
- return string_.size();
-}
-
-ustring::size_type ustring::capacity() const
-{
- return string_.capacity();
-}
-
-ustring::size_type ustring::max_size() const
-{
- return string_.max_size();
-}
-
-void ustring::resize(ustring::size_type n, gunichar uc)
-{
- const size_type size_now = size();
- if(n < size_now)
- erase(n, npos);
- else if(n > size_now)
- append(n - size_now, uc);
-}
-
-void ustring::resize(ustring::size_type n, char c)
-{
- const size_type size_now = size();
- if(n < size_now)
- erase(n, npos);
- else if(n > size_now)
- string_.append(n - size_now, c);
-}
-
-void ustring::reserve(ustring::size_type n)
-{
- string_.reserve(n);
-}
-
-
-/**** Glib::ustring -- C string access *************************************/
-
-const char* ustring::data() const
-{
- return string_.data();
-}
-
-const char* ustring::c_str() const
-{
- return string_.c_str();
-}
-
-// Note that copy() requests UTF-8 character offsets as
-// parameters, but returns the number of copied bytes.
-//
-ustring::size_type ustring::copy(char* dest, ustring::size_type n, ustring::size_type i) const
-{
- const Utf8SubstrBounds bounds (string_, i, n);
- return string_.copy(dest, bounds.n, bounds.i);
-}
-
-
-/**** Glib::ustring -- UTF-8 utilities *************************************/
-
-bool ustring::validate() const
-{
- return (g_utf8_validate(string_.data(), string_.size(), 0) != 0);
-}
-
-bool ustring::validate(ustring::iterator& first_invalid)
-{
- const char *const pdata = string_.data();
- const char* valid_end = pdata;
- const int is_valid = g_utf8_validate(pdata, string_.size(), &valid_end);
-
- first_invalid = iterator(string_.begin() + (valid_end - pdata));
- return (is_valid != 0);
-}
-
-bool ustring::validate(ustring::const_iterator& first_invalid) const
-{
- const char *const pdata = string_.data();
- const char* valid_end = pdata;
- const int is_valid = g_utf8_validate(pdata, string_.size(), &valid_end);
-
- first_invalid = const_iterator(string_.begin() + (valid_end - pdata));
- return (is_valid != 0);
-}
-
-bool ustring::is_ascii() const
-{
- const char* p = string_.data();
- const char *const pend = p + string_.size();
-
- for(; p != pend; ++p)
- {
- if((static_cast<unsigned char>(*p) & 0x80u) != 0)
- return false;
- }
-
- return true;
-}
-
-ustring ustring::normalize(NormalizeMode mode) const
-{
- const ScopedPtr<char> buf (g_utf8_normalize(string_.data(), string_.size(),
- static_cast<GNormalizeMode>(int(mode))));
- return ustring(buf.get());
-}
-
-ustring ustring::uppercase() const
-{
- const ScopedPtr<char> buf (g_utf8_strup(string_.data(), string_.size()));
- return ustring(buf.get());
-}
-
-ustring ustring::lowercase() const
-{
- const ScopedPtr<char> buf (g_utf8_strdown(string_.data(), string_.size()));
- return ustring(buf.get());
-}
-
-ustring ustring::casefold() const
-{
- const ScopedPtr<char> buf (g_utf8_casefold(string_.data(), string_.size()));
- return ustring(buf.get());
-}
-
-std::string ustring::collate_key() const
-{
- const ScopedPtr<char> buf (g_utf8_collate_key(string_.data(), string_.size()));
- return std::string(buf.get());
-}
-
-std::string ustring::casefold_collate_key() const
-{
- char *const casefold_buf = g_utf8_casefold(string_.data(), string_.size());
- char *const key_buf = g_utf8_collate_key(casefold_buf, -1);
- g_free(casefold_buf);
- return std::string(ScopedPtr<char>(key_buf).get());
-}
-
-/**** Glib::ustring -- Message formatting **********************************/
-
-// static
-ustring ustring::compose_argv(const Glib::ustring& fmt, int argc, const ustring* const* argv)
-{
- std::string::size_type result_size = fmt.raw().size();
-
- // Guesstimate the final string size.
- for (int i = 0; i < argc; ++i)
- result_size += argv[i]->raw().size();
-
- std::string result;
- result.reserve(result_size);
-
- const char* const pfmt = fmt.raw().c_str();
- const char* start = pfmt;
-
- while (const char* const stop = std::strchr(start, '%'))
- {
- if (stop[1] == '%')
- {
- result.append(start, stop - start + 1);
- start = stop + 2;
- }
- else
- {
- const int index = Ascii::digit_value(stop[1]) - 1;
-
- if (index >= 0 && index < argc)
- {
- result.append(start, stop - start);
- result += argv[index]->raw();
- start = stop + 2;
- }
- else
- {
- const char* const next = (stop[1] != '\0') ? g_utf8_next_char(stop + 1) : (stop + 1);
-
- // Copy invalid substitutions literally to the output.
- result.append(start, next - start);
-
- g_warning("invalid substitution \"%s\" in fmt string \"%s\"",
- result.c_str() + result.size() - (next - stop), pfmt);
- start = next;
- }
- }
- }
-
- result.append(start, pfmt + fmt.raw().size() - start);
-
- return result;
-}
-
-/**** Glib::ustring::SequenceToString **************************************/
-
-ustring::SequenceToString<Glib::ustring::iterator,gunichar>
- ::SequenceToString(Glib::ustring::iterator pbegin, Glib::ustring::iterator pend)
-:
- std::string(pbegin.base(), pend.base())
-{}
-
-ustring::SequenceToString<Glib::ustring::const_iterator,gunichar>
- ::SequenceToString(Glib::ustring::const_iterator pbegin, Glib::ustring::const_iterator pend)
-:
- std::string(pbegin.base(), pend.base())
-{}
-
-/**** Glib::ustring::FormatStream ******************************************/
-
-ustring::FormatStream::FormatStream()
-:
- stream_ ()
-{}
-
-ustring::FormatStream::~FormatStream()
-{}
-
-ustring ustring::FormatStream::to_string() const
-{
- GError* error = 0;
-
-#ifdef GLIBMM_HAVE_WIDE_STREAM
- const std::wstring str = stream_.str();
-
-# if defined(__STDC_ISO_10646__) && SIZEOF_WCHAR_T == 4
- // Avoid going through iconv if wchar_t always contains UCS-4.
- glong n_bytes = 0;
- const ScopedPtr<char> buf (g_ucs4_to_utf8(reinterpret_cast<const gunichar*>(str.data()),
- str.size(), 0, &n_bytes, &error));
-# elif defined(G_OS_WIN32) && SIZEOF_WCHAR_T == 2
- // Avoid going through iconv if wchar_t always contains UTF-16.
- glong n_bytes = 0;
- const ScopedPtr<char> buf (g_utf16_to_utf8(reinterpret_cast<const gunichar2*>(str.data()),
- str.size(), 0, &n_bytes, &error));
-# else
- gsize n_bytes = 0;
- const ScopedPtr<char> buf (g_convert(reinterpret_cast<const char*>(str.data()),
- str.size() * sizeof(std::wstring::value_type),
- "UTF-8", "WCHAR_T", 0, &n_bytes, &error));
-# endif /* !(__STDC_ISO_10646__ || G_OS_WIN32) */
-
-#else /* !GLIBMM_HAVE_WIDE_STREAM */
- const std::string str = stream_.str();
-
- gsize n_bytes = 0;
- const ScopedPtr<char> buf (g_locale_to_utf8(str.data(), str.size(), 0, &n_bytes, &error));
-#endif /* !GLIBMM_HAVE_WIDE_STREAM */
-
- if (error)
- {
- Glib::Error::throw_exception(error);
- }
-
- return ustring(buf.get(), buf.get() + n_bytes);
-}
-
-/**** Glib::ustring -- stream I/O operators ********************************/
-
-std::istream& operator>>(std::istream& is, Glib::ustring& utf8_string)
-{
- std::string str;
- is >> str;
-
- GError* error = 0;
- gsize n_bytes = 0;
- const ScopedPtr<char> buf (g_locale_to_utf8(str.data(), str.size(), 0, &n_bytes, &error));
-
- if (error)
- {
- Glib::Error::throw_exception(error);
- }
-
- utf8_string.assign(buf.get(), buf.get() + n_bytes);
-
- return is;
-}
-
-std::ostream& operator<<(std::ostream& os, const Glib::ustring& utf8_string)
-{
- GError* error = 0;
- const ScopedPtr<char> buf (g_locale_from_utf8(utf8_string.raw().data(),
- utf8_string.raw().size(), 0, 0, &error));
- if (error)
- {
- Glib::Error::throw_exception(error);
- }
-
- // This won't work if the string contains NUL characters. Unfortunately,
- // std::ostream::write() ignores format flags, so we cannot use that.
- // The only option would be to create a temporary std::string. However,
- // even then GCC's libstdc++-v3 prints only the characters up to the first
- // NUL. Given this, there doesn't seem much of a point in allowing NUL in
- // formatted output. The semantics would be unclear anyway: what's the
- // screen width of a NUL?
- os << buf.get();
-
- return os;
-}
-
-#ifdef GLIBMM_HAVE_WIDE_STREAM
-
-std::wistream& operator>>(std::wistream& is, ustring& utf8_string)
-{
- GError* error = 0;
-
- std::wstring wstr;
- is >> wstr;
-
-#if defined(__STDC_ISO_10646__) && SIZEOF_WCHAR_T == 4
- // Avoid going through iconv if wchar_t always contains UCS-4.
- glong n_bytes = 0;
- const ScopedPtr<char> buf (g_ucs4_to_utf8(reinterpret_cast<const gunichar*>(wstr.data()),
- wstr.size(), 0, &n_bytes, &error));
-#elif defined(G_OS_WIN32) && SIZEOF_WCHAR_T == 2
- // Avoid going through iconv if wchar_t always contains UTF-16.
- glong n_bytes = 0;
- const ScopedPtr<char> buf (g_utf16_to_utf8(reinterpret_cast<const gunichar2*>(wstr.data()),
- wstr.size(), 0, &n_bytes, &error));
-#else
- gsize n_bytes = 0;
- const ScopedPtr<char> buf (g_convert(reinterpret_cast<const char*>(wstr.data()),
- wstr.size() * sizeof(std::wstring::value_type),
- "UTF-8", "WCHAR_T", 0, &n_bytes, &error));
-#endif // !(__STDC_ISO_10646__ || G_OS_WIN32)
-
- if (error)
- {
- Glib::Error::throw_exception(error);
- }
-
- utf8_string.assign(buf.get(), buf.get() + n_bytes);
-
- return is;
-}
-
-std::wostream& operator<<(std::wostream& os, const ustring& utf8_string)
-{
- GError* error = 0;
-
-#if defined(__STDC_ISO_10646__) && SIZEOF_WCHAR_T == 4
- // Avoid going through iconv if wchar_t always contains UCS-4.
- const ScopedPtr<gunichar> buf (g_utf8_to_ucs4(utf8_string.raw().data(),
- utf8_string.raw().size(), 0, 0, &error));
-#elif defined(G_OS_WIN32) && SIZEOF_WCHAR_T == 2
- // Avoid going through iconv if wchar_t always contains UTF-16.
- const ScopedPtr<gunichar2> buf (g_utf8_to_utf16(utf8_string.raw().data(),
- utf8_string.raw().size(), 0, 0, &error));
-#else
- // TODO: For some reason the conversion from UTF-8 to WCHAR_T doesn't work
- // with g_convert(), while iconv on the command line handles it just fine.
- // Maybe a bug in GLib?
- const ScopedPtr<char> buf (g_convert(utf8_string.raw().data(), utf8_string.raw().size(),
- "WCHAR_T", "UTF-8", 0, 0, &error));
-#endif // !(__STDC_ISO_10646__ || G_OS_WIN32)
-
- if (error)
- {
- Glib::Error::throw_exception(error);
- }
-
- // This won't work if the string contains NUL characters. Unfortunately,
- // std::wostream::write() ignores format flags, so we cannot use that.
- // The only option would be to create a temporary std::wstring. However,
- // even then GCC's libstdc++-v3 prints only the characters up to the first
- // NUL. Given this, there doesn't seem much of a point in allowing NUL in
- // formatted output. The semantics would be unclear anyway: what's the
- // screen width of a NUL?
- os << reinterpret_cast<wchar_t*>(buf.get());
-
- return os;
-}
-
-#endif /* GLIBMM_HAVE_WIDE_STREAM */
-
-} // namespace Glib
Deleted: trunk/src/libustring/ustring.h
===================================================================
--- trunk/src/libustring/ustring.h 2012-03-20 13:49:06 UTC (rev 203)
+++ trunk/src/libustring/ustring.h 2012-03-20 14:05:34 UTC (rev 204)
@@ -1,1615 +0,0 @@
-// -*- c++ -*-
-#ifndef _GLIBMM_USTRING_H
-#define _GLIBMM_USTRING_H
-
-/* $Id$ */
-
-/* Copyright (C) 2002 The gtkmm Development Team
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free
- * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#include <glibmmconfig.h>
-#include <glibmm/unicode.h>
-#include <glib.h>
-
-#include <iosfwd>
-#include <iterator>
-#include <sstream>
-#include <string>
-#ifndef GLIBMM_HAVE_STD_ITERATOR_TRAITS
-#include <cstddef> /* for ptrdiff_t */
-#endif
-
-namespace Glib
-{
-
-#ifndef DOXYGEN_SHOULD_SKIP_THIS
-#ifndef GLIBMM_HAVE_STD_ITERATOR_TRAITS
-
-template <class T>
-struct IteratorTraits
-{
- typedef typename T::iterator_category iterator_category;
- typedef typename T::value_type value_type;
- typedef typename T::difference_type difference_type;
- typedef typename T::pointer pointer;
- typedef typename T::reference reference;
-};
-
-template <class T>
-struct IteratorTraits<T*>
-{
- typedef std::random_access_iterator_tag iterator_category;
- typedef T value_type;
- typedef ptrdiff_t difference_type;
- typedef T* pointer;
- typedef T& reference;
-};
-
-template <class T>
-struct IteratorTraits<const T*>
-{
- typedef std::random_access_iterator_tag iterator_category;
- typedef T value_type;
- typedef ptrdiff_t difference_type;
- typedef const T* pointer;
- typedef const T& reference;
-};
-
-#endif /* GLIBMM_HAVE_STD_ITERATOR_TRAITS */
-#endif /* DOXYGEN_SHOULD_SKIP_THIS */
-
-
-/** The iterator type of Glib::ustring.
- * Note this is not a random access iterator but a bidirectional one,
- * since all index operations need to iterate over the UTF-8 data. Use
- * std::advance() to move to a certain position. However, all of the
- * relational operators are available:
- * <tt>== != < > <= >=</tt>
- *
- * A writeable iterator isn't provided because: The number of bytes of
- * the old UTF-8 character and the new one to write could be different.
- * Therefore, any write operation would invalidate all other iterators
- * pointing into the same string.
- */
-template <class T>
-class ustring_Iterator
-{
-public:
- typedef std::bidirectional_iterator_tag iterator_category;
- typedef gunichar value_type;
- typedef std::string::difference_type difference_type;
- typedef value_type reference;
- typedef void pointer;
-
- inline ustring_Iterator();
- inline ustring_Iterator(const ustring_Iterator<std::string::iterator>& other);
-
- inline value_type operator*() const;
-
- inline ustring_Iterator<T> & operator++();
- inline const ustring_Iterator<T> operator++(int);
- inline ustring_Iterator<T> & operator--();
- inline const ustring_Iterator<T> operator--(int);
-
- explicit inline ustring_Iterator(T pos);
- inline T base() const;
-
-private:
- T pos_;
-};
-
-
-/** Extract a UCS-4 character from UTF-8 data.
- * Convert a single UTF-8 (multibyte) character starting at @p pos to
- * a UCS-4 wide character. This may read up to 6 bytes after the start
- * position, depending on the UTF-8 character width. You have to make
- * sure the source contains at least one valid UTF-8 character.
- *
- * This is mainly used by the implementation of Glib::ustring::iterator,
- * but it might be useful as utility function if you prefer using
- * std::string even for UTF-8 encoding.
- */
-gunichar get_unichar_from_std_iterator(std::string::const_iterator pos) G_GNUC_PURE;
-
-
-/** Glib::ustring has much the same interface as std::string, but contains
- * %Unicode characters encoded as UTF-8.
- *
- * @par About UTF-8 and ASCII
- * @par
- * The standard character set ANSI_X3.4-1968 -- more commonly known as
- * ASCII -- is a subset of UTF-8. So, if you want to, you can use
- * Glib::ustring without even thinking about UTF-8.
- * @par
- * Whenever ASCII is mentioned in this manual, we mean the @em real ASCII
- * (i.e. as defined in ANSI_X3.4-1968), which contains only 7-bit characters.
- * Glib::ustring can @em not be used with ASCII-compatible extended 8-bit
- * charsets like ISO-8859-1. It's a good idea to avoid string literals
- * containing non-ASCII characters (e.g. German umlauts) in source code,
- * or at least you should use UTF-8 literals.
- * @par
- * You can find a detailed UTF-8 and %Unicode FAQ here:
- * http://www.cl.cam.ac.uk/~mgk25/unicode.html
- *
- * @par Glib::ustring vs. std::string
- * @par
- * Glib::ustring has implicit type conversions to and from std::string.
- * These conversions do @em not convert to/from the current locale (see
- * Glib::locale_from_utf8() and Glib::locale_to_utf8() if you need that). You
- * can always use std::string instead of Glib::ustring -- however, using
- * std::string with multi-byte characters is quite hard. For instance,
- * <tt>std::string::operator[]</tt> might return a byte in the middle of a
- * character, and <tt>std::string::length()</tt> returns the number of bytes
- * rather than characters. So don't do that without a good reason.
- * @par
- * In a perfect world the C++ Standard Library would contain a UTF-8 string
- * class. Unfortunately, the C++ standard doesn't mention UTF-8 at all. Note
- * that std::wstring is not a UTF-8 string class because it contains only
- * fixed-width characters (where width could be 32, 16, or even 8 bits).
- *
- * @par Glib::ustring and stream input/output
- * @par
- * The stream I/O operators, that is operator<<() and operator>>(), perform
- * implicit charset conversion to/from the current locale. If that's not
- * what you intented (e.g. when writing to a configuration file that should
- * always be UTF-8 encoded) use ustring::raw() to override this behaviour.
- * @par
- * If you're using std::ostringstream to build strings for display in the
- * user interface, you must convert the result back to UTF-8 as shown below:
- * @code
- * std::ostringstream output;
- * output.imbue(std::locale("")); // use the user's locale for this stream
- * output << percentage << " % done";
- * label->set_text(Glib::locale_to_utf8(output.str()));
- * @endcode
- *
- * @par Formatted output and internationalization
- * @par
- * The methods ustring::compose() and ustring::format() provide a convenient
- * and powerful alternative to string streams, as shown in the example below.
- * Refer to the method documentation of compose() and format() for details.
- * @code
- * using Glib::ustring;
- *
- * ustring message = ustring::compose("%1 is lower than 0x%2.",
- * 12, ustring::format(std::hex, 16));
- * @endcode
- *
- * @par Implementation notes
- * @par
- * Glib::ustring does not inherit from std::string, because std::string was
- * intended to be a final class. For instance, it does not have a virtual
- * destructor. Also, a HAS-A relationship is more appropriate because
- * ustring can't just enhance the std::string interface. Rather, it has to
- * reimplement the interface so that all operations are based on characters
- * instead of bytes.
- */
-class ustring
-{
-public:
- typedef std::string::size_type size_type;
- typedef std::string::difference_type difference_type;
-
- typedef gunichar value_type;
- typedef gunichar & reference;
- typedef const gunichar & const_reference;
-
- typedef ustring_Iterator<std::string::iterator> iterator;
- typedef ustring_Iterator<std::string::const_iterator> const_iterator;
-
-#ifndef GLIBMM_HAVE_SUN_REVERSE_ITERATOR
-
- typedef std::reverse_iterator<iterator> reverse_iterator;
- typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
-
-#else
-
- typedef std::reverse_iterator<iterator,
- iterator::iterator_category,
- iterator::value_type,
- iterator::reference,
- iterator::pointer,
- iterator::difference_type> reverse_iterator;
- typedef std::reverse_iterator<const_iterator,
- const_iterator::iterator_category,
- const_iterator::value_type,
- const_iterator::reference,
- const_iterator::pointer,
- const_iterator::difference_type> const_reverse_iterator;
-
-#endif /* GLIBMM_HAVE_SUN_REVERSE_ITERATOR */
-
-#ifdef GLIBMM_HAVE_ALLOWS_STATIC_INLINE_NPOS
- static GLIBMM_API const size_type npos = std::string::npos;
-#else
- //The IRIX MipsPro compiler says "The indicated constant value is not known",
- //so we need to initalize the static member data elsewhere.
- static GLIBMM_API const size_type npos;
-#endif
-
- /*! Default constructor, which creates an empty string.
- */
- ustring();
-
- ~ustring();
-
- /*! Construct a ustring as a copy of another ustring.
- * @param other A source string.
- */
- ustring(const ustring& other);
-
- /*! Assign the value of another string to this string.
- * @param other A source string.
- */
- ustring& operator=(const ustring& other);
-
- /*! Swap contents with another string.
- * @param other String to swap with.
- */
- void swap(ustring& other);
-
- /*! Construct a ustring as a copy of another std::string.
- * @param src A source <tt>std::string</tt> containing text encoded as UTF-8.
- */
- ustring(const std::string& src);
-
- /*! Construct a ustring as a copy of a substring.
- * @param src %Source ustring.
- * @param i Index of first character to copy from.
- * @param n Number of UTF-8 characters to copy (defaults to copying the remainder).
- */
- ustring(const ustring& src, size_type i, size_type n=npos);
-
- /*! Construct a ustring as a partial copy of a C string.
- * @param src %Source C string encoded as UTF-8.
- * @param n Number of UTF-8 characters to copy.
- */
- ustring(const char* src, size_type n);
-
- /*! Construct a ustring as a copy of a C string.
- * @param src %Source C string encoded as UTF-8.
- */
- ustring(const char* src);
-
- /*! Construct a ustring as multiple characters.
- * @param n Number of characters.
- * @param uc UCS-4 code point to use.
- */
- ustring(size_type n, gunichar uc);
-
- /*! Construct a ustring as multiple characters.
- * @param n Number of characters.
- * @param c ASCII character to use.
- */
- ustring(size_type n, char c);
-
- /*! Construct a ustring as a copy of a range.
- * @param pbegin Start of range.
- * @param pend End of range.
- */
- template <class In> ustring(In pbegin, In pend);
-
-
-//! @name Assign new contents.
-//! @{
-
- ustring& operator=(const std::string& src);
- ustring& operator=(const char* src);
- ustring& operator=(gunichar uc);
- ustring& operator=(char c);
-
- ustring& assign(const ustring& src);
- ustring& assign(const ustring& src, size_type i, size_type n);
- ustring& assign(const char* src, size_type n);
- ustring& assign(const char* src);
- ustring& assign(size_type n, gunichar uc);
- ustring& assign(size_type n, char c);
- template <class In> ustring& assign(In pbegin, In pend);
-
-//! @}
-//! @name Append to the string.
-//! @{
-
- ustring& operator+=(const ustring& src);
- ustring& operator+=(const char* src);
- ustring& operator+=(gunichar uc);
- ustring& operator+=(char c);
- void push_back(gunichar uc);
- void push_back(char c);
-
- ustring& append(const ustring& src);
- ustring& append(const ustring& src, size_type i, size_type n);
- ustring& append(const char* src, size_type n);
- ustring& append(const char* src);
- ustring& append(size_type n, gunichar uc);
- ustring& append(size_type n, char c);
- template <class In> ustring& append(In pbegin, In pend);
-
-//! @}
-//! @name Insert into the string.
-//! @{
-
- ustring& insert(size_type i, const ustring& src);
- ustring& insert(size_type i, const ustring& src, size_type i2, size_type n);
- ustring& insert(size_type i, const char* src, size_type n);
- ustring& insert(size_type i, const char* src);
- ustring& insert(size_type i, size_type n, gunichar uc);
- ustring& insert(size_type i, size_type n, char c);
-
- iterator insert(iterator p, gunichar uc);
- iterator insert(iterator p, char c);
- void insert(iterator p, size_type n, gunichar uc);
- void insert(iterator p, size_type n, char c);
- template <class In> void insert(iterator p, In pbegin, In pend);
-
-//! @}
-//! @name Replace sub-strings.
-//! @{
-
- ustring& replace(size_type i, size_type n, const ustring& src);
- ustring& replace(size_type i, size_type n, const ustring& src, size_type i2, size_type n2);
- ustring& replace(size_type i, size_type n, const char* src, size_type n2);
- ustring& replace(size_type i, size_type n, const char* src);
- ustring& replace(size_type i, size_type n, size_type n2, gunichar uc);
- ustring& replace(size_type i, size_type n, size_type n2, char c);
-
- ustring& replace(iterator pbegin, iterator pend, const ustring& src);
- ustring& replace(iterator pbegin, iterator pend, const char* src, size_type n);
- ustring& replace(iterator pbegin, iterator pend, const char* src);
- ustring& replace(iterator pbegin, iterator pend, size_type n, gunichar uc);
- ustring& replace(iterator pbegin, iterator pend, size_type n, char c);
- template <class In> ustring& replace(iterator pbegin, iterator pend, In pbegin2, In pend2);
-
-//! @}
-//! @name Erase sub-strings.
-//! @{
-
- void clear();
- ustring& erase(size_type i, size_type n=npos);
- ustring& erase();
- iterator erase(iterator p);
- iterator erase(iterator pbegin, iterator pend);
-
-//! @}
-//! @name Compare and collate.
-//! @{
-
- int compare(const ustring& rhs) const;
- int compare(const char* rhs) const;
- int compare(size_type i, size_type n, const ustring& rhs) const;
- int compare(size_type i, size_type n, const ustring& rhs, size_type i2, size_type n2) const;
- int compare(size_type i, size_type n, const char* rhs, size_type n2) const;
- int compare(size_type i, size_type n, const char* rhs) const;
-
- /*! Create a unique sorting key for the UTF-8 string. If you need to
- * compare UTF-8 strings regularly, e.g. for sorted containers such as
- * <tt>std::set<></tt>, you should consider creating a collate key first
- * and compare this key instead of the actual string.
- *
- * The ustring::compare() methods as well as the relational operators
- * <tt>== != < > <= >=</tt> are quite costly
- * because they have to deal with %Unicode and the collation rules defined by
- * the current locale. Converting both operands to UCS-4 is just the first
- * of several costly steps involved when comparing ustrings. So be careful.
- */
- std::string collate_key() const;
-
- /*! Create a unique key for the UTF-8 string that can be used for caseless
- * sorting. <tt>ustr.casefold_collate_key()</tt> results in the same string
- * as <tt>ustr.casefold().collate_key()</tt>, but the former is likely more
- * efficient.
- */
- std::string casefold_collate_key() const;
-
-//! @}
-//! @name Extract characters and sub-strings.
-//! @{
-
- /*! No reference return; use replace() to write characters. */
- value_type operator[](size_type i) const;
-
- /*! No reference return; use replace() to write characters. @throw std::out_of_range */
- value_type at(size_type i) const;
-
- inline ustring substr(size_type i=0, size_type n=npos) const;
-
-//! @}
-//! @name Access a sequence of characters.
-//! @{
-
- iterator begin();
- iterator end();
- const_iterator begin() const;
- const_iterator end() const;
- reverse_iterator rbegin();
- reverse_iterator rend();
- const_reverse_iterator rbegin() const;
- const_reverse_iterator rend() const;
-
-//! @}
-//! @name Find sub-strings.
-//! @{
-
- size_type find(const ustring& str, size_type i=0) const;
- size_type find(const char* str, size_type i, size_type n) const;
- size_type find(const char* str, size_type i=0) const;
- size_type find(gunichar uc, size_type i=0) const;
- size_type find(char c, size_type i=0) const;
-
- size_type rfind(const ustring& str, size_type i=npos) const;
- size_type rfind(const char* str, size_type i, size_type n) const;
- size_type rfind(const char* str, size_type i=npos) const;
- size_type rfind(gunichar uc, size_type i=npos) const;
- size_type rfind(char c, size_type i=npos) const;
-
-//! @}
-//! @name Match against a set of characters.
-//! @{
-
- size_type find_first_of(const ustring& match, size_type i=0) const;
- size_type find_first_of(const char* match, size_type i, size_type n) const;
- size_type find_first_of(const char* match, size_type i=0) const;
- size_type find_first_of(gunichar uc, size_type i=0) const;
- size_type find_first_of(char c, size_type i=0) const;
-
- size_type find_last_of(const ustring& match, size_type i=npos) const;
- size_type find_last_of(const char* match, size_type i, size_type n) const;
- size_type find_last_of(const char* match, size_type i=npos) const;
- size_type find_last_of(gunichar uc, size_type i=npos) const;
- size_type find_last_of(char c, size_type i=npos) const;
-
- size_type find_first_not_of(const ustring& match, size_type i=0) const;
- size_type find_first_not_of(const char* match, size_type i, size_type n) const;
- size_type find_first_not_of(const char* match, size_type i=0) const;
- size_type find_first_not_of(gunichar uc, size_type i=0) const;
- size_type find_first_not_of(char c, size_type i=0) const;
-
- size_type find_last_not_of(const ustring& match, size_type i=npos) const;
- size_type find_last_not_of(const char* match, size_type i, size_type n) const;
- size_type find_last_not_of(const char* match, size_type i=npos) const;
- size_type find_last_not_of(gunichar uc, size_type i=npos) const;
- size_type find_last_not_of(char c, size_type i=npos) const;
-
-//! @}
-//! @name Retrieve the string's size.
-//! @{
-
- /** Returns true if the string is empty. Equivalent to *this == "".
- * @result Whether the string is empty.
- */
- bool empty() const;
-
- /** Returns the number of characters in the string, not including any null-termination.
- * @result T...
[truncated message content] |
|
From: <tbr...@us...> - 2012-03-20 13:49:17
|
Revision: 203
http://xmlwrapp.svn.sourceforge.net/xmlwrapp/?rev=203&view=rev
Author: tbrowder2
Date: 2012-03-20 13:49:06 +0000 (Tue, 20 Mar 2012)
Log Message:
-----------
add ignores
Added Paths:
-----------
trunk/.svnignore
Property Changed:
----------------
trunk/
Property changes on: trunk
___________________________________________________________________
Modified: svn:ignore
- Makefile
Makefile.in
xmlwrapp-config
xmlwrapp.pc
xsltwrapp.pc
config.log
config.status
stamp-h1
libtool
configure
autom4te.cache
aclocal.m4
+
Added: trunk/.svnignore
===================================================================
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tbr...@us...> - 2012-03-20 13:48:38
|
Revision: 202
http://xmlwrapp.svn.sourceforge.net/xmlwrapp/?rev=202&view=rev
Author: tbrowder2
Date: 2012-03-20 13:48:32 +0000 (Tue, 20 Mar 2012)
Log Message:
-----------
add generic INSTALL file for autotools
Added Paths:
-----------
trunk/INSTALL
Added: trunk/INSTALL
===================================================================
--- trunk/INSTALL (rev 0)
+++ trunk/INSTALL 2012-03-20 13:48:32 UTC (rev 202)
@@ -0,0 +1,365 @@
+Installation Instructions
+*************************
+
+Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005,
+2006, 2007, 2008, 2009 Free Software Foundation, Inc.
+
+ Copying and distribution of this file, with or without modification,
+are permitted in any medium without royalty provided the copyright
+notice and this notice are preserved. This file is offered as-is,
+without warranty of any kind.
+
+Basic Installation
+==================
+
+ Briefly, the shell commands `./configure; make; make install' should
+configure, build, and install this package. The following
+more-detailed instructions are generic; see the `README' file for
+instructions specific to this package. Some packages provide this
+`INSTALL' file but do not implement all of the features documented
+below. The lack of an optional feature in a given package is not
+necessarily a bug. More recommendations for GNU packages can be found
+in *note Makefile Conventions: (standards)Makefile Conventions.
+
+ The `configure' shell script attempts to guess correct values for
+various system-dependent variables used during compilation. It uses
+those values to create a `Makefile' in each directory of the package.
+It may also create one or more `.h' files containing system-dependent
+definitions. Finally, it creates a shell script `config.status' that
+you can run in the future to recreate the current configuration, and a
+file `config.log' containing compiler output (useful mainly for
+debugging `configure').
+
+ It can also use an optional file (typically called `config.cache'
+and enabled with `--cache-file=config.cache' or simply `-C') that saves
+the results of its tests to speed up reconfiguring. Caching is
+disabled by default to prevent problems with accidental use of stale
+cache files.
+
+ If you need to do unusual things to compile the package, please try
+to figure out how `configure' could check whether to do them, and mail
+diffs or instructions to the address given in the `README' so they can
+be considered for the next release. If you are using the cache, and at
+some point `config.cache' contains results you don't want to keep, you
+may remove or edit it.
+
+ The file `configure.ac' (or `configure.in') is used to create
+`configure' by a program called `autoconf'. You need `configure.ac' if
+you want to change it or regenerate `configure' using a newer version
+of `autoconf'.
+
+ The simplest way to compile this package is:
+
+ 1. `cd' to the directory containing the package's source code and type
+ `./configure' to configure the package for your system.
+
+ Running `configure' might take a while. While running, it prints
+ some messages telling which features it is checking for.
+
+ 2. Type `make' to compile the package.
+
+ 3. Optionally, type `make check' to run any self-tests that come with
+ the package, generally using the just-built uninstalled binaries.
+
+ 4. Type `make install' to install the programs and any data files and
+ documentation. When installing into a prefix owned by root, it is
+ recommended that the package be configured and built as a regular
+ user, and only the `make install' phase executed with root
+ privileges.
+
+ 5. Optionally, type `make installcheck' to repeat any self-tests, but
+ this time using the binaries in their final installed location.
+ This target does not install anything. Running this target as a
+ regular user, particularly if the prior `make install' required
+ root privileges, verifies that the installation completed
+ correctly.
+
+ 6. You can remove the program binaries and object files from the
+ source code directory by typing `make clean'. To also remove the
+ files that `configure' created (so you can compile the package for
+ a different kind of computer), type `make distclean'. There is
+ also a `make maintainer-clean' target, but that is intended mainly
+ for the package's developers. If you use it, you may have to get
+ all sorts of other programs in order to regenerate files that came
+ with the distribution.
+
+ 7. Often, you can also type `make uninstall' to remove the installed
+ files again. In practice, not all packages have tested that
+ uninstallation works correctly, even though it is required by the
+ GNU Coding Standards.
+
+ 8. Some packages, particularly those that use Automake, provide `make
+ distcheck', which can by used by developers to test that all other
+ targets like `make install' and `make uninstall' work correctly.
+ This target is generally not run by end users.
+
+Compilers and Options
+=====================
+
+ Some systems require unusual options for compilation or linking that
+the `configure' script does not know about. Run `./configure --help'
+for details on some of the pertinent environment variables.
+
+ You can give `configure' initial values for configuration parameters
+by setting variables in the command line or in the environment. Here
+is an example:
+
+ ./configure CC=c99 CFLAGS=-g LIBS=-lposix
+
+ *Note Defining Variables::, for more details.
+
+Compiling For Multiple Architectures
+====================================
+
+ You can compile the package for more than one kind of computer at the
+same time, by placing the object files for each architecture in their
+own directory. To do this, you can use GNU `make'. `cd' to the
+directory where you want the object files and executables to go and run
+the `configure' script. `configure' automatically checks for the
+source code in the directory that `configure' is in and in `..'. This
+is known as a "VPATH" build.
+
+ With a non-GNU `make', it is safer to compile the package for one
+architecture at a time in the source code directory. After you have
+installed the package for one architecture, use `make distclean' before
+reconfiguring for another architecture.
+
+ On MacOS X 10.5 and later systems, you can create libraries and
+executables that work on multiple system types--known as "fat" or
+"universal" binaries--by specifying multiple `-arch' options to the
+compiler but only a single `-arch' option to the preprocessor. Like
+this:
+
+ ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
+ CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
+ CPP="gcc -E" CXXCPP="g++ -E"
+
+ This is not guaranteed to produce working output in all cases, you
+may have to build one architecture at a time and combine the results
+using the `lipo' tool if you have problems.
+
+Installation Names
+==================
+
+ By default, `make install' installs the package's commands under
+`/usr/local/bin', include files under `/usr/local/include', etc. You
+can specify an installation prefix other than `/usr/local' by giving
+`configure' the option `--prefix=PREFIX', where PREFIX must be an
+absolute file name.
+
+ You can specify separate installation prefixes for
+architecture-specific files and architecture-independent files. If you
+pass the option `--exec-prefix=PREFIX' to `configure', the package uses
+PREFIX as the prefix for installing programs and libraries.
+Documentation and other data files still use the regular prefix.
+
+ In addition, if you use an unusual directory layout you can give
+options like `--bindir=DIR' to specify different values for particular
+kinds of files. Run `configure --help' for a list of the directories
+you can set and what kinds of files go in them. In general, the
+default for these options is expressed in terms of `${prefix}', so that
+specifying just `--prefix' will affect all of the other directory
+specifications that were not explicitly provided.
+
+ The most portable way to affect installation locations is to pass the
+correct locations to `configure'; however, many packages provide one or
+both of the following shortcuts of passing variable assignments to the
+`make install' command line to change installation locations without
+having to reconfigure or recompile.
+
+ The first method involves providing an override variable for each
+affected directory. For example, `make install
+prefix=/alternate/directory' will choose an alternate location for all
+directory configuration variables that were expressed in terms of
+`${prefix}'. Any directories that were specified during `configure',
+but not in terms of `${prefix}', must each be overridden at install
+time for the entire installation to be relocated. The approach of
+makefile variable overrides for each directory variable is required by
+the GNU Coding Standards, and ideally causes no recompilation.
+However, some platforms have known limitations with the semantics of
+shared libraries that end up requiring recompilation when using this
+method, particularly noticeable in packages that use GNU Libtool.
+
+ The second method involves providing the `DESTDIR' variable. For
+example, `make install DESTDIR=/alternate/directory' will prepend
+`/alternate/directory' before all installation names. The approach of
+`DESTDIR' overrides is not required by the GNU Coding Standards, and
+does not work on platforms that have drive letters. On the other hand,
+it does better at avoiding recompilation issues, and works well even
+when some directory options were not specified in terms of `${prefix}'
+at `configure' time.
+
+Optional Features
+=================
+
+ If the package supports it, you can cause programs to be installed
+with an extra prefix or suffix on their names by giving `configure' the
+option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
+
+ Some packages pay attention to `--enable-FEATURE' options to
+`configure', where FEATURE indicates an optional part of the package.
+They may also pay attention to `--with-PACKAGE' options, where PACKAGE
+is something like `gnu-as' or `x' (for the X Window System). The
+`README' should mention any `--enable-' and `--with-' options that the
+package recognizes.
+
+ For packages that use the X Window System, `configure' can usually
+find the X include and library files automatically, but if it doesn't,
+you can use the `configure' options `--x-includes=DIR' and
+`--x-libraries=DIR' to specify their locations.
+
+ Some packages offer the ability to configure how verbose the
+execution of `make' will be. For these packages, running `./configure
+--enable-silent-rules' sets the default to minimal output, which can be
+overridden with `make V=1'; while running `./configure
+--disable-silent-rules' sets the default to verbose, which can be
+overridden with `make V=0'.
+
+Particular systems
+==================
+
+ On HP-UX, the default C compiler is not ANSI C compatible. If GNU
+CC is not installed, it is recommended to use the following options in
+order to use an ANSI C compiler:
+
+ ./configure CC="cc -Ae -D_XOPEN_SOURCE=500"
+
+and if that doesn't work, install pre-built binaries of GCC for HP-UX.
+
+ On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot
+parse its `<wchar.h>' header file. The option `-nodtk' can be used as
+a workaround. If GNU CC is not installed, it is therefore recommended
+to try
+
+ ./configure CC="cc"
+
+and if that doesn't work, try
+
+ ./configure CC="cc -nodtk"
+
+ On Solaris, don't put `/usr/ucb' early in your `PATH'. This
+directory contains several dysfunctional programs; working variants of
+these programs are available in `/usr/bin'. So, if you need `/usr/ucb'
+in your `PATH', put it _after_ `/usr/bin'.
+
+ On Haiku, software installed for all users goes in `/boot/common',
+not `/usr/local'. It is recommended to use the following options:
+
+ ./configure --prefix=/boot/common
+
+Specifying the System Type
+==========================
+
+ There may be some features `configure' cannot figure out
+automatically, but needs to determine by the type of machine the package
+will run on. Usually, assuming the package is built to be run on the
+_same_ architectures, `configure' can figure that out, but if it prints
+a message saying it cannot guess the machine type, give it the
+`--build=TYPE' option. TYPE can either be a short name for the system
+type, such as `sun4', or a canonical name which has the form:
+
+ CPU-COMPANY-SYSTEM
+
+where SYSTEM can have one of these forms:
+
+ OS
+ KERNEL-OS
+
+ See the file `config.sub' for the possible values of each field. If
+`config.sub' isn't included in this package, then this package doesn't
+need to know the machine type.
+
+ If you are _building_ compiler tools for cross-compiling, you should
+use the option `--target=TYPE' to select the type of system they will
+produce code for.
+
+ If you want to _use_ a cross compiler, that generates code for a
+platform different from the build platform, you should specify the
+"host" platform (i.e., that on which the generated programs will
+eventually be run) with `--host=TYPE'.
+
+Sharing Defaults
+================
+
+ If you want to set default values for `configure' scripts to share,
+you can create a site shell script called `config.site' that gives
+default values for variables like `CC', `cache_file', and `prefix'.
+`configure' looks for `PREFIX/share/config.site' if it exists, then
+`PREFIX/etc/config.site' if it exists. Or, you can set the
+`CONFIG_SITE' environment variable to the location of the site script.
+A warning: not all `configure' scripts look for a site script.
+
+Defining Variables
+==================
+
+ Variables not defined in a site shell script can be set in the
+environment passed to `configure'. However, some packages may run
+configure again during the build, and the customized values of these
+variables may be lost. In order to avoid this problem, you should set
+them in the `configure' command line, using `VAR=value'. For example:
+
+ ./configure CC=/usr/local2/bin/gcc
+
+causes the specified `gcc' to be used as the C compiler (unless it is
+overridden in the site shell script).
+
+Unfortunately, this technique does not work for `CONFIG_SHELL' due to
+an Autoconf bug. Until the bug is fixed you can use this workaround:
+
+ CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash
+
+`configure' Invocation
+======================
+
+ `configure' recognizes the following options to control how it
+operates.
+
+`--help'
+`-h'
+ Print a summary of all of the options to `configure', and exit.
+
+`--help=short'
+`--help=recursive'
+ Print a summary of the options unique to this package's
+ `configure', and exit. The `short' variant lists options used
+ only in the top level, while the `recursive' variant lists options
+ also present in any nested packages.
+
+`--version'
+`-V'
+ Print the version of Autoconf used to generate the `configure'
+ script, and exit.
+
+`--cache-file=FILE'
+ Enable the cache: use and save the results of the tests in FILE,
+ traditionally `config.cache'. FILE defaults to `/dev/null' to
+ disable caching.
+
+`--config-cache'
+`-C'
+ Alias for `--cache-file=config.cache'.
+
+`--quiet'
+`--silent'
+`-q'
+ Do not print messages saying which checks are being made. To
+ suppress all normal output, redirect it to `/dev/null' (any error
+ messages will still be shown).
+
+`--srcdir=DIR'
+ Look for the package's source code in directory DIR. Usually
+ `configure' can determine that directory automatically.
+
+`--prefix=DIR'
+ Use DIR as the installation prefix. *note Installation Names::
+ for more details, including other options available for fine-tuning
+ the installation locations.
+
+`--no-create'
+`-n'
+ Run the configure checks, but stop before creating any output
+ files.
+
+`configure' also accepts some other, not widely useful, options. Run
+`configure --help' for more details.
+
Property changes on: trunk/INSTALL
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:eol-style
+ native
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tbr...@us...> - 2012-03-20 13:48:04
|
Revision: 201
http://xmlwrapp.svn.sourceforge.net/xmlwrapp/?rev=201&view=rev
Author: tbrowder2
Date: 2012-03-20 13:47:53 +0000 (Tue, 20 Mar 2012)
Log Message:
-----------
add ustring tests from the glibmm project
Modified Paths:
--------------
trunk/tests/Makefile.am
Added Paths:
-----------
trunk/tests/ustring/
trunk/tests/ustring/test_ustring_compose.cc
trunk/tests/ustring/test_ustring_format.cc
Modified: trunk/tests/Makefile.am
===================================================================
--- trunk/tests/Makefile.am 2012-03-20 13:35:13 UTC (rev 200)
+++ trunk/tests/Makefile.am 2012-03-20 13:47:53 UTC (rev 201)
@@ -2,9 +2,10 @@
TESTS = test
AM_CPPFLAGS = -I$(top_srcdir)/include
-LIBS = $(top_builddir)/src/libxmlwrapp.la \
- $(BOOST_UNIT_TEST_FRAMEWORK_LIBS) $(BOOST_UNIT_TEST_FRAMEWORK_LDFLAGS) \
- $(BOOST_IOSTREAMS_LIBS) $(BOOST_IOSTREAMS_LDFLAGS)
+LIBS = $(top_builddir)/src/libxmlwrapp.la \
+ $(top_builddir)/src/libustring.la \
+ $(BOOST_UNIT_TEST_FRAMEWORK_LIBS) $(BOOST_UNIT_TEST_FRAMEWORK_LDFLAGS) \
+ $(BOOST_IOSTREAMS_LIBS) $(BOOST_IOSTREAMS_LDFLAGS)
noinst_PROGRAMS = test
@@ -15,7 +16,9 @@
document/test_document.cc \
event/test_event.cc \
node/test_node.cc \
- tree/test_tree.cc
+ tree/test_tree.cc \
+ ustring/test_ustring_compose.cc \
+ ustring/test_ustring_format.cc \
if WITH_XSLT
LIBS += $(top_builddir)/src/libxsltwrapp.la
Added: trunk/tests/ustring/test_ustring_compose.cc
===================================================================
--- trunk/tests/ustring/test_ustring_compose.cc (rev 0)
+++ trunk/tests/ustring/test_ustring_compose.cc 2012-03-20 13:47:53 UTC (rev 201)
@@ -0,0 +1,36 @@
+#include <glibmm.h>
+
+#include <iostream>
+
+//Use this line if you want debug output:
+//std::ostream& ostr = std::cout;
+
+//This seems nicer and more useful than putting an ifdef around the use of ostr:
+std::stringstream debug;
+std::ostream& ostr = debug;
+
+int main(int, char**)
+{
+ Glib::init();
+
+ //TODO: Check the output?
+ const char *constant_string = "constant string";
+ ostr << Glib::ustring::compose("Compose strings: %1", constant_string) << std::endl;
+ ostr << Glib::ustring::compose("Compose strings: %1 and %2", constant_string, "string_literal") << std::endl;
+
+ ostr << Glib::ustring::compose("Compose strings: %1 and %2", 123, 123.4567) << std::endl;
+
+ ostr << Glib::ustring::compose("Compose strings: %1 and %2", (int)123, (float)123.4567) << std::endl;
+
+ ostr << Glib::ustring::compose("Compose strings: %1 and %2", Glib::ustring("foo"), std::string("goo")) << std::endl;
+
+ int i = 1;
+ ostr << Glib::ustring::compose("Compose strings: %1 and %2", 'f', &i) << std::endl;
+
+ ostr << Glib::ustring::compose("%1 is lower than 0x%2.", 12, Glib::ustring::format(std::hex, 16)) << std::endl;
+
+ //TODO: More tests.
+
+ return EXIT_SUCCESS;
+}
+
Property changes on: trunk/tests/ustring/test_ustring_compose.cc
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:eol-style
+ native
Added: trunk/tests/ustring/test_ustring_format.cc
===================================================================
--- trunk/tests/ustring/test_ustring_format.cc (rev 0)
+++ trunk/tests/ustring/test_ustring_format.cc 2012-03-20 13:47:53 UTC (rev 201)
@@ -0,0 +1,30 @@
+#include <glibmm.h>
+
+#include <iostream>
+
+int main(int, char**)
+{
+ Glib::init();
+
+ char carr[10] = "Užduotys";
+ char * const cptr = carr;
+
+ /*
+ std::wostringstream wsout;
+ wsout << carr;
+ const std::wstring& wstr = wsout.str();
+ const gunichar * const data = reinterpret_cast<const gunichar *>(
+ wstr.data());
+
+ for(int i = 0; wstr.size() > i; ++i)
+ std::cout << data[i] << std::endl;
+ */
+
+ //Check both the const char* and char* versions.
+ Glib::ustring::format(carr);
+
+ //This threw an exception before we added a ustring::FormatStream::stream(char*) overload.
+ Glib::ustring::format(cptr);
+
+ return EXIT_SUCCESS;
+}
Property changes on: trunk/tests/ustring/test_ustring_format.cc
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:eol-style
+ native
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|