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 13:35:22
|
Revision: 200 http://xmlwrapp.svn.sourceforge.net/xmlwrapp/?rev=200&view=rev Author: tbrowder2 Date: 2012-03-20 13:35:13 +0000 (Tue, 20 Mar 2012) Log Message: ----------- add ustring source from glibmm project Modified Paths: -------------- trunk/src/Makefile.am Added Paths: ----------- trunk/src/libustring/ trunk/src/libustring/ustring.cc trunk/src/libustring/ustring.h Modified: trunk/src/Makefile.am =================================================================== --- trunk/src/Makefile.am 2012-03-20 13:21:45 UTC (rev 199) +++ trunk/src/Makefile.am 2012-03-20 13:35:13 UTC (rev 200) @@ -2,16 +2,24 @@ AM_CPPFLAGS = -I$(top_srcdir)/include $(CXXFLAGS_VISIBILITY) if WITH_XSLT -lib_LTLIBRARIES = libxmlwrapp.la libxsltwrapp.la +lib_LTLIBRARIES = libxmlwrapp.la libxsltwrapp.la libustring.la else -lib_LTLIBRARIES = libxmlwrapp.la +lib_LTLIBRARIES = libxmlwrapp.la libustring.la endif +libustring_la_CPPFLAGS = $(AM_CPPFLAGS) $(LIBXML_CFLAGS) +libustring_la_LIBADD = $(LIBXML_LIBS) +libustring_la_LDFLAGS = -version-info 6:0:1 -no-undefined + +libustring_la_SOURCES = \ + libustring/ustring.cc \ + libustring/ustring.h \ + libxmlwrapp_la_CPPFLAGS = $(AM_CPPFLAGS) $(LIBXML_CFLAGS) -libxmlwrapp_la_LIBADD = $(LIBXML_LIBS) -libxmlwrapp_la_LDFLAGS = -version-info 6:0:1 -no-undefined +libxmlwrapp_la_LIBADD = $(LIBXML_LIBS) +libxmlwrapp_la_LDFLAGS = -version-info 6:0:1 -no-undefined -libxmlwrapp_la_SOURCES = \ +libxmlwrapp_la_SOURCES = \ libxml/ait_impl.cc \ libxml/ait_impl.h \ libxml/attributes.cc \ Added: trunk/src/libustring/ustring.cc =================================================================== --- trunk/src/libustring/ustring.cc (rev 0) +++ trunk/src/libustring/ustring.cc 2012-03-20 13:35:13 UTC (rev 200) @@ -0,0 +1,1418 @@ +// -*- 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 Property changes on: trunk/src/libustring/ustring.cc ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Added: trunk/src/libustring/ustring.h =================================================================== --- trunk/src/libustring/ustring.h (rev 0) +++ trunk/src/libustring/ustring.h 2012-03-20 13:35:13 UTC (rev 200) @@ -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 ustri... [truncated message content] |
From: <tbr...@us...> - 2012-03-20 13:21:58
|
Revision: 199 http://xmlwrapp.svn.sourceforge.net/xmlwrapp/?rev=199&view=rev Author: tbrowder2 Date: 2012-03-20 13:21:45 +0000 (Tue, 20 Mar 2012) Log Message: ----------- delete unneeded file Removed Paths: ------------- trunk/misc/libtool.m4 Deleted: trunk/misc/libtool.m4 =================================================================== --- trunk/misc/libtool.m4 2012-03-20 01:53:04 UTC (rev 198) +++ trunk/misc/libtool.m4 2012-03-20 13:21:45 UTC (rev 199) @@ -1,6000 +0,0 @@ -# libtool.m4 - Configure libtool for the host system. -*-Autoconf-*- -## Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004 -## Free Software Foundation, Inc. -## Originally by Gordon Matzigkeit <go...@gn...>, 1996 -## -## This program is free software; you can redistribute it and/or modify -## it under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 2 of the License, or -## (at your option) any later version. -## -## This program 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 -## General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with this program; if not, write to the Free Software -## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -## -## As a special exception to the GNU General Public License, if you -## distribute this file as part of a program that contains a -## configuration script generated by Autoconf, you may include it under -## the same distribution terms that you use for the rest of that program. - -# serial 47 AC_PROG_LIBTOOL - - -# AC_PROVIDE_IFELSE(MACRO-NAME, IF-PROVIDED, IF-NOT-PROVIDED) -# ----------------------------------------------------------- -# If this macro is not defined by Autoconf, define it here. -m4_ifdef([AC_PROVIDE_IFELSE], - [], - [m4_define([AC_PROVIDE_IFELSE], - [m4_ifdef([AC_PROVIDE_$1], - [$2], [$3])])]) - - -# AC_PROG_LIBTOOL -# --------------- -AC_DEFUN([AC_PROG_LIBTOOL], -[AC_REQUIRE([_AC_PROG_LIBTOOL])dnl -dnl If AC_PROG_CXX has already been expanded, run AC_LIBTOOL_CXX -dnl immediately, otherwise, hook it in at the end of AC_PROG_CXX. - AC_PROVIDE_IFELSE([AC_PROG_CXX], - [AC_LIBTOOL_CXX], - [define([AC_PROG_CXX], defn([AC_PROG_CXX])[AC_LIBTOOL_CXX - ])]) -dnl And a similar setup for Fortran 77 support - AC_PROVIDE_IFELSE([AC_PROG_F77], - [AC_LIBTOOL_F77], - [define([AC_PROG_F77], defn([AC_PROG_F77])[AC_LIBTOOL_F77 -])]) - -dnl Quote A][M_PROG_GCJ so that aclocal doesn't bring it in needlessly. -dnl If either AC_PROG_GCJ or A][M_PROG_GCJ have already been expanded, run -dnl AC_LIBTOOL_GCJ immediately, otherwise, hook it in at the end of both. - AC_PROVIDE_IFELSE([AC_PROG_GCJ], - [AC_LIBTOOL_GCJ], - [AC_PROVIDE_IFELSE([A][M_PROG_GCJ], - [AC_LIBTOOL_GCJ], - [AC_PROVIDE_IFELSE([LT_AC_PROG_GCJ], - [AC_LIBTOOL_GCJ], - [ifdef([AC_PROG_GCJ], - [define([AC_PROG_GCJ], defn([AC_PROG_GCJ])[AC_LIBTOOL_GCJ])]) - ifdef([A][M_PROG_GCJ], - [define([A][M_PROG_GCJ], defn([A][M_PROG_GCJ])[AC_LIBTOOL_GCJ])]) - ifdef([LT_AC_PROG_GCJ], - [define([LT_AC_PROG_GCJ], - defn([LT_AC_PROG_GCJ])[AC_LIBTOOL_GCJ])])])]) -])])# AC_PROG_LIBTOOL - - -# _AC_PROG_LIBTOOL -# ---------------- -AC_DEFUN([_AC_PROG_LIBTOOL], -[AC_REQUIRE([AC_LIBTOOL_SETUP])dnl -AC_BEFORE([$0],[AC_LIBTOOL_CXX])dnl -AC_BEFORE([$0],[AC_LIBTOOL_F77])dnl -AC_BEFORE([$0],[AC_LIBTOOL_GCJ])dnl - -# This can be used to rebuild libtool when needed -LIBTOOL_DEPS="$ac_aux_dir/ltmain.sh" - -# Always use our own libtool. -LIBTOOL='$(SHELL) $(top_builddir)/libtool' -AC_SUBST(LIBTOOL)dnl - -# Prevent multiple expansion -define([AC_PROG_LIBTOOL], []) -])# _AC_PROG_LIBTOOL - - -# AC_LIBTOOL_SETUP -# ---------------- -AC_DEFUN([AC_LIBTOOL_SETUP], -[AC_PREREQ(2.50)dnl -AC_REQUIRE([AC_ENABLE_SHARED])dnl -AC_REQUIRE([AC_ENABLE_STATIC])dnl -AC_REQUIRE([AC_ENABLE_FAST_INSTALL])dnl -AC_REQUIRE([AC_CANONICAL_HOST])dnl -AC_REQUIRE([AC_CANONICAL_BUILD])dnl -AC_REQUIRE([AC_PROG_CC])dnl -AC_REQUIRE([AC_PROG_LD])dnl -AC_REQUIRE([AC_PROG_LD_RELOAD_FLAG])dnl -AC_REQUIRE([AC_PROG_NM])dnl - -AC_REQUIRE([AC_PROG_LN_S])dnl -AC_REQUIRE([AC_DEPLIBS_CHECK_METHOD])dnl -# Autoconf 2.13's AC_OBJEXT and AC_EXEEXT macros only works for C compilers! -AC_REQUIRE([AC_OBJEXT])dnl -AC_REQUIRE([AC_EXEEXT])dnl -dnl - -AC_LIBTOOL_SYS_MAX_CMD_LEN -AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE -AC_LIBTOOL_OBJDIR - -AC_REQUIRE([_LT_AC_SYS_COMPILER])dnl -_LT_AC_PROG_ECHO_BACKSLASH - -case $host_os in -aix3*) - # AIX sometimes has problems with the GCC collect2 program. For some - # reason, if we set the COLLECT_NAMES environment variable, the problems - # vanish in a puff of smoke. - if test "X${COLLECT_NAMES+set}" != Xset; then - COLLECT_NAMES= - export COLLECT_NAMES - fi - ;; -esac - -# Sed substitution that helps us do robust quoting. It backslashifies -# metacharacters that are still active within double-quoted strings. -Xsed='sed -e s/^X//' -[sed_quote_subst='s/\([\\"\\`$\\\\]\)/\\\1/g'] - -# Same as above, but do not quote variable references. -[double_quote_subst='s/\([\\"\\`\\\\]\)/\\\1/g'] - -# Sed substitution to delay expansion of an escaped shell variable in a -# double_quote_subst'ed string. -delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' - -# Sed substitution to avoid accidental globbing in evaled expressions -no_glob_subst='s/\*/\\\*/g' - -# Constants: -rm="rm -f" - -# Global variables: -default_ofile=libtool -can_build_shared=yes - -# All known linkers require a `.a' archive for static linking (except M$VC, -# which needs '.lib'). -libext=a -ltmain="$ac_aux_dir/ltmain.sh" -ofile="$default_ofile" -with_gnu_ld="$lt_cv_prog_gnu_ld" - -AC_CHECK_TOOL(AR, ar, false) -AC_CHECK_TOOL(RANLIB, ranlib, :) -AC_CHECK_TOOL(STRIP, strip, :) - -old_CC="$CC" -old_CFLAGS="$CFLAGS" - -# Set sane defaults for various variables -test -z "$AR" && AR=ar -test -z "$AR_FLAGS" && AR_FLAGS=cru -test -z "$AS" && AS=as -test -z "$CC" && CC=cc -test -z "$LTCC" && LTCC=$CC -test -z "$DLLTOOL" && DLLTOOL=dlltool -test -z "$LD" && LD=ld -test -z "$LN_S" && LN_S="ln -s" -test -z "$MAGIC_CMD" && MAGIC_CMD=file -test -z "$NM" && NM=nm -test -z "$SED" && SED=sed -test -z "$OBJDUMP" && OBJDUMP=objdump -test -z "$RANLIB" && RANLIB=: -test -z "$STRIP" && STRIP=: -test -z "$ac_objext" && ac_objext=o - -# Determine commands to create old-style static archives. -old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs$old_deplibs' -old_postinstall_cmds='chmod 644 $oldlib' -old_postuninstall_cmds= - -if test -n "$RANLIB"; then - case $host_os in - openbsd*) - old_postinstall_cmds="\$RANLIB -t \$oldlib~$old_postinstall_cmds" - ;; - *) - old_postinstall_cmds="\$RANLIB \$oldlib~$old_postinstall_cmds" - ;; - esac - old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib" -fi - -cc_basename=`$echo X"$compiler" | $Xsed -e 's%^.*/%%'` - -# Only perform the check for file, if the check method requires it -case $deplibs_check_method in -file_magic*) - if test "$file_magic_cmd" = '$MAGIC_CMD'; then - AC_PATH_MAGIC - fi - ;; -esac - -AC_PROVIDE_IFELSE([AC_LIBTOOL_DLOPEN], enable_dlopen=yes, enable_dlopen=no) -AC_PROVIDE_IFELSE([AC_LIBTOOL_WIN32_DLL], -enable_win32_dll=yes, enable_win32_dll=no) - -AC_ARG_ENABLE([libtool-lock], - [AC_HELP_STRING([--disable-libtool-lock], - [avoid locking (might break parallel builds)])]) -test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes - -AC_ARG_WITH([pic], - [AC_HELP_STRING([--with-pic], - [try to use only PIC/non-PIC objects @<:@default=use both@:>@])], - [pic_mode="$withval"], - [pic_mode=default]) -test -z "$pic_mode" && pic_mode=default - -# Use C for the default configuration in the libtool script -tagname= -AC_LIBTOOL_LANG_C_CONFIG -_LT_AC_TAGCONFIG -])# AC_LIBTOOL_SETUP - - -# _LT_AC_SYS_COMPILER -# ------------------- -AC_DEFUN([_LT_AC_SYS_COMPILER], -[AC_REQUIRE([AC_PROG_CC])dnl - -# If no C compiler was specified, use CC. -LTCC=${LTCC-"$CC"} - -# Allow CC to be a program name with arguments. -compiler=$CC -])# _LT_AC_SYS_COMPILER - - -# _LT_AC_SYS_LIBPATH_AIX -# ---------------------- -# Links a minimal program and checks the executable -# for the system default hardcoded library path. In most cases, -# this is /usr/lib:/lib, but when the MPI compilers are used -# the location of the communication and MPI libs are included too. -# If we don't find anything, use the default library path according -# to the aix ld manual. -AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX], -[AC_LINK_IFELSE(AC_LANG_PROGRAM,[ -aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } -}'` -# Check for a 64-bit object if we didn't find anything. -if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } -}'`; fi],[]) -if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi -])# _LT_AC_SYS_LIBPATH_AIX - - -# _LT_AC_SHELL_INIT(ARG) -# ---------------------- -AC_DEFUN([_LT_AC_SHELL_INIT], -[ifdef([AC_DIVERSION_NOTICE], - [AC_DIVERT_PUSH(AC_DIVERSION_NOTICE)], - [AC_DIVERT_PUSH(NOTICE)]) -$1 -AC_DIVERT_POP -])# _LT_AC_SHELL_INIT - - -# _LT_AC_PROG_ECHO_BACKSLASH -# -------------------------- -# Add some code to the start of the generated configure script which -# will find an echo command which doesn't interpret backslashes. -AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH], -[_LT_AC_SHELL_INIT([ -# Check that we are running under the correct shell. -SHELL=${CONFIG_SHELL-/bin/sh} - -case X$ECHO in -X*--fallback-echo) - # Remove one level of quotation (which was required for Make). - ECHO=`echo "$ECHO" | sed 's,\\\\\[$]\\[$]0,'[$]0','` - ;; -esac - -echo=${ECHO-echo} -if test "X[$]1" = X--no-reexec; then - # Discard the --no-reexec flag, and continue. - shift -elif test "X[$]1" = X--fallback-echo; then - # Avoid inline document here, it may be left over - : -elif test "X`($echo '\t') 2>/dev/null`" = 'X\t' ; then - # Yippee, $echo works! - : -else - # Restart under the correct shell. - exec $SHELL "[$]0" --no-reexec ${1+"[$]@"} -fi - -if test "X[$]1" = X--fallback-echo; then - # used as fallback echo - shift - cat <<EOF -[$]* -EOF - exit 0 -fi - -# The HP-UX ksh and POSIX shell print the target directory to stdout -# if CDPATH is set. -(unset CDPATH) >/dev/null 2>&1 && unset CDPATH - -if test -z "$ECHO"; then -if test "X${echo_test_string+set}" != Xset; then -# find a string as large as possible, as long as the shell can cope with it - for cmd in 'sed 50q "[$]0"' 'sed 20q "[$]0"' 'sed 10q "[$]0"' 'sed 2q "[$]0"' 'echo test'; do - # expected sizes: less than 2Kb, 1Kb, 512 bytes, 16 bytes, ... - if (echo_test_string="`eval $cmd`") 2>/dev/null && - echo_test_string="`eval $cmd`" && - (test "X$echo_test_string" = "X$echo_test_string") 2>/dev/null - then - break - fi - done -fi - -if test "X`($echo '\t') 2>/dev/null`" = 'X\t' && - echo_testing_string=`($echo "$echo_test_string") 2>/dev/null` && - test "X$echo_testing_string" = "X$echo_test_string"; then - : -else - # The Solaris, AIX, and Digital Unix default echo programs unquote - # backslashes. This makes it impossible to quote backslashes using - # echo "$something" | sed 's/\\/\\\\/g' - # - # So, first we look for a working echo in the user's PATH. - - lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR - for dir in $PATH /usr/ucb; do - IFS="$lt_save_ifs" - if (test -f $dir/echo || test -f $dir/echo$ac_exeext) && - test "X`($dir/echo '\t') 2>/dev/null`" = 'X\t' && - echo_testing_string=`($dir/echo "$echo_test_string") 2>/dev/null` && - test "X$echo_testing_string" = "X$echo_test_string"; then - echo="$dir/echo" - break - fi - done - IFS="$lt_save_ifs" - - if test "X$echo" = Xecho; then - # We didn't find a better echo, so look for alternatives. - if test "X`(print -r '\t') 2>/dev/null`" = 'X\t' && - echo_testing_string=`(print -r "$echo_test_string") 2>/dev/null` && - test "X$echo_testing_string" = "X$echo_test_string"; then - # This shell has a builtin print -r that does the trick. - echo='print -r' - elif (test -f /bin/ksh || test -f /bin/ksh$ac_exeext) && - test "X$CONFIG_SHELL" != X/bin/ksh; then - # If we have ksh, try running configure again with it. - ORIGINAL_CONFIG_SHELL=${CONFIG_SHELL-/bin/sh} - export ORIGINAL_CONFIG_SHELL - CONFIG_SHELL=/bin/ksh - export CONFIG_SHELL - exec $CONFIG_SHELL "[$]0" --no-reexec ${1+"[$]@"} - else - # Try using printf. - echo='printf %s\n' - if test "X`($echo '\t') 2>/dev/null`" = 'X\t' && - echo_testing_string=`($echo "$echo_test_string") 2>/dev/null` && - test "X$echo_testing_string" = "X$echo_test_string"; then - # Cool, printf works - : - elif echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` && - test "X$echo_testing_string" = 'X\t' && - echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` && - test "X$echo_testing_string" = "X$echo_test_string"; then - CONFIG_SHELL=$ORIGINAL_CONFIG_SHELL - export CONFIG_SHELL - SHELL="$CONFIG_SHELL" - export SHELL - echo="$CONFIG_SHELL [$]0 --fallback-echo" - elif echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` && - test "X$echo_testing_string" = 'X\t' && - echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` && - test "X$echo_testing_string" = "X$echo_test_string"; then - echo="$CONFIG_SHELL [$]0 --fallback-echo" - else - # maybe with a smaller string... - prev=: - - for cmd in 'echo test' 'sed 2q "[$]0"' 'sed 10q "[$]0"' 'sed 20q "[$]0"' 'sed 50q "[$]0"'; do - if (test "X$echo_test_string" = "X`eval $cmd`") 2>/dev/null - then - break - fi - prev="$cmd" - done - - if test "$prev" != 'sed 50q "[$]0"'; then - echo_test_string=`eval $prev` - export echo_test_string - exec ${ORIGINAL_CONFIG_SHELL-${CONFIG_SHELL-/bin/sh}} "[$]0" ${1+"[$]@"} - else - # Oops. We lost completely, so just stick with echo. - echo=echo - fi - fi - fi - fi -fi -fi - -# Copy echo and quote the copy suitably for passing to libtool from -# the Makefile, instead of quoting the original, which is used later. -ECHO=$echo -if test "X$ECHO" = "X$CONFIG_SHELL [$]0 --fallback-echo"; then - ECHO="$CONFIG_SHELL \\\$\[$]0 --fallback-echo" -fi - -AC_SUBST(ECHO) -])])# _LT_AC_PROG_ECHO_BACKSLASH - - -# _LT_AC_LOCK -# ----------- -AC_DEFUN([_LT_AC_LOCK], -[AC_ARG_ENABLE([libtool-lock], - [AC_HELP_STRING([--disable-libtool-lock], - [avoid locking (might break parallel builds)])]) -test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes - -# Some flags need to be propagated to the compiler or linker for good -# libtool support. -case $host in -ia64-*-hpux*) - # Find out which ABI we are using. - echo 'int i;' > conftest.$ac_ext - if AC_TRY_EVAL(ac_compile); then - case `/usr/bin/file conftest.$ac_objext` in - *ELF-32*) - HPUX_IA64_MODE="32" - ;; - *ELF-64*) - HPUX_IA64_MODE="64" - ;; - esac - fi - rm -rf conftest* - ;; -*-*-irix6*) - # Find out which ABI we are using. - echo '[#]line __oline__ "configure"' > conftest.$ac_ext - if AC_TRY_EVAL(ac_compile); then - if test "$lt_cv_prog_gnu_ld" = yes; then - case `/usr/bin/file conftest.$ac_objext` in - *32-bit*) - LD="${LD-ld} -melf32bsmip" - ;; - *N32*) - LD="${LD-ld} -melf32bmipn32" - ;; - *64-bit*) - LD="${LD-ld} -melf64bmip" - ;; - esac - else - case `/usr/bin/file conftest.$ac_objext` in - *32-bit*) - LD="${LD-ld} -32" - ;; - *N32*) - LD="${LD-ld} -n32" - ;; - *64-bit*) - LD="${LD-ld} -64" - ;; - esac - fi - fi - rm -rf conftest* - ;; - -x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*|s390*-*linux*|sparc*-*linux*) - # Find out which ABI we are using. - echo 'int i;' > conftest.$ac_ext - if AC_TRY_EVAL(ac_compile); then - case "`/usr/bin/file conftest.o`" in - *32-bit*) - case $host in - x86_64-*linux*) - LD="${LD-ld} -m elf_i386" - ;; - ppc64-*linux*|powerpc64-*linux*) - LD="${LD-ld} -m elf32ppclinux" - ;; - s390x-*linux*) - LD="${LD-ld} -m elf_s390" - ;; - sparc64-*linux*) - LD="${LD-ld} -m elf32_sparc" - ;; - esac - ;; - *64-bit*) - case $host in - x86_64-*linux*) - LD="${LD-ld} -m elf_x86_64" - ;; - ppc*-*linux*|powerpc*-*linux*) - LD="${LD-ld} -m elf64ppc" - ;; - s390*-*linux*) - LD="${LD-ld} -m elf64_s390" - ;; - sparc*-*linux*) - LD="${LD-ld} -m elf64_sparc" - ;; - esac - ;; - esac - fi - rm -rf conftest* - ;; - -*-*-sco3.2v5*) - # On SCO OpenServer 5, we need -belf to get full-featured binaries. - SAVE_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS -belf" - AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf, - [AC_LANG_PUSH(C) - AC_TRY_LINK([],[],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no]) - AC_LANG_POP]) - if test x"$lt_cv_cc_needs_belf" != x"yes"; then - # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf - CFLAGS="$SAVE_CFLAGS" - fi - ;; -AC_PROVIDE_IFELSE([AC_LIBTOOL_WIN32_DLL], -[*-*-cygwin* | *-*-mingw* | *-*-pw32*) - AC_CHECK_TOOL(DLLTOOL, dlltool, false) - AC_CHECK_TOOL(AS, as, false) - AC_CHECK_TOOL(OBJDUMP, objdump, false) - ;; - ]) -esac - -need_locks="$enable_libtool_lock" - -])# _LT_AC_LOCK - - -# AC_LIBTOOL_COMPILER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS, -# [OUTPUT-FILE], [ACTION-SUCCESS], [ACTION-FAILURE]) -# ---------------------------------------------------------------- -# Check whether the given compiler option works -AC_DEFUN([AC_LIBTOOL_COMPILER_OPTION], -[AC_REQUIRE([LT_AC_PROG_SED]) -AC_CACHE_CHECK([$1], [$2], - [$2=no - ifelse([$4], , [ac_outfile=conftest.$ac_objext], [ac_outfile=$4]) - printf "$lt_simple_compile_test_code" > conftest.$ac_ext - lt_compiler_flag="$3" - # Insert the option either (1) after the last *FLAGS variable, or - # (2) before a word containing "conftest.", or (3) at the end. - # Note that $ac_compile itself does not contain backslashes and begins - # with a dollar sign (not a hyphen), so the echo should work correctly. - # The option is referenced via a variable to avoid confusing sed. - lt_compile=`echo "$ac_compile" | $SED \ - -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ - -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \ - -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD) - (eval "$lt_compile" 2>conftest.err) - ac_status=$? - cat conftest.err >&AS_MESSAGE_LOG_FD - echo "$as_me:__oline__: \$? = $ac_status" >&AS_MESSAGE_LOG_FD - if (exit $ac_status) && test -s "$ac_outfile"; then - # The compiler can only warn and ignore the option if not recognized - # So say no if there are warnings - if test ! -s conftest.err; then - $2=yes - fi - fi - $rm conftest* -]) - -if test x"[$]$2" = xyes; then - ifelse([$5], , :, [$5]) -else - ifelse([$6], , :, [$6]) -fi -])# AC_LIBTOOL_COMPILER_OPTION - - -# AC_LIBTOOL_LINKER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS, -# [ACTION-SUCCESS], [ACTION-FAILURE]) -# ------------------------------------------------------------ -# Check whether the given compiler option works -AC_DEFUN([AC_LIBTOOL_LINKER_OPTION], -[AC_CACHE_CHECK([$1], [$2], - [$2=no - save_LDFLAGS="$LDFLAGS" - LDFLAGS="$LDFLAGS $3" - printf "$lt_simple_link_test_code" > conftest.$ac_ext - if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then - # The compiler can only warn and ignore the option if not recognized - # So say no if there are warnings - if test -s conftest.err; then - # Append any errors to the config.log. - cat conftest.err 1>&AS_MESSAGE_LOG_FD - else - $2=yes - fi - fi - $rm conftest* - LDFLAGS="$save_LDFLAGS" -]) - -if test x"[$]$2" = xyes; then - ifelse([$4], , :, [$4]) -else - ifelse([$5], , :, [$5]) -fi -])# AC_LIBTOOL_LINKER_OPTION - - -# AC_LIBTOOL_SYS_MAX_CMD_LEN -# -------------------------- -AC_DEFUN([AC_LIBTOOL_SYS_MAX_CMD_LEN], -[# find the maximum length of command line arguments -AC_MSG_CHECKING([the maximum length of command line arguments]) -AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl - i=0 - teststring="ABCD" - - case $build_os in - msdosdjgpp*) - # On DJGPP, this test can blow up pretty badly due to problems in libc - # (any single argument exceeding 2000 bytes causes a buffer overrun - # during glob expansion). Even if it were fixed, the result of this - # check would be larger than it should be. - lt_cv_sys_max_cmd_len=12288; # 12K is about right - ;; - - gnu*) - # Under GNU Hurd, this test is not required because there is - # no limit to the length of command line arguments. - # Libtool will interpret -1 as no limit whatsoever - lt_cv_sys_max_cmd_len=-1; - ;; - - cygwin* | mingw*) - # On Win9x/ME, this test blows up -- it succeeds, but takes - # about 5 minutes as the teststring grows exponentially. - # Worse, since 9x/ME are not pre-emptively multitasking, - # you end up with a "frozen" computer, even though with patience - # the test eventually succeeds (with a max line length of 256k). - # Instead, let's just punt: use the minimum linelength reported by - # all of the supported platforms: 8192 (on NT/2K/XP). - lt_cv_sys_max_cmd_len=8192; - ;; - - amigaos*) - # On AmigaOS with pdksh, this test takes hours, literally. - # So we just punt and use a minimum line length of 8192. - lt_cv_sys_max_cmd_len=8192; - ;; - - netbsd* | freebsd* | openbsd* | darwin* ) - # This has been around since 386BSD, at least. Likely further. - if test -x /sbin/sysctl; then - lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax` - elif test -x /usr/sbin/sysctl; then - lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax` - else - lt_cv_sys_max_cmd_len=65536 # usable default for *BSD - fi - # And add a safety zone - lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` - ;; - - *) - # If test is not a shell built-in, we'll probably end up computing a - # maximum length that is only half of the actual maximum length, but - # we can't tell. - SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}} - while (test "X"`$SHELL [$]0 --fallback-echo "X$teststring" 2>/dev/null` \ - = "XX$teststring") >/dev/null 2>&1 && - new_result=`expr "X$teststring" : ".*" 2>&1` && - lt_cv_sys_max_cmd_len=$new_result && - test $i != 17 # 1/2 MB should be enough - do - i=`expr $i + 1` - teststring=$teststring$teststring - done - teststring= - # Add a significant safety factor because C++ compilers can tack on massive - # amounts of additional arguments before passing them to the linker. - # It appears as though 1/2 is a usable value. - lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2` - ;; - esac -]) -if test -n $lt_cv_sys_max_cmd_len ; then - AC_MSG_RESULT($lt_cv_sys_max_cmd_len) -else - AC_MSG_RESULT(none) -fi -])# AC_LIBTOOL_SYS_MAX_CMD_LEN - - -# _LT_AC_CHECK_DLFCN -# -------------------- -AC_DEFUN([_LT_AC_CHECK_DLFCN], -[AC_CHECK_HEADERS(dlfcn.h)dnl -])# _LT_AC_CHECK_DLFCN - - -# _LT_AC_TRY_DLOPEN_SELF (ACTION-IF-TRUE, ACTION-IF-TRUE-W-USCORE, -# ACTION-IF-FALSE, ACTION-IF-CROSS-COMPILING) -# ------------------------------------------------------------------ -AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF], -[AC_REQUIRE([_LT_AC_CHECK_DLFCN])dnl -if test "$cross_compiling" = yes; then : - [$4] -else - lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 - lt_status=$lt_dlunknown - cat > conftest.$ac_ext <<EOF -[#line __oline__ "configure" -#include "confdefs.h" - -#if HAVE_DLFCN_H -#include <dlfcn.h> -#endif - -#include <stdio.h> - -#ifdef RTLD_GLOBAL -# define LT_DLGLOBAL RTLD_GLOBAL -#else -# ifdef DL_GLOBAL -# define LT_DLGLOBAL DL_GLOBAL -# else -# define LT_DLGLOBAL 0 -# endif -#endif - -/* We may have to define LT_DLLAZY_OR_NOW in the command line if we - find out it does not work in some platform. */ -#ifndef LT_DLLAZY_OR_NOW -# ifdef RTLD_LAZY -# define LT_DLLAZY_OR_NOW RTLD_LAZY -# else -# ifdef DL_LAZY -# define LT_DLLAZY_OR_NOW DL_LAZY -# else -# ifdef RTLD_NOW -# define LT_DLLAZY_OR_NOW RTLD_NOW -# else -# ifdef DL_NOW -# define LT_DLLAZY_OR_NOW DL_NOW -# else -# define LT_DLLAZY_OR_NOW 0 -# endif -# endif -# endif -# endif -#endif - -#ifdef __cplusplus -extern "C" void exit (int); -#endif - -void fnord() { int i=42;} -int main () -{ - void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); - int status = $lt_dlunknown; - - if (self) - { - if (dlsym (self,"fnord")) status = $lt_dlno_uscore; - else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; - /* dlclose (self); */ - } - - exit (status); -}] -EOF - if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext} 2>/dev/null; then - (./conftest; exit; ) 2>/dev/null - lt_status=$? - case x$lt_status in - x$lt_dlno_uscore) $1 ;; - x$lt_dlneed_uscore) $2 ;; - x$lt_unknown|x*) $3 ;; - esac - else : - # compilation failed - $3 - fi -fi -rm -fr conftest* -])# _LT_AC_TRY_DLOPEN_SELF - - -# AC_LIBTOOL_DLOPEN_SELF -# ------------------- -AC_DEFUN([AC_LIBTOOL_DLOPEN_SELF], -[AC_REQUIRE([_LT_AC_CHECK_DLFCN])dnl -if test "x$enable_dlopen" != xyes; then - enable_dlopen=unknown - enable_dlopen_self=unknown - enable_dlopen_self_static=unknown -else - lt_cv_dlopen=no - lt_cv_dlopen_libs= - - case $host_os in - beos*) - lt_cv_dlopen="load_add_on" - lt_cv_dlopen_libs= - lt_cv_dlopen_self=yes - ;; - - mingw* | pw32*) - lt_cv_dlopen="LoadLibrary" - lt_cv_dlopen_libs= - ;; - - cygwin*) - lt_cv_dlopen="dlopen" - lt_cv_dlopen_libs= - ;; - - darwin*) - # if libdl is installed we need to link against it - AC_CHECK_LIB([dl], [dlopen], - [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],[ - lt_cv_dlopen="dyld" - lt_cv_dlopen_libs= - lt_cv_dlopen_self=yes - ]) - ;; - - *) - AC_CHECK_FUNC([shl_load], - [lt_cv_dlopen="shl_load"], - [AC_CHECK_LIB([dld], [shl_load], - [lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-dld"], - [AC_CHECK_FUNC([dlopen], - [lt_cv_dlopen="dlopen"], - [AC_CHECK_LIB([dl], [dlopen], - [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"], - [AC_CHECK_LIB([svld], [dlopen], - [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"], - [AC_CHECK_LIB([dld], [dld_link], - [lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-dld"]) - ]) - ]) - ]) - ]) - ]) - ;; - esac - - if test "x$lt_cv_dlopen" != xno; then - enable_dlopen=yes - else - enable_dlopen=no - fi - - case $lt_cv_dlopen in - dlopen) - save_CPPFLAGS="$CPPFLAGS" - test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" - - save_LDFLAGS="$LDFLAGS" - eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" - - save_LIBS="$LIBS" - LIBS="$lt_cv_dlopen_libs $LIBS" - - AC_CACHE_CHECK([whether a program can dlopen itself], - lt_cv_dlopen_self, [dnl - _LT_AC_TRY_DLOPEN_SELF( - lt_cv_dlopen_self=yes, lt_cv_dlopen_self=yes, - lt_cv_dlopen_self=no, lt_cv_dlopen_self=cross) - ]) - - if test "x$lt_cv_dlopen_self" = xyes; then - LDFLAGS="$LDFLAGS $link_static_flag" - AC_CACHE_CHECK([whether a statically linked program can dlopen itself], - lt_cv_dlopen_self_static, [dnl - _LT_AC_TRY_DLOPEN_SELF( - lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=yes, - lt_cv_dlopen_self_static=no, lt_cv_dlopen_self_static=cross) - ]) - fi - - CPPFLAGS="$save_CPPFLAGS" - LDFLAGS="$save_LDFLAGS" - LIBS="$save_LIBS" - ;; - esac - - case $lt_cv_dlopen_self in - yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; - *) enable_dlopen_self=unknown ;; - esac - - case $lt_cv_dlopen_self_static in - yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; - *) enable_dlopen_self_static=unknown ;; - esac -fi -])# AC_LIBTOOL_DLOPEN_SELF - - -# AC_LIBTOOL_PROG_CC_C_O([TAGNAME]) -# --------------------------------- -# Check to see if options -c and -o are simultaneously supported by compiler -AC_DEFUN([AC_LIBTOOL_PROG_CC_C_O], -[AC_REQUIRE([_LT_AC_SYS_COMPILER])dnl -AC_CACHE_CHECK([if $compiler supports -c -o file.$ac_objext], - [_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)], - [_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)=no - $rm -r conftest 2>/dev/null - mkdir conftest - cd conftest - mkdir out - printf "$lt_simple_compile_test_code" > conftest.$ac_ext - - lt_compiler_flag="-o out/conftest2.$ac_objext" - # Insert the option either (1) after the last *FLAGS variable, or - # (2) before a word containing "conftest.", or (3) at the end. - # Note that $ac_compile itself does not contain backslashes and begins - # with a dollar sign (not a hyphen), so the echo should work correctly. - lt_compile=`echo "$ac_compile" | $SED \ - -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ - -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \ - -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD) - (eval "$lt_compile" 2>out/conftest.err) - ac_status=$? - cat out/conftest.err >&AS_MESSAGE_LOG_FD - echo "$as_me:__oline__: \$? = $ac_status" >&AS_MESSAGE_LOG_FD - if (exit $ac_status) && test -s out/conftest2.$ac_objext - then - # The compiler can only warn and ignore the option if not recognized - # So say no if there are warnings - if test ! -s out/conftest.err; then - _LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes - fi - fi - chmod u+w . - $rm conftest* - # SGI C++ compiler will create directory out/ii_files/ for - # template instantiation - test -d out/ii_files && $rm out/ii_files/* && rmdir out/ii_files - $rm out/* && rmdir out - cd .. - rmdir conftest - $rm conftest* -]) -])# AC_LIBTOOL_PROG_CC_C_O - - -# AC_LIBTOOL_SYS_HARD_LINK_LOCKS([TAGNAME]) -# ----------------------------------------- -# Check to see if we can do hard links to lock some files if needed -AC_DEFUN([AC_LIBTOOL_SYS_HARD_LINK_LOCKS], -[AC_REQUIRE([_LT_AC_LOCK])dnl - -hard_links="nottested" -if test "$_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)" = no && test "$need_locks" != no; then - # do not overwrite the value of need_locks provided by the user - AC_MSG_CHECKING([if we can lock with hard links]) - hard_links=yes - $rm conftest* - ln conftest.a conftest.b 2>/dev/null && hard_links=no - touch conftest.a - ln conftest.a conftest.b 2>&5 || hard_links=no - ln conftest.a conftest.b 2>/dev/null && hard_links=no - AC_MSG_RESULT([$hard_links]) - if test "$hard_links" = no; then - AC_MSG_WARN([`$CC' does not support `-c -o', so `make -j' may be unsafe]) - need_locks=warn - fi -else - need_locks=no -fi -])# AC_LIBTOOL_SYS_HARD_LINK_LOCKS - - -# AC_LIBTOOL_OBJDIR -# ----------------- -AC_DEFUN([AC_LIBTOOL_OBJDIR], -[AC_CACHE_CHECK([for objdir], [lt_cv_objdir], -[rm -f .libs 2>/dev/null -mkdir .libs 2>/dev/null -if test -d .libs; then - lt_cv_objdir=.libs -else - # MS-DOS does not allow filenames that begin with a dot. - lt_cv_objdir=_libs -fi -rmdir .libs 2>/dev/null]) -objdir=$lt_cv_objdir -])# AC_LIBTOOL_OBJDIR - - -# AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH([TAGNAME]) -# ---------------------------------------------- -# Check hardcoding attributes. -AC_DEFUN([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH], -[AC_MSG_CHECKING([how to hardcode library paths into programs]) -_LT_AC_TAGVAR(hardcode_action, $1)= -if test -n "$_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)" || \ - test -n "$_LT_AC_TAGVAR(runpath_var, $1)" || \ - test "X$_LT_AC_TAGVAR(hardcode_automatic, $1)" = "Xyes" ; then - - # We can hardcode non-existant directories. - if test "$_LT_AC_TAGVAR(hardcode_direct, $1)" != no && - # If the only mechanism to avoid hardcoding is shlibpath_var, we - # have to relink, otherwise we might link with an installed library - # when we should be linking with a yet-to-be-installed one - ## test "$_LT_AC_TAGVAR(hardcode_shlibpath_var, $1)" != no && - test "$_LT_AC_TAGVAR(hardcode_minus_L, $1)" != no; then - # Linking always hardcodes the temporary library directory. - _LT_AC_TAGVAR(hardcode_action, $1)=relink - else - # We can link without hardcoding, and we can hardcode nonexisting dirs. - _LT_AC_TAGVAR(hardcode_action, $1)=immediate - fi -else - # We cannot hardcode anything, or else we can only hardcode existing - # directories. - _LT_AC_TAGVAR(hardcode_action, $1)=unsupported -fi -AC_MSG_RESULT([$_LT_AC_TAGVAR(hardcode_action, $1)]) - -if test "$_LT_AC_TAGVAR(hardcode_action, $1)" = relink; then - # Fast installation is not supported - enable_fast_install=no -elif test "$shlibpath_overrides_runpath" = yes || - test "$enable_shared" = no; then - # Fast installation is not necessary - enable_fast_install=needless -fi -])# AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH - - -# AC_LIBTOOL_SYS_LIB_STRIP -# ------------------------ -AC_DEFUN([AC_LIBTOOL_SYS_LIB_STRIP], -[striplib= -old_striplib= -AC_MSG_CHECKING([whether stripping libraries is possible]) -if test -n "$STRIP" && $STRIP -V 2>&1 | grep "GNU strip" >/dev/null; then - test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" - test -z "$striplib" && striplib="$STRIP --strip-unneeded" - AC_MSG_RESULT([yes]) -else -# FIXME - insert some real tests, host_os isn't really good enough - case $host_os in - darwin*) - if test -n "$STRIP" ; then - striplib="$STRIP -x" - AC_MSG_RESULT([yes]) - else - AC_MSG_RESULT([no]) -fi - ;; - *) - AC_MSG_RESULT([no]) - ;; - esac -fi -])# AC_LIBTOOL_SYS_LIB_STRIP - - -# AC_LIBTOOL_SYS_DYNAMIC_LINKER -# ----------------------------- -# PORTME Fill in your ld.so characteristics -AC_DEFUN([AC_LIBTOOL_SYS_DYNAMIC_LINKER], -[AC_MSG_CHECKING([dynamic linker characteristics]) -library_names_spec= -libname_spec='lib$name' -soname_spec= -shrext_cmds=".so" -postinstall_cmds= -postuninstall_cmds= -finish_cmds= -finish_eval= -shlibpath_var= -shlibpath_overrides_runpath=unknown -version_type=none -dynamic_linker="$host_os ld.so" -sys_lib_dlsearch_path_spec="/lib /usr/lib" -if test "$GCC" = yes; then - sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"` - if echo "$sys_lib_search_path_spec" | grep ';' >/dev/null ; then - # if the path contains ";" then we assume it to be the separator - # otherwise default to the standard path separator (i.e. ":") - it is - # assumed that no part of a normal pathname contains ";" but that should - # okay in the real world where ";" in dirpaths is itself problematic. - sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` - else - sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` - fi -else - sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" -fi -need_lib_prefix=unknown -hardcode_into_libs=no - -# when you set need_version to no, make sure it does not cause -set_version -# flags to be left without arguments -need_version=unknown - -case $host_os in -aix3*) - version_type=linux - library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' - shlibpath_var=LIBPATH - - # AIX 3 has no versioning support, so we append a major version to the name. - soname_spec='${libname}${release}${shared_ext}$major' - ;; - -aix4* | aix5*) - version_type=linux - need_lib_prefix=no - need_version=no - hardcode_into_libs=yes - if test "$host_cpu" = ia64; then - # AIX 5 supports IA64 - library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}' - shlibpath_var=LD_LIBRARY_PATH - else - # With GCC up to 2.95.x, collect2 would create an import file - # for dependence libraries. The import file would start with - # the line `#! .'. This would cause the generated library to - # depend on `.', always an invalid library. This was fixed in - # development snapshots of GCC prior to 3.0. - case $host_os in - aix4 | aix4.[[01]] | aix4.[[01]].*) - if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' - echo ' yes ' - echo '#endif'; } | ${CC} -E - | grep yes > /dev/null; then - : - else - can_build_shared=no - fi - ;; - esac - # AIX (on Power*) has no versioning support, so currently we can not hardcode correct - # soname into executable. Probably we can add versioning support to - # collect2, so additional links can be useful in future. - if test "$aix_use_runtimelinking" = yes; then - # If using run time linking (on AIX 4.2 or later) use lib<name>.so - # instead of lib<name>.a to let people know that these are not - # typical AIX shared libraries. - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - else - # We preserve .a as extension for shared libraries through AIX4.2 - # and later when we are not doing run time linking. - library_names_spec='${libname}${release}.a $libname.a' - soname_spec='${libname}${release}${shared_ext}$major' - fi - shlibpath_var=LIBPATH - fi - ;; - -amigaos*) - library_names_spec='$libname.ixlibrary $libname.a' - # Create ${libname}_ixlibrary.a entries in /sys/libs. - finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$echo "X$lib" | $Xsed -e '\''s%^.*/\([[^/]]*\)\.ixlibrary$%\1%'\''`; test $rm /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' - ;; - -beos*) - library_names_spec='${libname}${shared_ext}' - dynamic_linker="$host_os ld.so" - shlibpath_var=LIBRARY_PATH - ;; - -bsdi[[45]]*) - version_type=linux - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' - shlibpath_var=LD_LIBRARY_PATH - sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" - sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" - # the default ld.so.conf also contains /usr/contrib/lib and - # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow - # libtool to hard-code these into programs - ;; - -cygwin* | mingw* | pw32*) - version_type=windows - shrext_cmds=".dll" - need_version=no - need_lib_prefix=no - - case $GCC,$host_os in - yes,cygwin* | yes,mingw* | yes,pw32*) - library_names_spec='$libname.dll.a' - # DLL is installed to $(libdir)/../bin by postinstall_cmds - postinstall_cmds='base_file=`basename \${file}`~ - dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i;echo \$dlname'\''`~ - dldir=$destdir/`dirname \$dlpath`~ - test -d \$dldir || mkdir -p \$dldir~ - $install_prog $dir/$dlname \$dldir/$dlname' - postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ - dlpath=$dir/\$dldll~ - $rm \$dlpath' - shlibpath_overrides_runpath=yes - - case $host_os in - cygwin*) - # Cygwin DLLs use 'cyg' prefix rather than 'lib' - soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' - sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib" - ;; - mingw*) - # MinGW DLLs use traditional 'lib' prefix - soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' - sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"` - if echo "$sys_lib_search_path_spec" | [grep ';[c-zC-Z]:/' >/dev/null]; then - # It is most probably a Windows format PATH printed by - # mingw gcc, but we are running on Cygwin. Gcc prints its search - # path with ; separators, and with drive letters. We can handle the - # drive letters (cygwin fileutils understands them), so leave them, - # especially as we might pass files found there to a mingw objdump, - # which wouldn't understand a cygwinified path. Ahh. - sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` - else - sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` - fi - ;; - pw32*) - # pw32 DLLs use 'pw' prefix rather than 'lib' - library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' - ;; - esac - ;; - - *) - library_names_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext} $libname.lib' - ;; - esac - dynamic_linker='Win32 ld.exe' - # FIXME: first we should search . and the directory the executable is in - shlibpath_var=PATH - ;; - -darwin* | rhapsody*) - dynamic_linker="$host_os dyld" - version_type=darwin - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${versuffix}$shared_ext ${libname}${release}${major}$shared_ext ${libname}$shared_ext' - soname_spec='${libname}${release}${major}$shared_ext' - shlibpath_overrides_runpath=yes - shlibpath_var=DYLD_LIBRARY_PATH - shrext_cmds='$(test .$module = .yes && echo .so || echo .dylib)' - # Apple's gcc prints 'gcc -print-search-dirs' doesn't operate the same. - if test "$GCC" = yes; then - sys_lib_search_path_spec=`$CC -print-search-dirs | tr "\n" "$PATH_SEPARATOR" | sed -e 's/libraries:/@libraries:/' | tr "@" "\n" | grep "^libraries:" | sed -e "s/^libraries://" -e "s,=/,/,g" -e "s,$PATH_SEPARATOR, ,g" -e "s,.*,& /lib /usr/lib /usr/local/lib,g"` - else - sys_lib_search_path_spec='/lib /usr/lib /usr/local/lib' - fi - sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' - ;; - -dgux*) - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - ;; - -freebsd1*) - dynamic_linker=no - ;; - -kfreebsd*-gnu) - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - dynamic_linker='GNU ld.so' - ;; - -freebsd*) - objformat=`test -x /usr/bin/objformat && /usr/bin/objformat || echo aout` - version_type=freebsd-$objformat - case $version_type in - freebsd-elf*) - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' - need_version=no - need_lib_prefix=no - ;; - freebsd-*) - library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix' - need_version=yes - ;; - esac - shlibpath_var=LD_LIBRARY_PATH - case $host_os in - freebsd2*) - shlibpath_overrides_runpath=yes - ;; - freebsd3.[01]* | freebsdelf3.[01]*) - shlibpath_overrides_runpath=yes - hardcode_into_libs=yes - ;; - *) # from 3.2 on - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - ;; - esac - ;; - -gnu*) - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - hardcode_into_libs=yes - ;; - -hpux9* | hpux10* | hpux11*) - # Give a soname corresponding to the major version so that dld.sl refuses to - # link against other versions. - version_type=sunos - need_lib_prefix=no - need_version=no - case "$host_cpu" in - ia64*) - shrext_cmds='.so' - hardcode_into_libs=yes - dynamic_linker="$host_os dld.so" - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - if test "X$HPUX_IA64_MODE" = X32; then - sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" - else - sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" - fi - sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec - ;; - hppa*64*) - shrext_cmds='.sl' - hardcode_into_libs=yes - dynamic_linker="$host_os dld.sl" - shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH - shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" - sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec - ;; - *) - shrext_cmds='.sl' - dynamic_linker="$host_os dld.sl" - shlibpath_var=SHLIB_PATH - shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - ;; - esac - # HP-UX runs *really* slowly unless shared libraries are mode 555. - postinstall_cmds='chmod 555 $lib' - ;; - -irix5* | irix6* | nonstopux*) - case $host_os in - nonstopux*) version_type=nonstopux ;; - *) - if test "$lt_cv_prog_gnu_ld" = yes; then - version_type=linux - else - version_type=irix - fi ;; - esac - need_lib_prefix=no - need_version=no - soname_spec='${libname}${release}${shared_ext}$major' - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}' - case $host_os in - irix5* | nonstopux*) - libsuff= shlibsuff= - ;; - *) - case $LD in # libtool.m4 will add one of these switches to LD - *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") - libsuff= shlibsuff= libmagic=32-bit;; - *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") - libsuff=32 shlibsuff=N32 libmagic=N32;; - *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") - libsuff=64 shlibsuff=64 libmagic=64-bit;; - *) libsuff= shlibsuff= libmagic=never-match;; - esac - ;; - esac - shlibpath_var=LD_LIBRARY${shlibsuff}_PATH - shlibpath_overrides_runpath=no - sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" - sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" - hardcode_into_libs=yes - ;; - -# No shared lib support for Linux oldld, aout, or coff. -linux*oldld* | linux*aout* | linux*coff*) - dynamic_linker=no - ;; - -# This must be Linux ELF. -linux*) - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=no - # This implies no fast_install, which is unacceptable. - # Some rework will be needed to allow for fast_install - # before this can be enabled. - hardcode_into_libs=yes - - # Append ld.so.conf contents to the search path - if test -f /etc/ld.so.conf; then - lt_ld_extra=`$SED -e 's/[:,\t]/ /g;s/=[^=]*$//;s/=[^= ]* / /g' /etc/ld.so.conf | tr '\n' ' '` - sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" - fi - - # We used to test for /lib/ld.so.1 and disable shared libraries on - # powerpc, because MkLinux only supported shared libraries with the - # GNU dynamic linker. Since this was broken with cross compilers, - # most powerpc-linux boxes support dynamic linking these days and - # people can always --disable-shared, the test was removed, and we - # assume the GNU/Linux dynamic linker is in use. - dynamic_linker='GNU/Linux ld.so' - ;; - -knetbsd*-gnu) - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - dynamic_linker='GNU ld.so' - ;; - -netbsd*) - version_type=sunos - need_lib_prefix=no - need_version=no - if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' - finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' - dynamic_linker='NetBSD (a.out) ld.so' - else - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - dynamic_linker='NetBSD ld.elf_so' - fi - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - hardcode_into_libs=yes - ;; - -newsos6) - version_type=linux - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - ;; - -nto-qnx*) - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - ;; - -openbsd*) - version_type=sunos - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' - finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' - shlibpath_var=LD_LIBRARY_PATH - if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then - case $host_os in - openbsd2.[[89]] | openbsd2.[[89]].*) - shlibpath_overrides_runpath=no - ;; - *) - shlibpath_overrides_runpath=yes - ;; - esac - else - shlibpath_overrides_runpath=yes - fi - ;; - -os2*) - libname_spec='$name' - shrext_cmds=".dll" - need_lib_prefix=no - library_names_spec='$libname${shared_ext} $libname.a' - dynamic_linker='OS/2 ld.exe' - shlibpath_var=LIBPATH - ;; - -osf3* | osf4* | osf5*) - version_type=osf - need_lib_prefix=no - need_version=no - soname_spec='${libname}${release}${shared_ext}$major' - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - shlibpath_var=LD_LIBRARY_PATH - sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" - sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" - ;; - -sco3.2v5*) - version_type=osf - soname_spec='${libname}${release}${shared_ext}$major' - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - shlibpath_var=LD_LIBRARY_PATH - ;; - -solaris*) - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - hardcode_into_libs=yes - # ldd complains unless libraries are executable - postinstall_cmds='chmod +x $lib' - ;; - -sunos4*) - version_type=sunos - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' - finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - if test "$with_gnu_ld" = yes; then - need_lib_prefix=no - fi - need_version=yes - ;; - -sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) - version_type=linux - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - case $host_vendor in - sni) - shlibpath_overrides_runpath=no - need_lib_prefix=no - export_dynamic_flag_spec='${wl}-Blargedynsym' - runpath_var=LD_RUN_PATH - ;; - siemens) - need_lib_prefix=no - ;; - motorola) - need_lib_prefix=no - need_version=no - shlibpath_overrides_runpath=no - sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' - ;; - esac - ;; - -sysv4*MP*) - if test -d /usr/nec ;then - version_type=linux - library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' - soname_spec='$libname${shared_ext}.$major' - shlibpath_var=LD_LIBRARY_PATH - fi - ;; - -uts4*) - version_type=linux - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - ;; - -*) - dynamic_linker=no - ;; -esac -AC_MSG_RESULT([$dynamic_linker]) -test "$dynamic_linker" = no && can_build_shared=no -])# AC_LIBTOOL_SYS_DYNAMIC_LINKER - - -# _LT_AC_TAGCONFIG -# ---------------- -AC_DEFUN([_LT_AC_TAGCONFIG], -[AC_ARG_WITH([tags], - [AC_HELP_STRING([--with-tags@<:@=TAGS@:>@], - [include additional configurations @<:@automatic@:>@])], - [tagnames="$withval"]) - -if test -f "$ltmain" && test -n "$tagnames"; then - if test ! -f "${ofile}"; then - AC_MSG_WARN([output file `$ofile' does not exist]) - fi - - if test -z "$LTCC"; then - eval "`$SHELL ${ofile} --config | grep '^LTCC='`" - if test -z "$LTCC"; then - AC_MSG_WARN([output file `$ofile' does not look like a libtool script]) - else - AC_MSG_WARN([using `LTCC=$LTCC', extracted from `$ofile']) - fi - fi - - # Extract list of available tagged configurations in $ofile. - # Note that this assumes the entire list is on one line. - available_tags=`grep "^available_tags=" "${ofile}" | $SED -e 's/available_tags=\(.*$\)/\1/' -e 's/\"//g'` - - lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," - for tagname in $tagnames; do - IFS="$lt_save_ifs" - # Check whether tagname contains only valid characters - case `$echo "X$tagname" | $Xsed -e 's:[[-_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890,/]]::g'` in - "") ;; - *) AC_MSG_ERROR([invalid tag name: $tagname]) - ;; - esac - - if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$" < "${ofile}" > /dev/null - then - AC_MSG_ERROR([tag name \"$tagname\" already exists]) - fi - - # Update the list of available tags. - if test -n "$tagname"; then - echo appending configuration tag \"$tagname\" to $ofile - - case $tagname in - CXX) - if test -n "$CXX" && ( test "X$CXX" != "Xno" && - ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) || - (test "X$CXX" != "Xg++"))) ; then - AC_LIBTOOL_LANG_CXX_CONFIG - else - tagname="" - fi - ;; - - F77) - if test -n "$F77" && test "X$F77" != "Xno"; then - AC_LIBTOOL_LANG_F77_CONFIG - else - tagname="" - fi - ;; - - GCJ) - if test -n "$GCJ" && test "X$GCJ" != "Xno"; then - AC_LIBTOOL_LANG_GCJ_CONFIG - else - tagname="" - fi - ;; - - RC) - AC_LIBTOOL_LANG_RC_CONFIG - ;; - - *) - AC_MSG_ERROR([Unsupported tag name: $tagname]) - ;; - esac - - # Append the new tag name to the list of available tags. - if test -n "$tagname" ; then - available_tags="$available_tags $tagname" - fi - fi - done - IFS="$lt_save_ifs" - - # Now substitute the updated list of available tags. - if eval "sed -e 's/^available_tags=.*\$/available_tags=\"$available_tags\"/' \"$ofile\" > \"${ofile}T\""; then - mv "${ofile}T" "$ofile" - chmod +x "$ofile" - else - rm -f "${ofile}T" - AC_MSG_ERROR([unable to update list of available tagged configurations.]) - fi -fi -])# _LT_AC_TAGCONFIG - - -# AC_LIBTOOL_DLOPEN -# ----------------- -# enable checks for dlopen support -AC_DEFUN([AC_LIBTOOL_DLOPEN], - [AC_BEFORE([$0],[AC_LIBTOOL_SETUP]) -])# AC_LIBTOOL_DLOPEN - - -# AC_LIBTOOL_WIN32_DLL -# -------------------- -# declare package support for building win32 dll's -AC_DEFUN([AC_LIBTOOL_WIN32_DLL], -[AC_BEFORE([$0], [AC_LIBTOOL_SETUP]) -])# AC_LIBTOOL_WIN32_DLL - - -# AC_ENABLE_SHARED([DEFAULT]) -# --------------------------- -# implement the --enable-shared flag -# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. -AC_DEFUN([AC_ENABLE_SHARED], -[define([AC_ENABLE_SHARED_DEFAULT], ifelse($1, no, no, yes))dnl -AC_ARG_ENABLE([shared], - [AC_HELP_STRING([--enable-shared@<:@=PKGS@:>@], - [build shared libraries @<:@default=]AC_ENABLE_SHARED_DEFAULT[@:>@])], - [p=${PACKAGE-default} - case $enableval in - yes) enable_shared=yes ;; - no) enable_shared=no ;; - *) - enable_shared=no - # Look at the argument we got. We use all the common list separators. - lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," - for pkg in $enableval; do - IFS="$lt_save_ifs" - if test "X$pkg" = "X$p"; then - enable_shared=yes - fi - done - IFS="$lt_save_ifs" - ;; - esac], - [enable_shared=]AC_ENABLE_SHARED_DEFAULT) -])# AC_ENABLE_SHARED - - -# AC_DISABLE_SHARED -# ----------------- -#- set the default shared flag to --disable-shared -AC_DEFUN([AC_DISABLE_SHARED], -[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl -AC_ENABLE_SHARED(no) -])# AC_DISABLE_SHARED - - -# AC_ENABLE_STATIC([DEFAULT]) -# --------------------------- -# implement the --enable-static flag -# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. -AC_DEFUN([AC_ENABLE_STATIC], -[define([AC_ENABLE_STATIC_DEFAULT], ifelse($1, no, no, yes))dnl -AC_ARG_ENABLE([static], - [AC_HELP_STRING([--enable-static@<:@=PKGS@:>@], - [build static libraries @<:@default=]AC_ENABLE_STATIC_DEFAULT[@:>@])], - [p=${PACKAGE-default} - case $enableval in - yes) enable_static=yes ;; - no) enable_static=no ;; - *) - enable_static=no - # Look at the argument we got. We use all the common list separators. - lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," - for pkg in $enableval; do - IFS="$lt_save_ifs" - if test "X$pkg" = "X$p"; then - enable_static=yes - fi - done - IFS="$lt_save_ifs" - ;; - esac], - [enable_static=]AC_ENABLE_STATIC_DEFAULT) -])# AC_ENABLE_STATIC - - -# AC_DISABLE_STATIC -# ----------------- -# set the default static flag to --disable-static -AC_DEFUN([AC_DISABLE_STATIC], -[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl -AC_ENABLE_STATIC(no) -])# AC_DISABLE_STATIC - - -# AC_ENABLE_FAST_INSTALL([DEFAULT]) -# --------------------------------- -# implement the --enable-fast-install flag -# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. -AC_DEFUN([AC_ENABLE_FAST_INSTALL], -[define([AC_ENABLE_FAST_INSTALL_DEFAULT], ifelse($1, no, no, yes))dnl -AC_ARG_ENABLE([fast-install], - [AC_HELP_STRING([--enable-fast-install@<:@=PKGS@:>@], - [optimize for fast installation @<:@default=]AC_ENABLE_FAST_INSTALL_DEFAULT[@:>@])], - [p=${PACKAGE-default} - case $enableval in - yes) enable_fast_install=yes ;; - no) enable_fast_install=no ;; - *) - enable_fast_install=no - # Look at the argument we got. We use all the com... [truncated message content] |
From: <tbr...@us...> - 2012-03-20 01:53:13
|
Revision: 198 http://xmlwrapp.svn.sourceforge.net/xmlwrapp/?rev=198&view=rev Author: tbrowder2 Date: 2012-03-20 01:53:04 +0000 (Tue, 20 Mar 2012) Log Message: ----------- more C++ source file suffix changes from .cxx to .cc; add autogen.sh and supporting libtool file Modified Paths: -------------- trunk/examples/01-tree_parsing/Makefile.am Added Paths: ----------- trunk/autogen.sh trunk/misc/libtool.m4 Added: trunk/autogen.sh =================================================================== --- trunk/autogen.sh (rev 0) +++ trunk/autogen.sh 2012-03-20 01:53:04 UTC (rev 198) @@ -0,0 +1,1599 @@ +#!/bin/sh +# a u t o g e n . s h +# +# Copyright (c) 2005-2012 United States Government as represented by +# the U.S. Army Research Laboratory. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following +# disclaimer in the documentation and/or other materials provided +# with the distribution. +# +# 3. The name of the author may not be used to endorse or promote +# products derived from this software without specific prior written +# permission. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS +# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +### +# +# Script for automatically preparing the sources for compilation by +# performing the myriad of necessary steps. The script attempts to +# detect proper version support, and outputs warnings about particular +# systems that have autotool peculiarities. +# +# Basically, if everything is set up and installed correctly, the +# script will validate that minimum versions of the GNU Build System +# tools are installed, account for several common configuration +# issues, and then simply run autoreconf for you. +# +# If autoreconf fails, which can happen for many valid configurations, +# this script proceeds to run manual preparation steps effectively +# providing a POSIX shell script (mostly complete) reimplementation of +# autoreconf. +# +# The AUTORECONF, AUTOCONF, AUTOMAKE, LIBTOOLIZE, ACLOCAL, AUTOHEADER +# environment variables and corresponding _OPTIONS variables (e.g. +# AUTORECONF_OPTIONS) may be used to override the default automatic +# detection behaviors. Similarly the _VERSION variables will override +# the minimum required version numbers. +# +# Examples: +# +# To obtain help on usage: +# ./autogen.sh --help +# +# To obtain verbose output: +# ./autogen.sh --verbose +# +# To skip autoreconf and prepare manually: +# AUTORECONF=false ./autogen.sh +# +# To verbosely try running with an older (unsupported) autoconf: +# AUTOCONF_VERSION=2.50 ./autogen.sh --verbose +# +# Author: +# Christopher Sean Morrison <mor...@br...> +# +# Patches: +# Sebastian Pipping <seb...@pi...> +# Tom Browder <tbr...@us...> +# +###################################################################### + +# set to minimum acceptable version of autoconf +if [ "x$AUTOCONF_VERSION" = "x" ] ; then + AUTOCONF_VERSION=2.52 +fi +# set to minimum acceptable version of automake +if [ "x$AUTOMAKE_VERSION" = "x" ] ; then + AUTOMAKE_VERSION=1.6.0 +fi +# set to minimum acceptable version of libtool +if [ "x$LIBTOOL_VERSION" = "x" ] ; then + LIBTOOL_VERSION=1.4.2 +fi + + +################## +# ident function # +################## +ident ( ) { + # extract copyright from header + __copyright="`grep Copyright $AUTOGEN_SH | head -${HEAD_N}1 | awk '{print $4}'`" + if [ "x$__copyright" = "x" ] ; then + __copyright="`date +%Y`" + fi + + # extract version from CVS Id string + __id="$Id: autogen.sh 48890 2012-01-17 21:18:41Z erikgreenwald $" + __version="`echo $__id | sed 's/.*\([0-9][0-9][0-9][0-9]\)[-\/]\([0-9][0-9]\)[-\/]\([0-9][0-9]\).*/\1\2\3/'`" + if [ "x$__version" = "x" ] ; then + __version="" + fi + + echo "autogen.sh build preparation script by Christopher Sean Morrison" + echo " + config.guess download patch by Sebastian Pipping (2008-12-03)" + echo "revised 3-clause BSD-style license, copyright (c) $__copyright" + echo "script version $__version, ISO/IEC 9945 POSIX shell script" +} + + +################## +# USAGE FUNCTION # +################## +usage ( ) { + echo "Usage: $AUTOGEN_SH [-h|--help] [-v|--verbose] [-q|--quiet] [-d|--download] [--version]" + echo " --help Help on $NAME_OF_AUTOGEN usage" + echo " --verbose Verbose progress output" + echo " --quiet Quiet suppressed progress output" + echo " --download Download the latest config.guess from gnulib" + echo " --version Only perform GNU Build System version checks" + echo + echo "Description: This script will validate that minimum versions of the" + echo "GNU Build System tools are installed and then run autoreconf for you." + echo "Should autoreconf fail, manual preparation steps will be run" + echo "potentially accounting for several common preparation issues. The" + + echo "AUTORECONF, AUTOCONF, AUTOMAKE, LIBTOOLIZE, ACLOCAL, AUTOHEADER," + echo "PROJECT, & CONFIGURE environment variables and corresponding _OPTIONS" + echo "variables (e.g. AUTORECONF_OPTIONS) may be used to override the" + echo "default automatic detection behavior." + echo + + ident + + return 0 +} + + +########################## +# VERSION_ERROR FUNCTION # +########################## +version_error ( ) { + if [ "x$1" = "x" ] ; then + echo "INTERNAL ERROR: version_error was not provided a version" + exit 1 + fi + if [ "x$2" = "x" ] ; then + echo "INTERNAL ERROR: version_error was not provided an application name" + exit 1 + fi + $ECHO + $ECHO "ERROR: To prepare the ${PROJECT} build system from scratch," + $ECHO " at least version $1 of $2 must be installed." + $ECHO + $ECHO "$NAME_OF_AUTOGEN does not need to be run on the same machine that will" + $ECHO "run configure or make. Either the GNU Autotools will need to be installed" + $ECHO "or upgraded on this system, or $NAME_OF_AUTOGEN must be run on the source" + $ECHO "code on another system and then transferred to here. -- Cheers!" + $ECHO +} + +########################## +# VERSION_CHECK FUNCTION # +########################## +version_check ( ) { + if [ "x$1" = "x" ] ; then + echo "INTERNAL ERROR: version_check was not provided a minimum version" + exit 1 + fi + _min="$1" + if [ "x$2" = "x" ] ; then + echo "INTERNAL ERROR: version check was not provided a comparison version" + exit 1 + fi + _cur="$2" + + # needed to handle versions like 1.10 and 1.4-p6 + _min="`echo ${_min}. | sed 's/[^0-9]/./g' | sed 's/\.\././g'`" + _cur="`echo ${_cur}. | sed 's/[^0-9]/./g' | sed 's/\.\././g'`" + + _min_major="`echo $_min | cut -d. -f1`" + _min_minor="`echo $_min | cut -d. -f2`" + _min_patch="`echo $_min | cut -d. -f3`" + + _cur_major="`echo $_cur | cut -d. -f1`" + _cur_minor="`echo $_cur | cut -d. -f2`" + _cur_patch="`echo $_cur | cut -d. -f3`" + + if [ "x$_min_major" = "x" ] ; then + _min_major=0 + fi + if [ "x$_min_minor" = "x" ] ; then + _min_minor=0 + fi + if [ "x$_min_patch" = "x" ] ; then + _min_patch=0 + fi + if [ "x$_cur_minor" = "x" ] ; then + _cur_major=0 + fi + if [ "x$_cur_minor" = "x" ] ; then + _cur_minor=0 + fi + if [ "x$_cur_patch" = "x" ] ; then + _cur_patch=0 + fi + + $VERBOSE_ECHO "Checking if ${_cur_major}.${_cur_minor}.${_cur_patch} is greater than ${_min_major}.${_min_minor}.${_min_patch}" + + if [ $_min_major -lt $_cur_major ] ; then + return 0 + elif [ $_min_major -eq $_cur_major ] ; then + if [ $_min_minor -lt $_cur_minor ] ; then + return 0 + elif [ $_min_minor -eq $_cur_minor ] ; then + if [ $_min_patch -lt $_cur_patch ] ; then + return 0 + elif [ $_min_patch -eq $_cur_patch ] ; then + return 0 + fi + fi + fi + return 1 +} + + +###################################### +# LOCATE_CONFIGURE_TEMPLATE FUNCTION # +###################################### +locate_configure_template ( ) { + _pwd="`pwd`" + if test -f "./configure.ac" ; then + echo "./configure.ac" + elif test -f "./configure.in" ; then + echo "./configure.in" + elif test -f "$_pwd/configure.ac" ; then + echo "$_pwd/configure.ac" + elif test -f "$_pwd/configure.in" ; then + echo "$_pwd/configure.in" + elif test -f "$PATH_TO_AUTOGEN/configure.ac" ; then + echo "$PATH_TO_AUTOGEN/configure.ac" + elif test -f "$PATH_TO_AUTOGEN/configure.in" ; then + echo "$PATH_TO_AUTOGEN/configure.in" + fi +} + + +################## +# argument check # +################## +ARGS="$*" +PATH_TO_AUTOGEN="`dirname $0`" +NAME_OF_AUTOGEN="`basename $0`" +AUTOGEN_SH="$PATH_TO_AUTOGEN/$NAME_OF_AUTOGEN" + +LIBTOOL_M4="${PATH_TO_AUTOGEN}/misc/libtool.m4" + +if [ "x$HELP" = "x" ] ; then + HELP=no +fi +if [ "x$QUIET" = "x" ] ; then + QUIET=no +fi +if [ "x$VERBOSE" = "x" ] ; then + VERBOSE=no +fi +if [ "x$VERSION_ONLY" = "x" ] ; then + VERSION_ONLY=no +fi +if [ "x$DOWNLOAD" = "x" ] ; then + DOWNLOAD=no +fi +if [ "x$AUTORECONF_OPTIONS" = "x" ] ; then + AUTORECONF_OPTIONS="-i -f" +fi +if [ "x$AUTOCONF_OPTIONS" = "x" ] ; then + AUTOCONF_OPTIONS="-f" +fi +if [ "x$AUTOMAKE_OPTIONS" = "x" ] ; then + AUTOMAKE_OPTIONS="-a -c -f" +fi +ALT_AUTOMAKE_OPTIONS="-a -c" +if [ "x$LIBTOOLIZE_OPTIONS" = "x" ] ; then + LIBTOOLIZE_OPTIONS="--automake -c -f" +fi +ALT_LIBTOOLIZE_OPTIONS="--automake --copy --force" +if [ "x$ACLOCAL_OPTIONS" = "x" ] ; then + ACLOCAL_OPTIONS="" +fi +if [ "x$AUTOHEADER_OPTIONS" = "x" ] ; then + AUTOHEADER_OPTIONS="" +fi +if [ "x$CONFIG_GUESS_URL" = "x" ] ; then + CONFIG_GUESS_URL="http://git.savannah.gnu.org/gitweb/?p=gnulib.git;a=blob_plain;f=build-aux/config.guess;hb=HEAD" +fi +for arg in $ARGS ; do + case "x$arg" in + x--help) HELP=yes ;; + x-[hH]) HELP=yes ;; + x--quiet) QUIET=yes ;; + x-[qQ]) QUIET=yes ;; + x--verbose) VERBOSE=yes ;; + x-[dD]) DOWNLOAD=yes ;; + x--download) DOWNLOAD=yes ;; + x-[vV]) VERBOSE=yes ;; + x--version) VERSION_ONLY=yes ;; + *) + echo "Unknown option: $arg" + echo + usage + exit 1 + ;; + esac +done + + +##################### +# environment check # +##################### + +# sanity check before recursions potentially begin +if [ ! -f "$AUTOGEN_SH" ] ; then + if test -f ./autogen.sh ; then + PATH_TO_AUTOGEN="." + NAME_OF_AUTOGEN="autogen.sh" + AUTOGEN_SH="$PATH_TO_AUTOGEN/$NAME_OF_AUTOGEN" + else + echo "INTERNAL ERROR: $AUTOGEN_SH does not exist" + exit 1 + fi +fi + +# force locale setting to C so things like date output as expected +LC_ALL=C + +# commands that this script expects +for __cmd in echo head tail pwd ; do + echo "test" > /dev/null 2>&1 | $__cmd > /dev/null 2>&1 + if [ $? != 0 ] ; then + echo "INTERNAL ERROR: '${__cmd}' command is required" + exit 2 + fi +done +echo "test" | grep "test" > /dev/null 2>&1 +if test ! x$? = x0 ; then + echo "INTERNAL ERROR: grep command is required" + exit 1 +fi +echo "test" | sed "s/test/test/" > /dev/null 2>&1 +if test ! x$? = x0 ; then + echo "INTERNAL ERROR: sed command is required" + exit 1 +fi + + +# determine the behavior of echo +case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in + *c*,-n*) ECHO_N= ECHO_C=' +' ECHO_T=' ' ;; + *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;; + *) ECHO_N= ECHO_C='\c' ECHO_T= ;; +esac + +# determine the behavior of head +case "x`echo 'head' | head -n 1 2>&1`" in + *xhead*) HEAD_N="n " ;; + *) HEAD_N="" ;; +esac + +# determine the behavior of tail +case "x`echo 'tail' | tail -n 1 2>&1`" in + *xtail*) TAIL_N="n " ;; + *) TAIL_N="" ;; +esac + + +VERBOSE_ECHO=: +ECHO=: +if [ "x$QUIET" = "xyes" ] ; then + if [ "x$VERBOSE" = "xyes" ] ; then + echo "Verbose output quelled by quiet option. Further output disabled." + fi +else + ECHO=echo + if [ "x$VERBOSE" = "xyes" ] ; then + echo "Verbose output enabled" + VERBOSE_ECHO=echo + fi +fi + + +# allow a recursive run to disable further recursions +if [ "x$RUN_RECURSIVE" = "x" ] ; then + RUN_RECURSIVE=yes +fi + + +################################################ +# check for help arg and bypass version checks # +################################################ +if [ "x`echo $ARGS | sed 's/.*[hH][eE][lL][pP].*/help/'`" = "xhelp" ] ; then + HELP=yes +fi +if [ "x$HELP" = "xyes" ] ; then + usage + $ECHO "---" + $ECHO "Help was requested. No preparation or configuration will be performed." + exit 0 +fi + + +####################### +# set up signal traps # +####################### +untrap_abnormal ( ) { + for sig in 1 2 13 15; do + trap - $sig + done +} + +# do this cleanup whenever we exit. +trap ' + # start from the root + if test -d "$START_PATH" ; then + cd "$START_PATH" + fi + + # restore/delete backup files + if test "x$PFC_INIT" = "x1" ; then + recursive_restore + fi +' 0 + +# trap SIGHUP (1), SIGINT (2), SIGPIPE (13), SIGTERM (15) +for sig in 1 2 13 15; do + trap ' + $ECHO "" + $ECHO "Aborting $NAME_OF_AUTOGEN: caught signal '$sig'" + + # start from the root + if test -d "$START_PATH" ; then + cd "$START_PATH" + fi + + # clean up on abnormal exit + $VERBOSE_ECHO "rm -rf autom4te.cache" + rm -rf autom4te.cache + + if test -f "acinclude.m4.$$.backup" ; then + $VERBOSE_ECHO "cat acinclude.m4.$$.backup > acinclude.m4" + chmod u+w acinclude.m4 + cat acinclude.m4.$$.backup > acinclude.m4 + + $VERBOSE_ECHO "rm -f acinclude.m4.$$.backup" + rm -f acinclude.m4.$$.backup + fi + + { (exit 1); exit 1; } +' $sig +done + + +############################# +# look for a configure file # +############################# +if [ "x$CONFIGURE" = "x" ] ; then + CONFIGURE="`locate_configure_template`" + if [ ! "x$CONFIGURE" = "x" ] ; then + $VERBOSE_ECHO "Found a configure template: $CONFIGURE" + fi +else + $ECHO "Using CONFIGURE environment variable override: $CONFIGURE" +fi +if [ "x$CONFIGURE" = "x" ] ; then + if [ "x$VERSION_ONLY" = "xyes" ] ; then + CONFIGURE=/dev/null + else + $ECHO + $ECHO "A configure.ac or configure.in file could not be located implying" + $ECHO "that the GNU Build System is at least not used in this directory. In" + $ECHO "any case, there is nothing to do here without one of those files." + $ECHO + $ECHO "ERROR: No configure.in or configure.ac file found in `pwd`" + exit 1 + fi +fi + +#################### +# get project name # +#################### +if [ "x$PROJECT" = "x" ] ; then + PROJECT="`grep AC_INIT $CONFIGURE | grep -v '.*#.*AC_INIT' | tail -${TAIL_N}1 | sed 's/^[ ]*AC_INIT(\([^,)]*\).*/\1/' | sed 's/.*\[\(.*\)\].*/\1/'`" + if [ "x$PROJECT" = "xAC_INIT" ] ; then + # projects might be using the older/deprecated arg-less AC_INIT .. look for AM_INIT_AUTOMAKE instead + PROJECT="`grep AM_INIT_AUTOMAKE $CONFIGURE | grep -v '.*#.*AM_INIT_AUTOMAKE' | tail -${TAIL_N}1 | sed 's/^[ ]*AM_INIT_AUTOMAKE(\([^,)]*\).*/\1/' | sed 's/.*\[\(.*\)\].*/\1/'`" + fi + if [ "x$PROJECT" = "xAM_INIT_AUTOMAKE" ] ; then + PROJECT="project" + fi + if [ "x$PROJECT" = "x" ] ; then + PROJECT="project" + fi +else + $ECHO "Using PROJECT environment variable override: $PROJECT" +fi +$ECHO "Preparing the $PROJECT build system...please wait" +$ECHO + + +######################## +# check for autoreconf # +######################## +HAVE_AUTORECONF=no +if [ "x$AUTORECONF" = "x" ] ; then + for AUTORECONF in autoreconf ; do + $VERBOSE_ECHO "Checking autoreconf version: $AUTORECONF --version" + $AUTORECONF --version > /dev/null 2>&1 + if [ $? = 0 ] ; then + HAVE_AUTORECONF=yes + break + fi + done +else + HAVE_AUTORECONF=yes + $ECHO "Using AUTORECONF environment variable override: $AUTORECONF" +fi + + +########################## +# autoconf version check # +########################## +_acfound=no +if [ "x$AUTOCONF" = "x" ] ; then + for AUTOCONF in autoconf ; do + $VERBOSE_ECHO "Checking autoconf version: $AUTOCONF --version" + $AUTOCONF --version > /dev/null 2>&1 + if [ $? = 0 ] ; then + _acfound=yes + break + fi + done +else + _acfound=yes + $ECHO "Using AUTOCONF environment variable override: $AUTOCONF" +fi + +_report_error=no +if [ ! "x$_acfound" = "xyes" ] ; then + $ECHO "ERROR: Unable to locate GNU Autoconf." + _report_error=yes +else + _version="`$AUTOCONF --version | head -${HEAD_N}1 | sed 's/[^0-9]*\([0-9\.][0-9\.]*\)/\1/'`" + if [ "x$_version" = "x" ] ; then + _version="0.0.0" + fi + $ECHO "Found GNU Autoconf version $_version" + version_check "$AUTOCONF_VERSION" "$_version" + if [ $? -ne 0 ] ; then + _report_error=yes + fi +fi +if [ "x$_report_error" = "xyes" ] ; then + version_error "$AUTOCONF_VERSION" "GNU Autoconf" + exit 1 +fi + + +########################## +# automake version check # +########################## +_amfound=no +if [ "x$AUTOMAKE" = "x" ] ; then + for AUTOMAKE in automake ; do + $VERBOSE_ECHO "Checking automake version: $AUTOMAKE --version" + $AUTOMAKE --version > /dev/null 2>&1 + if [ $? = 0 ] ; then + _amfound=yes + break + fi + done +else + _amfound=yes + $ECHO "Using AUTOMAKE environment variable override: $AUTOMAKE" +fi + + +_report_error=no +if [ ! "x$_amfound" = "xyes" ] ; then + $ECHO + $ECHO "ERROR: Unable to locate GNU Automake." + _report_error=yes +else + _version="`$AUTOMAKE --version | head -${HEAD_N}1 | sed 's/[^0-9]*\([0-9\.][0-9\.]*\)/\1/'`" + if [ "x$_version" = "x" ] ; then + _version="0.0.0" + fi + $ECHO "Found GNU Automake version $_version" + version_check "$AUTOMAKE_VERSION" "$_version" + if [ $? -ne 0 ] ; then + _report_error=yes + fi +fi +if [ "x$_report_error" = "xyes" ] ; then + version_error "$AUTOMAKE_VERSION" "GNU Automake" + exit 1 +fi + + +######################## +# check for libtoolize # +######################## +HAVE_LIBTOOLIZE=yes +HAVE_ALT_LIBTOOLIZE=no +_ltfound=no +if [ "x$LIBTOOLIZE" = "x" ] ; then + LIBTOOLIZE=libtoolize + $VERBOSE_ECHO "Checking libtoolize version: $LIBTOOLIZE --version" + $LIBTOOLIZE --version > /dev/null 2>&1 + if [ ! $? = 0 ] ; then + HAVE_LIBTOOLIZE=no + $ECHO + if [ "x$HAVE_AUTORECONF" = "xno" ] ; then + $ECHO "Warning: libtoolize does not appear to be available." + else + $ECHO "Warning: libtoolize does not appear to be available. This means that" + $ECHO "the automatic build preparation via autoreconf will probably not work." + $ECHO "Preparing the build by running each step individually, however, should" + $ECHO "work and will be done automatically for you if autoreconf fails." + fi + + # look for some alternates + for tool in glibtoolize libtoolize15 libtoolize14 libtoolize13 ; do + $VERBOSE_ECHO "Checking libtoolize alternate: $tool --version" + _glibtoolize="`$tool --version > /dev/null 2>&1`" + if [ $? = 0 ] ; then + $VERBOSE_ECHO "Found $tool --version" + _glti="`which $tool`" + if [ "x$_glti" = "x" ] ; then + $VERBOSE_ECHO "Cannot find $tool with which" + continue; + fi + if test ! -f "$_glti" ; then + $VERBOSE_ECHO "Cannot use $tool, $_glti is not a file" + continue; + fi + _gltidir="`dirname $_glti`" + if [ "x$_gltidir" = "x" ] ; then + $VERBOSE_ECHO "Cannot find $tool path with dirname of $_glti" + continue; + fi + if test ! -d "$_gltidir" ; then + $VERBOSE_ECHO "Cannot use $tool, $_gltidir is not a directory" + continue; + fi + HAVE_ALT_LIBTOOLIZE=yes + LIBTOOLIZE="$tool" + $ECHO + $ECHO "Fortunately, $tool was found which means that your system may simply" + $ECHO "have a non-standard or incomplete GNU Autotools install. If you have" + $ECHO "sufficient system access, it may be possible to quell this warning by" + $ECHO "running:" + $ECHO + sudo -V > /dev/null 2>&1 + if [ $? = 0 ] ; then + $ECHO " sudo ln -s $_glti $_gltidir/libtoolize" + $ECHO + else + $ECHO " ln -s $_glti $_gltidir/libtoolize" + $ECHO + $ECHO "Run that as root or with proper permissions to the $_gltidir directory" + $ECHO + fi + _ltfound=yes + break + fi + done + else + _ltfound=yes + fi +else + _ltfound=yes + $ECHO "Using LIBTOOLIZE environment variable override: $LIBTOOLIZE" +fi + + +############################ +# libtoolize version check # +############################ +_report_error=no +if [ ! "x$_ltfound" = "xyes" ] ; then + $ECHO + $ECHO "ERROR: Unable to locate GNU Libtool." + _report_error=yes +else + _version="`$LIBTOOLIZE --version | head -${HEAD_N}1 | sed 's/[^0-9]*\([0-9\.][0-9\.]*\)/\1/'`" + if [ "x$_version" = "x" ] ; then + _version="0.0.0" + fi + $ECHO "Found GNU Libtool version $_version" + version_check "$LIBTOOL_VERSION" "$_version" + if [ $? -ne 0 ] ; then + _report_error=yes + fi +fi +if [ "x$_report_error" = "xyes" ] ; then + version_error "$LIBTOOL_VERSION" "GNU Libtool" + exit 1 +fi + + +##################### +# check for aclocal # +##################### +if [ "x$ACLOCAL" = "x" ] ; then + for ACLOCAL in aclocal ; do + $VERBOSE_ECHO "Checking aclocal version: $ACLOCAL --version" + $ACLOCAL --version > /dev/null 2>&1 + if [ $? = 0 ] ; then + break + fi + done +else + $ECHO "Using ACLOCAL environment variable override: $ACLOCAL" +fi + + +######################## +# check for autoheader # +######################## +if [ "x$AUTOHEADER" = "x" ] ; then + for AUTOHEADER in autoheader ; do + $VERBOSE_ECHO "Checking autoheader version: $AUTOHEADER --version" + $AUTOHEADER --version > /dev/null 2>&1 + if [ $? = 0 ] ; then + break + fi + done +else + $ECHO "Using AUTOHEADER environment variable override: $AUTOHEADER" +fi + + +######################### +# check if version only # +######################### +$VERBOSE_ECHO "Checking whether to only output version information" +if [ "x$VERSION_ONLY" = "xyes" ] ; then + $ECHO + ident + $ECHO "---" + $ECHO "Version requested. No preparation or configuration will be performed." + exit 0 +fi + + +################################# +# PROTECT_FROM_CLOBBER FUNCTION # +################################# +protect_from_clobber ( ) { + PFC_INIT=1 + + # protect COPYING & INSTALL from overwrite by automake. the + # automake force option will (inappropriately) ignore the existing + # contents of a COPYING and/or INSTALL files (depending on the + # version) instead of just forcing *missing* files like it does + # for AUTHORS, NEWS, and README. this is broken but extremely + # prevalent behavior, so we protect against it by keeping a backup + # of the file that can later be restored. + + for file in COPYING INSTALL ; do + if test -f ${file} ; then + if test -f ${file}.$$.protect_from_automake.backup ; then + $VERBOSE_ECHO "Already backed up ${file} in `pwd`" + else + $VERBOSE_ECHO "Backing up ${file} in `pwd`" + $VERBOSE_ECHO "cp -p ${file} ${file}.$$.protect_from_automake.backup" + cp -p ${file} ${file}.$$.protect_from_automake.backup + fi + fi + done +} + + +############################## +# RECURSIVE_PROTECT FUNCTION # +############################## +recursive_protect ( ) { + + # for projects using recursive configure, run the build + # preparation steps for the subdirectories. this function assumes + # START_PATH was set to pwd before recursion begins so that + # relative paths work. + + # git 'r done, protect COPYING and INSTALL from being clobbered + protect_from_clobber + + if test -d autom4te.cache ; then + $VERBOSE_ECHO "Found an autom4te.cache directory, deleting it" + $VERBOSE_ECHO "rm -rf autom4te.cache" + rm -rf autom4te.cache + fi + + # find configure template + _configure="`locate_configure_template`" + if [ "x$_configure" = "x" ] ; then + return + fi + # $VERBOSE_ECHO "Looking for configure template found `pwd`/$_configure" + + # look for subdirs + # $VERBOSE_ECHO "Looking for subdirs in `pwd`" + _det_config_subdirs="`grep AC_CONFIG_SUBDIRS $_configure | grep -v '.*#.*AC_CONFIG_SUBDIRS' | sed 's/^[ ]*AC_CONFIG_SUBDIRS(\(.*\)).*/\1/' | sed 's/.*\[\(.*\)\].*/\1/'`" + CHECK_DIRS="" + for dir in $_det_config_subdirs ; do + if test -d "`pwd`/$dir" ; then + CHECK_DIRS="$CHECK_DIRS \"`pwd`/$dir\"" + fi + done + + # process subdirs + if [ ! "x$CHECK_DIRS" = "x" ] ; then + $VERBOSE_ECHO "Recursively scanning the following directories:" + $VERBOSE_ECHO " $CHECK_DIRS" + for dir in $CHECK_DIRS ; do + $VERBOSE_ECHO "Protecting files from automake in $dir" + cd "$START_PATH" + eval "cd $dir" + + # recursively git 'r done + recursive_protect + done + fi +} # end of recursive_protect + + +############################# +# RESTORE_CLOBBERED FUNCION # +############################# +restore_clobbered ( ) { + + # The automake (and autoreconf by extension) -f/--force-missing + # option may overwrite COPYING and INSTALL even if they do exist. + # Here we restore the files if necessary. + + spacer=no + + for file in COPYING INSTALL ; do + if test -f ${file}.$$.protect_from_automake.backup ; then + if test -f ${file} ; then + # compare entire content, restore if needed + if test "x`cat ${file}`" != "x`cat ${file}.$$.protect_from_automake.backup`" ; then + if test "x$spacer" = "xno" ; then + $VERBOSE_ECHO + spacer=yes + fi + # restore the backup + $VERBOSE_ECHO "Restoring ${file} from backup (automake -f likely clobbered it)" + $VERBOSE_ECHO "rm -f ${file}" + rm -f ${file} + $VERBOSE_ECHO "mv ${file}.$$.protect_from_automake.backup ${file}" + mv ${file}.$$.protect_from_automake.backup ${file} + fi # check contents + elif test -f ${file}.$$.protect_from_automake.backup ; then + $VERBOSE_ECHO "mv ${file}.$$.protect_from_automake.backup ${file}" + mv ${file}.$$.protect_from_automake.backup ${file} + fi # -f ${file} + + # just in case + $VERBOSE_ECHO "rm -f ${file}.$$.protect_from_automake.backup" + rm -f ${file}.$$.protect_from_automake.backup + fi # -f ${file}.$$.protect_from_automake.backup + done + + CONFIGURE="`locate_configure_template`" + if [ "x$CONFIGURE" = "x" ] ; then + return + fi + + _aux_dir="`grep AC_CONFIG_AUX_DIR $CONFIGURE | grep -v '.*#.*AC_CONFIG_AUX_DIR' | tail -${TAIL_N}1 | sed 's/^[ ]*AC_CONFIG_AUX_DIR(\(.*\)).*/\1/' | sed 's/.*\[\(.*\)\].*/\1/'`" + if test ! -d "$_aux_dir" ; then + _aux_dir=. + fi + + for file in config.guess config.sub ltmain.sh ; do + if test -f "${_aux_dir}/${file}" ; then + $VERBOSE_ECHO "rm -f \"${_aux_dir}/${file}.backup\"" + rm -f "${_aux_dir}/${file}.backup" + fi + done +} # end of restore_clobbered + + +############################## +# RECURSIVE_RESTORE FUNCTION # +############################## +recursive_restore ( ) { + + # restore COPYING and INSTALL from backup if they were clobbered + # for each directory recursively. + + # git 'r undone + restore_clobbered + + # find configure template + _configure="`locate_configure_template`" + if [ "x$_configure" = "x" ] ; then + return + fi + + # look for subdirs + _det_config_subdirs="`grep AC_CONFIG_SUBDIRS $_configure | grep -v '.*#.*AC_CONFIG_SUBDIRS' | sed 's/^[ ]*AC_CONFIG_SUBDIRS(\(.*\)).*/\1/' | sed 's/.*\[\(.*\)\].*/\1/'`" + CHECK_DIRS="" + for dir in $_det_config_subdirs ; do + if test -d "`pwd`/$dir" ; then + CHECK_DIRS="$CHECK_DIRS \"`pwd`/$dir\"" + fi + done + + # process subdirs + if [ ! "x$CHECK_DIRS" = "x" ] ; then + $VERBOSE_ECHO "Recursively scanning the following directories:" + $VERBOSE_ECHO " $CHECK_DIRS" + for dir in $CHECK_DIRS ; do + $VERBOSE_ECHO "Checking files for automake damage in $dir" + cd "$START_PATH" + eval "cd $dir" + + # recursively git 'r undone + recursive_restore + done + fi +} # end of recursive_restore + + +####################### +# INITIALIZE FUNCTION # +####################### +initialize ( ) { + + # this routine performs a variety of directory-specific + # initializations. some are sanity checks, some are preventive, + # and some are necessary setup detection. + # + # this function sets: + # CONFIGURE + # SEARCH_DIRS + # CONFIG_SUBDIRS + + ################################## + # check for a configure template # + ################################## + CONFIGURE="`locate_configure_template`" + if [ "x$CONFIGURE" = "x" ] ; then + $ECHO + $ECHO "A configure.ac or configure.in file could not be located implying" + $ECHO "that the GNU Build System is at least not used in this directory. In" + $ECHO "any case, there is nothing to do here without one of those files." + $ECHO + $ECHO "ERROR: No configure.in or configure.ac file found in `pwd`" + exit 1 + fi + + ##################### + # detect an aux dir # + ##################### + _aux_dir="`grep AC_CONFIG_AUX_DIR $CONFIGURE | grep -v '.*#.*AC_CONFIG_AUX_DIR' | tail -${TAIL_N}1 | sed 's/^[ ]*AC_CONFIG_AUX_DIR(\(.*\)).*/\1/' | sed 's/.*\[\(.*\)\].*/\1/'`" + if test ! -d "$_aux_dir" ; then + _aux_dir=. + else + $VERBOSE_ECHO "Detected auxillary directory: $_aux_dir" + fi + + ################################ + # detect a recursive configure # + ################################ + CONFIG_SUBDIRS="" + _det_config_subdirs="`grep AC_CONFIG_SUBDIRS $CONFIGURE | grep -v '.*#.*AC_CONFIG_SUBDIRS' | sed 's/^[ ]*AC_CONFIG_SUBDIRS(\(.*\)).*/\1/' | sed 's/.*\[\(.*\)\].*/\1/'`" + for dir in $_det_config_subdirs ; do + if test -d "`pwd`/$dir" ; then + $VERBOSE_ECHO "Detected recursive configure directory: `pwd`/$dir" + CONFIG_SUBDIRS="$CONFIG_SUBDIRS `pwd`/$dir" + fi + done + + ########################################################### + # make sure certain required files exist for GNU projects # + ########################################################### + _marker_found="" + _marker_found_message_intro='Detected non-GNU marker "' + _marker_found_message_mid='" in ' + for marker in foreign cygnus ; do + _marker_found_message=${_marker_found_message_intro}${marker}${_marker_found_message_mid} + _marker_found="`grep 'AM_INIT_AUTOMAKE.*'${marker} $CONFIGURE`" + if [ ! "x$_marker_found" = "x" ] ; then + $VERBOSE_ECHO "${_marker_found_message}`basename \"$CONFIGURE\"`" + break + fi + __makefile=`dirname \"$CONFIGURE\"/Makefile.am` + if test -f "$__makefile" ; then + _marker_found="`grep 'AUTOMAKE_OPTIONS.*'${marker} $__makefile`" + if [ ! "x$_marker_found" = "x" ] ; then + $VERBOSE_ECHO "${_marker_found_message}${__makefile}" + break + fi + fi + done + if [ "x${_marker_found}" = "x" ] ; then + _suggest_foreign=no + for file in AUTHORS COPYING ChangeLog INSTALL NEWS README ; do + if [ ! -f $file ] ; then + $VERBOSE_ECHO "Touching ${file} since it does not exist" + _suggest_foreign=yes + touch $file + fi + done + + if [ "x${_suggest_foreign}" = "xyes" ] ; then + $ECHO + $ECHO "Warning: Several files expected of projects that conform to the GNU" + $ECHO "coding standards were not found. The files were automatically added" + $ECHO "for you since you do not have a 'foreign' declaration specified." + $ECHO + $ECHO "Consider adding 'foreign' to AM_INIT_AUTOMAKE in `basename \"$CONFIGURE\"`" + __makefile=`dirname \"$CONFIGURE\"/Makefile.am` + if test -f "$__makefile" ; then + $ECHO "or to AUTOMAKE_OPTIONS in your top-level Makefile.am file." + fi + $ECHO + fi + fi + + ################################################## + # make sure certain generated files do not exist # + ################################################## + for file in config.guess config.sub ltmain.sh ; do + if test -f "${_aux_dir}/${file}" ; then + $VERBOSE_ECHO "mv -f \"${_aux_dir}/${file}\" \"${_aux_dir}/${file}.backup\"" + mv -f "${_aux_dir}/${file}" "${_aux_dir}/${file}.backup" + fi + done + + ############################ + # search alternate m4 dirs # + ############################ + SEARCH_DIRS="" + for dir in m4 ; do + if [ -d $dir ] ; then + $VERBOSE_ECHO "Found extra aclocal search directory: $dir" + SEARCH_DIRS="$SEARCH_DIRS -I `pwd`/$dir" + fi + done + + ###################################### + # remove any previous build products # + ###################################### + if test -d autom4te.cache ; then + $VERBOSE_ECHO "Found an autom4te.cache directory, deleting it" + $VERBOSE_ECHO "rm -rf autom4te.cache" + rm -rf autom4te.cache + fi +# tcl/tk (and probably others) have a customized aclocal.m4, so can't delete it +# if test -f aclocal.m4 ; then +# $VERBOSE_ECHO "Found an aclocal.m4 file, deleting it" +# $VERBOSE_ECHO "rm -f aclocal.m4" +# rm -f aclocal.m4 +# fi + +} # end of initialize() + + +############## +# initialize # +############## + +# stash path +START_PATH="`pwd`" + +# Before running autoreconf or manual steps, some prep detection work +# is necessary or useful. Only needs to occur once per directory, but +# does need to traverse the entire subconfigure hierarchy to protect +# files from being clobbered even by autoreconf. +recursive_protect + +# start from where we started +cd "$START_PATH" + +# get ready to process +initialize + + +######################################### +# DOWNLOAD_GNULIB_CONFIG_GUESS FUNCTION # +######################################### + +# TODO - should make sure wget/curl exist and/or work before trying to +# use them. + +download_gnulib_config_guess () { + # abuse gitweb to download gnulib's latest config.guess via HTTP + config_guess_temp="config.guess.$$.download" + ret=1 + for __cmd in wget curl fetch ; do + $VERBOSE_ECHO "Checking for command ${__cmd}" + ${__cmd} --version > /dev/null 2>&1 + ret=$? + if [ ! $ret = 0 ] ; then + continue + fi + + __cmd_version=`${__cmd} --version | head -n 1 | sed -e 's/^[^0-9]\+//' -e 's/ .*//'` + $VERBOSE_ECHO "Found ${__cmd} ${__cmd_version}" + + opts="" + case ${__cmd} in + wget) + opts="-O" + ;; + curl) + opts="-o" + ;; + fetch) + opts="-t 5 -f" + ;; + esac + + $VERBOSE_ECHO "Running $__cmd \"${CONFIG_GUESS_URL}\" $opts \"${config_guess_temp}\"" + eval "$__cmd \"${CONFIG_GUESS_URL}\" $opts \"${config_guess_temp}\"" > /dev/null 2>&1 + if [ $? = 0 ] ; then + mv -f "${config_guess_temp}" ${_aux_dir}/config.guess + ret=0 + break + fi + done + + if [ ! $ret = 0 ] ; then + $ECHO "Warning: config.guess download failed from: $CONFIG_GUESS_URL" + rm -f "${config_guess_temp}" + fi +} + + +############################## +# LIBTOOLIZE_NEEDED FUNCTION # +############################## +libtoolize_needed () { + ret=1 # means no, don't need libtoolize + for feature in AC_PROG_LIBTOOL AM_PROG_LIBTOOL LT_INIT ; do + $VERBOSE_ECHO "Searching for $feature in $CONFIGURE" + found="`grep \"^$feature.*\" $CONFIGURE`" + if [ ! "x$found" = "x" ] ; then + ret=0 # means yes, need to run libtoolize + break + fi + done + return ${ret} +} + + + +############################################ +# prepare build via autoreconf or manually # +############################################ +reconfigure_manually=no +if [ "x$HAVE_AUTORECONF" = "xyes" ] ; then + $ECHO + $ECHO $ECHO_N "Automatically preparing build ... $ECHO_C" + + $VERBOSE_ECHO "$AUTORECONF $SEARCH_DIRS $AUTORECONF_OPTIONS" + autoreconf_output="`$AUTORECONF $SEARCH_DIRS $AUTORECONF_OPTIONS 2>&1`" + ret=$? + $VERBOSE_ECHO "$autoreconf_output" + + if [ ! $ret = 0 ] ; then + if [ "x$HAVE_ALT_LIBTOOLIZE" = "xyes" ] ; then + if [ ! "x`echo \"$autoreconf_output\" | grep libtoolize | grep \"No such file or directory\"`" = "x" ] ; then + $ECHO + $ECHO "Warning: autoreconf failed but due to what is usually a common libtool" + $ECHO "misconfiguration issue. This problem is encountered on systems that" + $ECHO "have installed libtoolize under a different name without providing a" + $ECHO "symbolic link or without setting the LIBTOOLIZE environment variable." + $ECHO + $ECHO "Restarting the preparation steps with LIBTOOLIZE set to $LIBTOOLIZE" + + export LIBTOOLIZE + RUN_RECURSIVE=no + export RUN_RECURSIVE + untrap_abnormal + + $VERBOSE_ECHO sh $AUTOGEN_SH "$1" "$2" "$3" "$4" "$5" "$6" "$7" "$8" "$9" + sh "$AUTOGEN_SH" "$1" "$2" "$3" "$4" "$5" "$6" "$7" "$8" "$9" + exit $? + fi + fi + + $ECHO "Warning: $AUTORECONF failed" + + if test -f ltmain.sh ; then + $ECHO "libtoolize being run by autoreconf is not creating ltmain.sh in the auxillary directory like it should" + fi + + $ECHO "Attempting to run the preparation steps individually" + reconfigure_manually=yes + else + if [ "x$DOWNLOAD" = "xyes" ] ; then + if libtoolize_needed ; then + download_gnulib_config_guess + fi + fi + fi +else + reconfigure_manually=yes +fi + + +############################ +# LIBTOOL_FAILURE FUNCTION # +############################ +libtool_failure ( ) { + + # libtool is rather error-prone in comparison to the other + # autotools and this routine attempts to compensate for some + # common failures. the output after a libtoolize failure is + # parsed for an error related to AC_PROG_LIBTOOL and if found, we + # attempt to inject a project-provided libtool.m4 file. + + _autoconf_output="$1" + + if [ "x$RUN_RECURSIVE" = "xno" ] ; then + # we already tried the libtool.m4, don't try again + return 1 + fi + + if test -f "$LIBTOOL_M4" ; then + found_libtool="`$ECHO $_autoconf_output | grep AC_PROG_LIBTOOL`" + if test ! "x$found_libtool" = "x" ; then + if test -f acinclude.m4 ; then + rm -f acinclude.m4.$$.backup + $VERBOSE_ECHO "cat acinclude.m4 > acinclude.m4.$$.backup" + cat acinclude.m4 > acinclude.m4.$$.backup + fi + $VERBOSE_ECHO "cat \"$LIBTOOL_M4\" >> acinclude.m4" + chmod u+w acinclude.m4 + cat "$LIBTOOL_M4" >> acinclude.m4 + + # don't keep doing this + RUN_RECURSIVE=no + export RUN_RECURSIVE + untrap_abnormal + + $ECHO + $ECHO "Restarting the preparation steps with libtool macros in acinclude.m4" + $VERBOSE_ECHO sh $AUTOGEN_SH "$1" "$2" "$3" "$4" "$5" "$6" "$7" "$8" "$9" + sh "$AUTOGEN_SH" "$1" "$2" "$3" "$4" "$5" "$6" "$7" "$8" "$9" + exit $? + fi + fi +} + + +########################### +# MANUAL_AUTOGEN FUNCTION # +########################### +manual_autogen ( ) { + + ################################################## + # Manual preparation steps taken are as follows: # + # aclocal [-I m4] # + # libtoolize --automake -c -f # + # aclocal [-I m4] # + # autoconf -f # + # autoheader # + # automake -a -c -f # + ################################################## + + ########### + # aclocal # + ########### + $VERBOSE_ECHO "$ACLOCAL $SEARCH_DIRS $ACLOCAL_OPTIONS" + aclocal_output="`$ACLOCAL $SEARCH_DIRS $ACLOCAL_OPTIONS 2>&1`" + ret=$? + $VERBOSE_ECHO "$aclocal_output" + if [ ! $ret = 0 ] ; then $ECHO "ERROR: $ACLOCAL failed" && exit 2 ; fi + + ############## + # libtoolize # + ############## + if libtoolize_needed ; then + if [ "x$HAVE_LIBTOOLIZE" = "xyes" ] ; then + $VERBOSE_ECHO "$LIBTOOLIZE $LIBTOOLIZE_OPTIONS" + libtoolize_output="`$LIBTOOLIZE $LIBTOOLIZE_OPTIONS 2>&1`" + ret=$? + $VERBOSE_ECHO "$libtoolize_output" + + if [ ! $ret = 0 ] ; then $ECHO "ERROR: $LIBTOOLIZE failed" && exit 2 ; fi + else + if [ "x$HAVE_ALT_LIBTOOLIZE" = "xyes" ] ; then + $VERBOSE_ECHO "$LIBTOOLIZE $ALT_LIBTOOLIZE_OPTIONS" + libtoolize_output="`$LIBTOOLIZE $ALT_LIBTOOLIZE_OPTIONS 2>&1`" + ret=$? + $VERBOSE_ECHO "$libtoolize_output" + + if [ ! $ret = 0 ] ; then $ECHO "ERROR: $LIBTOOLIZE failed" && exit 2 ; fi + fi + fi + + ########### + # aclocal # + ########### + # re-run again as instructed by libtoolize + $VERBOSE_ECHO "$ACLOCAL $SEARCH_DIRS $ACLOCAL_OPTIONS" + aclocal_output="`$ACLOCAL $SEARCH_DIRS $ACLOCAL_OPTIONS 2>&1`" + ret=$? + $VERBOSE_ECHO "$aclocal_output" + + # libtoolize might put ltmain.sh in the wrong place + if test -f ltmain.sh ; then + if test ! -f "${_aux_dir}/ltmain.sh" ; then + $ECHO + $ECHO "Warning: $LIBTOOLIZE is creating ltmain.sh in the wrong directory" + $ECHO + $ECHO "Fortunately, the problem can be worked around by simply copying the" + $ECHO "file to the appropriate location (${_aux_dir}/). This has been done for you." + $ECHO + $VERBOSE_ECHO "cp -p ltmain.sh \"${_aux_dir}/ltmain.sh\"" + cp -p ltmain.sh "${_aux_dir}/ltmain.sh" + $ECHO $ECHO_N "Continuing build preparation ... $ECHO_C" + fi + fi # ltmain.sh + + if [ "x$DOWNLOAD" = "xyes" ] ; then + download_gnulib_config_guess + fi + fi # libtoolize_needed + + ############ + # autoconf # + ############ + $VERBOSE_ECHO + $VERBOSE_ECHO "$AUTOCONF $AUTOCONF_OPTIONS" + autoconf_output="`$AUTOCONF $AUTOCONF_OPTIONS 2>&1`" + ret=$? + $VERBOSE_ECHO "$autoconf_output" + + if [ ! $ret = 0 ] ; then + # retry without the -f and check for usage of macros that are too new + ac2_65_macros="AT_CHECK_EUNIT AC_PROG_OBJCXX AC_PROG_OBJCXXCPP" + ac2_64_macros="AT_CHECK_UNQUOTED AT_FAIL_IF AT_SKIP_IF AC_ERLANG_SUBST_ERTS_VER" + ac2_62_macros="AC_AUTOCONF_VERSION AC_OPENMP AC_PATH_PROGS_FEATURE_CHECK" + ac2_60_macros="AC_C_FLEXIBLE_ARRAY_MEMBER AC_C_VARARRAYS" + ac2_59_macros="AC_C_RESTRICT AC_INCLUDES_DEFAULT AC_LANG_ASSERT AC_LANG_WERROR AS_SET_CATFILE AC_PROG_SED AC_PROG_GREP AC_REQUIRE_AUX_FILE AC_CHECK_TARGET_TOOL AC_PATH_TARGET_TOOL AC_CHECK_TARGET_TOOLS AC_CHECK_ALIGNOF AC_PROG_OBJC AC_PROG_OBJCPP AC_ERLANG_SUBST_INSTALL_LIB_DIR AC_ERLANG_SUBST_INSTALL_LIB_SUBDIR AC_ERLANG_PATH_ERLC AC_ERLANG_NEED_ERLC AC_ERLANG_PATH_ERL AC_ERLANG_NEED_ERL AC_ERLANG_CHECK_LIB AC_ERLANG_SUBST_ROOT_DIR AC_ERLANG_SUBST_LIB_DIR AT_COPYRIGHT AS_BOURNE_COMPATIBLE AS_SHELL_SANITIZE AS_CASE AH_HEADER AC_USE_SYSTEM_EXTENSIONS AC_TYPE_INT8_T AC_TYPE_INT16_T AC_TYPE_INT32_T AC_TYPE_INT64_T AC_TYPE_INTMAX_T AC_TYPE_INTPTR_T AC_TYPE_LONG_LONG_INT AC_TYPE_SSIZE_T AC_TYPE_UINT8_T AC_TYPE_UINT16_T AC_TYPE_UINT32_T AC_TYPE_UINT64_T AC_TYPE_UINTMAX_T AC_TYPE_UINTPTR_T AC_TYPE_UNSIGNED_LONG_LONG_INT AC_TYPE_LONG_DOUBLE AC_TYPE_LONG_DOUBLE_WIDER AC_STRUCT_DIRENT_D_INO AC_STRUCT_DIRENT_D_TYPE AC_PROG_CC_C89 AC_PROG_CC_C99 AC_PRESERVE_HELP_ORDER AC_HEADER_ASSERT AC_FUNC_STRTOLD AC_C_TYPEOF AC_PROG_MKDIR_P AC_PROG_CXX_C_O" + ac2_55_macros="AC_COMPILER_IFELSE AC_FUNC_MBRTOWC AC_HEADER_STDBOOL AC_LANG_CONFTEST AC_LANG_SOURCE AC_LANG_PROGRAM AC_LANG_CALL AC_LANG_FUNC_TRY_LINK AC_MSG_FAILURE AC_PREPROC_IFELSE" + ac2_54_macros="AC_C_BACKSLASH_A AC_CONFIG_LIBOBJ_DIR AC_GNU_SOURCE AC_PROG_EGREP AC_PROG_FGREP AC_REPLACE_FNMATCH AC_FUNC_FNMATCH_GNU AC_FUNC_REALLOC AC_TYPE_MBSTATE_T" + + macros_to_search="" + ac_major="`echo ${AUTOCONF_VERSION}. | cut -d. -f1 | sed 's/[^0-9]//g'`" + ac_minor="`echo ${AUTOCONF_VERSION}. | cut -d. -f2 | sed 's/[^0-9]//g'`" + + if [ $ac_major -lt 2 ] ; then + macros_to_search="$ac2_65 $ac2_64 $ac2_62 $ac2_60 $ac2_59 $ac2_55 $ac2_54" + else + if [ $ac_minor -lt 54 ] ; then + macros_to_search="$ac2_65 $ac2_64 $ac2_62 $ac2_60 $ac2_59 $ac2_55 $ac2_54" + elif [ $ac_minor -lt 55 ] ; then + macros_to_search="$ac2_65 $ac2_64 $ac2_62 $ac2_60 $ac2_59 $ac2_55" + elif [ $ac_minor -lt 59 ] ; then + macros_to_search="$ac2_65 $ac2_64 $ac2_62 $ac2_60 $ac2_59" + elif [ $ac_minor -lt 60 ] ; then + macros_to_search="$ac2_65 $ac2_64 $ac2_62 $ac2_60" + elif [ $ac_minor -lt 62 ] ; then + macros_to_search="$ac2_65 $ac2_64 $ac2_62" + elif [ $ac_minor -lt 64 ] ; then + macros_to_search="$ac2_65 $ac2_64" + elif [ $ac_minor -lt 65 ] ; then + macros_to_search="$ac2_65" + fi + fi + + configure_ac_macros=__none__ + for feature in $macros_to_search ; do + $VERBOSE_ECHO "Searching for $feature in $CONFIGURE" + found="`grep \"^$feature.*\" $CONFIGURE`" + if [ ! "x$found" = "x" ] ; then + if [ "x$configure_ac_macros" = "x__none__" ] ; then + configure_ac_macros="$feature" + else + configure_ac_macros="$feature $configure_ac_macros" + fi + fi + done + if [ ! "x$configure_ac_macros" = "x__none__" ] ; then + $ECHO + $ECHO "Warning: Unsupported macros were found in $CONFIGURE" + $ECHO + $ECHO "The `basename \"$CONFIGURE\"` file was scanned in order to determine if any" + $ECHO "unsupported macros are used that exceed the minimum version" + $ECHO "settings specified within this file. As such, the following macros" + $ECHO "should be removed from configure.ac or the version numbers in this" + $ECHO "file should be increased:" + $ECHO + $ECHO "$configure_ac_macros" + $ECHO + $ECHO $ECHO_N "Ignorantly continuing build preparation ... $ECHO_C" + fi + + ################### + # autoconf, retry # + ################### + $VERBOSE_ECHO + $VERBOSE_ECHO "$AUTOCONF" + autoconf_output="`$AUTOCONF 2>&1`" + ret=$? + $VERBOSE_ECHO "$autoconf_output" + + if [ ! $ret = 0 ] ; then + # test if libtool is busted + libtool_failure "$autoconf_output" + + # let the user know what went wrong + cat <<EOF +$autoconf_output +EOF + $ECHO "ERROR: $AUTOCONF failed" + exit 2 + else + # autoconf sans -f and possibly sans unsupported options succeed so warn verbosely + $ECHO + $ECHO "Warning: autoconf seems to have succeeded by removing the following options:" + $ECHO " AUTOCONF_OPTIONS=\"$AUTOCONF_OPTIONS\"" + $ECHO + $ECHO "Removing those options should not be necessary and indicate some other" + $ECHO "problem with the build system. The build preparation is highly suspect" + $ECHO "and may result in configuration or compilation errors. Consider" + if [ "x$VERBOSE_ECHO" = "x:" ] ; then + $ECHO "rerunning the build preparation with verbose output enabled." + $ECHO " $AUTOGEN_SH --verbose" + else + $ECHO "reviewing the minimum GNU Autotools version settings contained in" + $ECHO "this script along with the macros being used in your `basename \"$CONFIGURE\"` file." + fi + $ECHO + $ECHO $ECHO_N "Continuing build preparation ... $ECHO_C" + fi # autoconf ret = 0 + fi # autoconf ret = 0 + + ############## + # autoheader # + ############## + need_autoheader=no + for feature in AM_CONFIG_HEADER AC_CONFIG_HEADER ; do + $VERBOSE_ECHO "Searching for $feature in $CONFIGURE" + found="`grep \"^$feature.*\" $CONFIGURE`" + if [ ! "x$found" = "x" ] ; then + need_autoheader=yes + break + fi + done + if [ "x$need_autoheader" = "xyes" ] ; then + $VERBOSE_ECHO "$AUTOHEADER $AUTOHEADER_OPTIONS" + autoheader_output="`$AUTOHEADER $AUTOHEADER_OPTIONS 2>&1`" + ret=$? + $VERBOSE_ECHO "$autoheader_output" + if [ ! $ret = 0 ] ; then $ECHO "ERROR: $AUTOHEADER failed" && exit 2 ; fi + fi # need_autoheader + + ############ + # automake # + ############ + need_automake=no + for feature in AM_INIT_AUTOMAKE ; do + $VERBOSE_ECHO "Searching for $feature in $CONFIGURE" + found="`grep \"^$feature.*\" $CONFIGURE`" + if [ ! "x$found" = "x" ] ; then + need_automake=yes + break + fi + done + + if [ "x$need_automake" = "xyes" ] ; then + $VERBOSE_ECHO "$AUTOMAKE $AUTOMAKE_OPTIONS" + automake_output="`$AUTOMAKE $AUTOMAKE_OPTIONS 2>&1`" + ret=$? + $VERBOSE_ECHO "$automake_output" + + if [ ! $ret = 0 ] ; then + + ################### + # automake, retry # + ################### + $VERBOSE_ECHO + $VERBOSE_ECHO "$AUTOMAKE $ALT_AUTOMAKE_OPTIONS" + # retry without the -f + automake_output="`$AUTOMAKE $ALT_AUTOMAKE_OPTIONS 2>&1`" + ret=$? + $VERBOSE_ECHO "$automake_output" + + if [ ! $ret = 0 ] ; then + # test if libtool is busted + libtool_failure "$automake_output" + + # let the user know what went wrong + cat <<EOF +$automake_output +EOF + $ECHO "ERROR: $AUTOMAKE failed" + exit 2 + fi # automake retry + fi # automake ret = 0 + fi # need_automake +} # end of manual_autogen + + +##################################### +# RECURSIVE_MANUAL_AUTOGEN FUNCTION # +##################################### +recursive_manual_autogen ( ) { + + # run the build preparation steps manually for this directory + manual_autogen + + # for projects using recursive configure, run the build + # preparation steps for the subdirectories. + if [ ! "x$CONFIG_SUBDIRS" = "x" ] ; then + $VERBOSE_ECHO "Recursively configuring the following directories:" + $VERBOSE_ECHO " $CONFIG_SUBDIRS" + for dir in $CONFIG_SUBDIRS ; do + $VERBOSE_ECHO "Processing recursive configure in $dir" + cd "$START_PATH" + cd "$dir" + + # new directory, prepare + initialize + + # run manual steps for the subdir and any others below + recursive_manual_autogen + done + fi +} + + +################################ +# run manual preparation steps # +################################ +if [ "x$reconfigure_manually" = "xyes" ] ; then + $ECHO + $ECHO $ECHO_N "Preparing build ... $ECHO_C" + + recursive_manual_autogen +fi + + +######################### +# restore and summarize # +######################### +cd "$START_PATH" + +# restore COPYING and INSTALL from backup if necessary +recursive_restore + +# make sure we end up with a configure script +config_ac="`locate_configure_template`" +config="`echo $config_ac | sed 's/\.ac$//' | sed 's/\.in$//'`" +if [ "x$config" = "x" ] ; then + $VERBOSE_ECHO "Could not locate the configure template (from `pwd`)" +fi + +# summarize +$ECHO "done" +$ECHO +if test "x$config" = "x" -o ! -f "$config" ; then + $ECHO "WARNING: The $PROJECT build system should now be prepared but there" + $ECHO "does not seem to be a resulting configure file. This is unexpected" + $ECHO "and likely the result of an error. You should run $NAME_OF_AUTOGEN" + $ECHO "with the --verbose option to get more details on a potential" + $ECHO "misconfiguration." +else + $ECHO "The $PROJECT build system is now prepared. To build here, run:" + $ECHO " $config" + $ECHO " make" +fi + +# finish up where we started +cd "$START_PATH" + +# Local Variables: +# mode: sh +# tab-width: 8 +# sh-basic-offset: 4 +# sh-indentation: 4 +# indent-tabs-mode: t +# End: +# ex: shiftwidth=4 tabstop=8 Property changes on: trunk/autogen.sh ___________________________________________________________________ Added: svn:executable + * Added: svn:mime-type + text/x-sh Added: svn:eol-style + native Modified: trunk/examples/01-tree_parsing/Makefile.am =================================================================== --- trunk/examples/01-tree_parsing/Makefile.am 2012-03-20 01:38:42 UTC (rev 197) +++ trunk/examples/01-tree_parsing/Makefile.am 2012-03-20 01:53:04 UTC (rev 198) @@ -1,6 +1,6 @@ noinst_PROGRAMS = example -example_SOURCES = example.cxx +example_SOURCES = example.cc example_CPPFLAGS = -I$(top_srcdir)/include example_LDADD = ../../src/libxmlwrapp.la Added: trunk/misc/libtool.m4 =================================================================== --- trunk/misc/libtool.m4 (rev 0) +++ trunk/misc/libtool.m4 2012-03-20 01:53:04 UTC (rev 198) @@ -0,0 +1,6000 @@ +# libtool.m4 - Configure libtool for the host system. -*-Autoconf-*- +## Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004 +## Free Software Foundation, Inc. +## Originally by Gordon Matzigkeit <go...@gn...>, 1996 +## +## This program is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation; either version 2 of the License, or +## (at your option) any later version. +## +## This program 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 +## General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with this program; if not, write to the Free Software +## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +## +## As a special exception to the GNU General Public License, if you +## distribute this file as part of a program that contains a +## configuration script generated by Autoconf, you may include it under +## the same distribution terms that you use for the rest of that program. + +# serial 47 AC_PROG_LIBTOOL + + +# AC_PROVIDE_IFELSE(MACRO-NAME, IF-PROVIDED, IF-NOT-PROVIDED) +# ----------------------------------------------------------- +# If this macro is not defined by Autoconf, define it here. +m4_ifdef([AC_PROVIDE_IFELSE], + [], + [m4_define([AC_PROVIDE_IFELSE], + [m4_ifdef([AC_PROVIDE_$1], + [$2], [$3])])]) + + +# AC_PROG_LIBTOOL +# --------------- +AC_DEFUN([AC_PROG_LIBTOOL], +[AC_REQUIRE([_AC_PROG_LIBTOOL])dnl +dnl If AC_PROG_CXX has already been expanded, run AC_LIBTOOL_CXX +dnl immediately, otherwise, hook it in at the end of AC_PROG_CXX. + AC_PROVIDE_IFELSE([AC_PROG_CXX], + [AC_LIBTOOL_CXX], + [define([AC_PROG_CXX], defn([AC_PROG_CXX])[AC_LIBTOOL_CXX + ])]) +dnl And a similar setup for Fortran 77 support + AC_PROVIDE_IFELSE([AC_PROG_F77], + [AC_LIBTOOL_F77], + [define([AC_PROG_F77], defn([AC_PROG_F77])[AC_LIBTOOL_F77 +])]) + +dnl Quote A][M_PROG_GCJ so that aclocal doesn't bring it in needlessly. +dnl If either AC_PROG_GCJ or A][M_PROG_GCJ have already been expanded, run +dnl AC_LIBTOOL_GCJ immediately, otherwise, hook it in at the end of both. + AC_PROVIDE_IFELSE([AC_PROG_GCJ], + [AC_LIBTOOL_GCJ], + [AC_PROVIDE_IFELSE([A][M_PROG_GCJ], + [AC_LIBTOOL_GCJ], + [AC_PROVIDE_IFELSE([LT_AC_PROG_GCJ], + [AC_LIBTOOL_GCJ], + [ifdef([AC_PROG_GCJ], + [define([AC_PROG_GCJ], defn([AC_PROG_GCJ])[AC_LIBTOOL_GCJ])]) + ifdef([A][M_PROG_GCJ], + [define([A][M_PROG_GCJ], defn([A][M_PROG_GCJ])[AC_LIBTOOL_GCJ])]) + ifdef([LT_AC_PROG_GCJ], + [define([LT_AC_PROG_GCJ], + defn([LT_AC_PROG_GCJ])[AC_LIBTOOL_GCJ])])])]) +])])# AC_PROG_LIBTOOL + + +# _AC_PROG_LIBTOOL +# ---------------- +AC_DEFUN([_AC_PROG_LIBTOOL], +[AC_REQUIRE([AC_LIBTOOL_SETUP])dnl +AC_BEFORE([$0],[AC_LIBTOOL_CXX])dnl +AC_BEFORE([$0],[AC_LIBTOOL_F77])dnl +AC_BEFORE([$0],[AC_LIBTOOL_GCJ])dnl + +# This can be used to rebuild libtool when needed +LIBTOOL_DEPS="$ac_aux_dir/ltmain.sh" + +# Always use our own libtool. +LIBTOOL='$(SHELL) $(top_builddir)/libtool' +AC_SUBST(LIBTOOL)dnl + +# Prevent multiple expansion +define([AC_PROG_LIBTOOL], []) +])# _AC_PROG_LIBTOOL + + +# AC_LIBTOOL_SETUP +# ---------------- +AC_DEFUN([AC_LIBTOOL_SETUP], +[AC_PREREQ(2.50)dnl +AC_REQUIRE([AC_ENABLE_SHARED])dnl +AC_REQUIRE([AC_ENABLE_STATIC])dnl +AC_REQUIRE([AC_ENABLE_FAST_INSTALL])dnl +AC_REQUIRE([AC_CANONICAL_HOST])dnl +AC_REQUIRE([AC_CANONICAL_BUILD])dnl +AC_REQUIRE([AC_PROG_CC])dnl +AC_REQUIRE([AC_PROG_LD])dnl +AC_REQUIRE([AC_PROG_LD_RELOAD_FLAG])dnl +AC_REQUIRE([AC_PROG_NM])dnl + +AC_REQUIRE([AC_PROG_LN_S])dnl +AC_REQUIRE([AC_DEPLIBS_CHECK_METHOD])dnl +# Autoconf 2.13's AC_OBJEXT and AC_EXEEXT macros only works for C compilers! +AC_REQUIRE([AC_OBJEXT])dnl +AC_REQUIRE([AC_EXEEXT])dnl +dnl + +AC_LIBTOOL_SYS_MAX_CMD_LEN +AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE +AC_LIBTOOL_OBJDIR + +AC_REQUIRE([_LT_AC_SYS_COMPILER])dnl +_LT_AC_PROG_ECHO_BACKSLASH + +case $host_os in +aix3*) + # AIX sometimes has problems with the GCC collect2 program. For some + # reason, if we set the COLLECT_NAMES environment variable, the problems + # vanish in a puff of smoke. + if test "X${COLLECT_NAMES+set}" != Xset; then + COLLECT_NAMES= + export COLLECT_NAMES + fi + ;; +esac + +# Sed substitution that helps us do robust quoting. It backslashifies +# metacharacters that are still active within double-quoted strings. +Xsed='sed -e s/^X//' +[sed_quote_subst='s/\([\\"\\`$\\\\]\)/\\\1/g'] + +# Same as above, but do not quote variable references. +[double_quote_subst='s/\([\\"\\`\\\\]\)/\\\1/g'] + +# Sed substitution to delay expansion of an escaped shell variable in a +# double_quote_subst'ed string. +delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' + +# Sed substitution to avoid accidental globbing in evaled expressions +no_glob_subst='s/\*/\\\*/g' + +# Constants: +rm="rm -f" + +# Global variables: +default_ofile=libtool +can_build_shared=yes + +# All known linkers require a `.a' archive for static linking (except M$VC, +# which needs '.lib'). +libext=a +ltmain="$ac_aux_dir/ltmain.sh" +ofile="$default_ofile" +with_gnu_ld="$lt_cv_prog_gnu_ld" + +AC_CHECK_TOOL(AR, ar, false) +AC_CHECK_TOOL(RANLIB, ranlib, :) +AC_CHECK_TOOL(STRIP, strip, :) + +old_CC="$CC" +old_CFLAGS="$CFLAGS" + +# Set sane defaults for various variables +test -z "$AR" && AR=ar +test -z "$AR_FLAGS" && AR_FLAGS=cru +test -z "$AS" && AS=as +test -z "$CC" && CC=cc +test -z "$LTCC" && LTCC=$CC +test -z "$DLLTOOL" && DLLTOOL=dlltool +test -z "$LD" && LD=ld +test -z "$LN_S" && LN_S="ln -s" +test -z "$MAGIC_CMD" && MAGIC_CMD=file +test -z "$NM" && NM=nm +test -z "$SED" && SED=sed +test -z "$OBJDUMP" && OBJDUMP=objdump +test -z "$RANLIB" && RANLIB=: +test -z "$STRIP" && STRIP=: +test -z "$ac_objext" && ac_objext=o + +# Determine commands to create old-style static archives. +old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs$old_deplibs' +old_postinstall_cmds='chmod 644 $oldlib' +old_postuninstall_cmds= + +if test -n "$RANLIB"; then + case $host_os in + openbsd*) + old_postinstall_cmds="\$RANLIB -t \$oldlib~$old_postinstall_cmds" + ;; + *) + old_postinstall_cmds="\$RANLIB \$oldlib~$old_postinstall_cmds" + ;; + esac + old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib" +fi + +cc_basename=`$echo X"$compiler" | $Xsed -e 's%^.*/%%'` + +# Only perform the check for file, if the check method requires it +case $deplibs_check_method in +file_magic*) + if test "$file_magic_cmd" = '$MAGIC_CMD'; then + AC_PATH_MAGIC + fi + ;; +esac + +AC_PROVIDE_IFELSE([AC_LIBTOOL_DLOPEN], enable_dlopen=yes, enable_dlopen=no) +AC_PROVIDE_IFELSE([AC_LIBTOOL_WIN32_DLL], +enable_win32_dll=yes, enable_win32_dll=no) + +AC_ARG_ENABLE([libtool-lock], + [AC_HELP_STRING([--disable-libtool-lock], + [avoid locking (might break parallel builds)])]) +test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes + +AC_ARG_WITH([pic], + [AC_HELP_STRING([--with-pic], + [try to use only PIC/non-PIC objects @<:@default=use both@:>@])], + [pic_mode="$withval"], + [pic_mode=default]) +test -z "$pic_mode" && pic_mode=default + +# Use C for the default configuration in the libtool script +tagname= +AC_LIBTOOL_LANG_C_CONFIG +_LT_AC_TAGCONFIG +])# AC_LIBTOOL_SETUP + + +# _LT_AC_SYS_COMPILER +# ------------------- +AC_DEFUN([_LT_AC_SYS_COMPILER], +[AC_REQUIRE([AC_PROG_CC])dnl + +# If no C compiler was specified, use CC. +LTCC=${LTCC-"$CC"} + +# Allow CC to be a program name with arguments. +compiler=$CC +])# _LT_AC_SYS_COMPILER + + +# _LT_AC_SYS_LIBPATH_AIX +# ---------------------- +# Links a minimal program and checks the executable +# for the system default hardcoded library path. In most cases, +# this is /usr/lib:/lib, but when the MPI compilers are used +# the location of the communication and MPI libs are included too. +# If we don't find anything, use the default library path according +# to the aix ld manual. +AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX], +[AC_LINK_IFELSE(AC_LANG_PROGRAM,[ +aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } +}'` +# Che... [truncated message content] |
From: <tbr...@us...> - 2012-03-20 01:38:52
|
Revision: 197 http://xmlwrapp.svn.sourceforge.net/xmlwrapp/?rev=197&view=rev Author: tbrowder2 Date: 2012-03-20 01:38:42 +0000 (Tue, 20 Mar 2012) Log Message: ----------- more C++ source file suffix changes from .cxx to .cc Modified Paths: -------------- trunk/examples/02-event_parsing/Makefile.am trunk/examples/03-xml_generation/Makefile.am trunk/examples/04-xslt/Makefile.am trunk/tests/Makefile.am Added Paths: ----------- trunk/examples/01-tree_parsing/example.cc trunk/examples/02-event_parsing/example.cc trunk/examples/03-xml_generation/example.cc trunk/examples/04-xslt/example.cc trunk/tests/attributes/test_attributes.cc trunk/tests/document/test_document.cc trunk/tests/event/test_event.cc trunk/tests/node/test_node.cc trunk/tests/test_main.cc trunk/tests/tree/test_tree.cc trunk/tests/xslt/test_xslt.cc Removed Paths: ------------- trunk/examples/01-tree_parsing/example.cxx trunk/examples/02-event_parsing/example.cxx trunk/examples/03-xml_generation/example.cxx trunk/examples/04-xslt/example.cxx trunk/tests/attributes/test_attributes.cxx trunk/tests/document/test_document.cxx trunk/tests/event/test_event.cxx trunk/tests/node/test_node.cxx trunk/tests/test_main.cxx trunk/tests/tree/test_tree.cxx trunk/tests/xslt/test_xslt.cxx Copied: trunk/examples/01-tree_parsing/example.cc (from rev 186, trunk/examples/01-tree_parsing/example.cxx) =================================================================== --- trunk/examples/01-tree_parsing/example.cc (rev 0) +++ trunk/examples/01-tree_parsing/example.cc 2012-03-20 01:38:42 UTC (rev 197) @@ -0,0 +1,71 @@ +/* + * Copyright (C) 2001-2003 Peter J Jones (pj...@pm...) + * All Rights Reserved + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name of the Author nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR + * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* + * This file demonstrates how to use the xml::tree_parser class to parse XML + * data and create a tree of xml::node objects. It also shows how you can + * walk the tree using xml::node iterators. + */ + +// xmlwrapp include +#include <xmlwrapp/xmlwrapp.h> + +// standard includes +#include <iostream> +#include <exception> + +int main (int argc, char *argv[]) { + if (argc != 2) { + std::cerr << argv[0] << ": you must give one and only one XML file name\n"; + return 1; + } + + try { + + xml::tree_parser parser(argv[1]); + + xml::node &root = parser.get_document().get_root_node(); + std::cout << "root node is '" << root.get_name() << "'\n"; + + xml::node::const_iterator child(root.begin()), child_end(root.end()); + for (; child != child_end; ++child) { + if (child->is_text()) continue; + std::cout << "child node '" << child->get_name() << "'\n"; + } + + } catch (std::exception &e) { + std::cerr << argv[0] << ": " << e.what() << "\n"; + return 1; + } + + return 0; +} Deleted: trunk/examples/01-tree_parsing/example.cxx =================================================================== --- trunk/examples/01-tree_parsing/example.cxx 2012-03-20 01:20:13 UTC (rev 196) +++ trunk/examples/01-tree_parsing/example.cxx 2012-03-20 01:38:42 UTC (rev 197) @@ -1,71 +0,0 @@ -/* - * Copyright (C) 2001-2003 Peter J Jones (pj...@pm...) - * All Rights Reserved - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name of the Author nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR - * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -/* - * This file demonstrates how to use the xml::tree_parser class to parse XML - * data and create a tree of xml::node objects. It also shows how you can - * walk the tree using xml::node iterators. - */ - -// xmlwrapp include -#include <xmlwrapp/xmlwrapp.h> - -// standard includes -#include <iostream> -#include <exception> - -int main (int argc, char *argv[]) { - if (argc != 2) { - std::cerr << argv[0] << ": you must give one and only one XML file name\n"; - return 1; - } - - try { - - xml::tree_parser parser(argv[1]); - - xml::node &root = parser.get_document().get_root_node(); - std::cout << "root node is '" << root.get_name() << "'\n"; - - xml::node::const_iterator child(root.begin()), child_end(root.end()); - for (; child != child_end; ++child) { - if (child->is_text()) continue; - std::cout << "child node '" << child->get_name() << "'\n"; - } - - } catch (std::exception &e) { - std::cerr << argv[0] << ": " << e.what() << "\n"; - return 1; - } - - return 0; -} Modified: trunk/examples/02-event_parsing/Makefile.am =================================================================== --- trunk/examples/02-event_parsing/Makefile.am 2012-03-20 01:20:13 UTC (rev 196) +++ trunk/examples/02-event_parsing/Makefile.am 2012-03-20 01:38:42 UTC (rev 197) @@ -1,6 +1,6 @@ noinst_PROGRAMS = example -example_SOURCES = example.cxx +example_SOURCES = example.cc example_CPPFLAGS = -I$(top_srcdir)/include example_LDADD = ../../src/libxmlwrapp.la Copied: trunk/examples/02-event_parsing/example.cc (from rev 186, trunk/examples/02-event_parsing/example.cxx) =================================================================== --- trunk/examples/02-event_parsing/example.cc (rev 0) +++ trunk/examples/02-event_parsing/example.cc 2012-03-20 01:38:42 UTC (rev 197) @@ -0,0 +1,85 @@ +/* + * Copyright (C) 2001-2003 Peter J Jones (pj...@pm...) + * All Rights Reserved + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name of the Author nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR + * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* + * The following code demonstrates the usage of the xml::event_parser class. + * This class must be derived from and the new subclass must implement the + * pure virtual member functions from xml::event_parser. These member + * functions are called when parsing events occur. + */ + +// xmlwrapp include +#include <xmlwrapp/xmlwrapp.h> + +// standard includes +#include <iostream> +#include <exception> + +/* + * Here we create a class that will receive the parsing events. + */ +class myparser : public xml::event_parser { +public: + myparser (void) + { std::cout << "myparser constructor\n"; } + + ~myparser (void) + { std::cout << "myparser destructor\n"; } +private: + bool start_element (const std::string &name, const attrs_type&) + { std::cout << "begin tag '" << name << "'\n"; return true; } + + bool end_element (const std::string &name) + { std::cout << "end tag '" << name << "'\n"; return true; } + + bool text (const std::string&) + { return true; } +}; + +/* + * And here is good ol' main. + */ +int main (int argc, char *argv[]) { + if (argc != 2) { + std::cerr << argv[0] << ": you must give one and only one XML file name\n"; + return 1; + } + + myparser parser; + + if (!parser.parse_file(argv[1])) { + std::cerr << argv[0] << ": error parsing XML file\n"; + return 1; + } + + return 0; +} Deleted: trunk/examples/02-event_parsing/example.cxx =================================================================== --- trunk/examples/02-event_parsing/example.cxx 2012-03-20 01:20:13 UTC (rev 196) +++ trunk/examples/02-event_parsing/example.cxx 2012-03-20 01:38:42 UTC (rev 197) @@ -1,85 +0,0 @@ -/* - * Copyright (C) 2001-2003 Peter J Jones (pj...@pm...) - * All Rights Reserved - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name of the Author nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR - * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -/* - * The following code demonstrates the usage of the xml::event_parser class. - * This class must be derived from and the new subclass must implement the - * pure virtual member functions from xml::event_parser. These member - * functions are called when parsing events occur. - */ - -// xmlwrapp include -#include <xmlwrapp/xmlwrapp.h> - -// standard includes -#include <iostream> -#include <exception> - -/* - * Here we create a class that will receive the parsing events. - */ -class myparser : public xml::event_parser { -public: - myparser (void) - { std::cout << "myparser constructor\n"; } - - ~myparser (void) - { std::cout << "myparser destructor\n"; } -private: - bool start_element (const std::string &name, const attrs_type&) - { std::cout << "begin tag '" << name << "'\n"; return true; } - - bool end_element (const std::string &name) - { std::cout << "end tag '" << name << "'\n"; return true; } - - bool text (const std::string&) - { return true; } -}; - -/* - * And here is good ol' main. - */ -int main (int argc, char *argv[]) { - if (argc != 2) { - std::cerr << argv[0] << ": you must give one and only one XML file name\n"; - return 1; - } - - myparser parser; - - if (!parser.parse_file(argv[1])) { - std::cerr << argv[0] << ": error parsing XML file\n"; - return 1; - } - - return 0; -} Modified: trunk/examples/03-xml_generation/Makefile.am =================================================================== --- trunk/examples/03-xml_generation/Makefile.am 2012-03-20 01:20:13 UTC (rev 196) +++ trunk/examples/03-xml_generation/Makefile.am 2012-03-20 01:38:42 UTC (rev 197) @@ -1,6 +1,6 @@ noinst_PROGRAMS = example -example_SOURCES = example.cxx +example_SOURCES = example.cc example_CPPFLAGS = -I$(top_srcdir)/include example_LDADD = ../../src/libxmlwrapp.la Copied: trunk/examples/03-xml_generation/example.cc (from rev 186, trunk/examples/03-xml_generation/example.cxx) =================================================================== --- trunk/examples/03-xml_generation/example.cc (rev 0) +++ trunk/examples/03-xml_generation/example.cc 2012-03-20 01:38:42 UTC (rev 197) @@ -0,0 +1,88 @@ +/* + * Copyright (C) 2001-2003 Peter J Jones (pj...@pm...) + * All Rights Reserved + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name of the Author nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR + * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* + * The following code demonstrates how to use the xml::node class to build + * an XML tree and then convert it to XML text. + * + * Here is what we want to create: + * + * <abook> + * <person id="01" name="Peter Jones"> + * <email>pj...@pm...</email> + * <!-- Fake Phone Number --> + * <phone type="home">555-1212</phone> + * </person> + * </abook> + */ + +// xmlwrapp include +#include <xmlwrapp/xmlwrapp.h> + +// standard includes +#include <iostream> +#include <exception> + +int main (void) { + // create a new XML document and set the root node + xml::document xmldoc("abook"); + xml::node &root = xmldoc.get_root_node(); + + // add a child to the root node, <person> + xml::node::iterator it = root.insert(root.begin(), xml::node("person")); + + /* + * set the attributes for this new <person> element using the + * xml::attributes object returned from xml::node::get_attributes + */ + it->get_attributes().insert("id", "01"); + it->get_attributes().insert("name", "Peter Jones"); + + // add a node and set the content for that new node + it->push_back(xml::node("email", "pj...@pm...")); + + // add an XML comment + it->push_back(xml::node(xml::node::comment(" Fake Phone Number "))); + + // build a node one member function at a time + it = it->insert(xml::node("phone")); + it->get_attributes().insert("type", "home"); + it->set_content("555-1212"); + + // set some document settings + xmldoc.set_is_standalone(true); + xmldoc.set_encoding("ISO-8859-1"); + + // convert the document to XML + std::cout << xmldoc; + return 0; +} Deleted: trunk/examples/03-xml_generation/example.cxx =================================================================== --- trunk/examples/03-xml_generation/example.cxx 2012-03-20 01:20:13 UTC (rev 196) +++ trunk/examples/03-xml_generation/example.cxx 2012-03-20 01:38:42 UTC (rev 197) @@ -1,88 +0,0 @@ -/* - * Copyright (C) 2001-2003 Peter J Jones (pj...@pm...) - * All Rights Reserved - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name of the Author nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR - * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -/* - * The following code demonstrates how to use the xml::node class to build - * an XML tree and then convert it to XML text. - * - * Here is what we want to create: - * - * <abook> - * <person id="01" name="Peter Jones"> - * <email>pj...@pm...</email> - * <!-- Fake Phone Number --> - * <phone type="home">555-1212</phone> - * </person> - * </abook> - */ - -// xmlwrapp include -#include <xmlwrapp/xmlwrapp.h> - -// standard includes -#include <iostream> -#include <exception> - -int main (void) { - // create a new XML document and set the root node - xml::document xmldoc("abook"); - xml::node &root = xmldoc.get_root_node(); - - // add a child to the root node, <person> - xml::node::iterator it = root.insert(root.begin(), xml::node("person")); - - /* - * set the attributes for this new <person> element using the - * xml::attributes object returned from xml::node::get_attributes - */ - it->get_attributes().insert("id", "01"); - it->get_attributes().insert("name", "Peter Jones"); - - // add a node and set the content for that new node - it->push_back(xml::node("email", "pj...@pm...")); - - // add an XML comment - it->push_back(xml::node(xml::node::comment(" Fake Phone Number "))); - - // build a node one member function at a time - it = it->insert(xml::node("phone")); - it->get_attributes().insert("type", "home"); - it->set_content("555-1212"); - - // set some document settings - xmldoc.set_is_standalone(true); - xmldoc.set_encoding("ISO-8859-1"); - - // convert the document to XML - std::cout << xmldoc; - return 0; -} Modified: trunk/examples/04-xslt/Makefile.am =================================================================== --- trunk/examples/04-xslt/Makefile.am 2012-03-20 01:20:13 UTC (rev 196) +++ trunk/examples/04-xslt/Makefile.am 2012-03-20 01:38:42 UTC (rev 197) @@ -3,7 +3,7 @@ noinst_PROGRAMS = example -example_SOURCES = example.cxx +example_SOURCES = example.cc example_CPPFLAGS = -I$(top_srcdir)/include example_LDADD = ../../src/libxsltwrapp.la ../../src/libxmlwrapp.la Copied: trunk/examples/04-xslt/example.cc (from rev 186, trunk/examples/04-xslt/example.cxx) =================================================================== --- trunk/examples/04-xslt/example.cc (rev 0) +++ trunk/examples/04-xslt/example.cc 2012-03-20 01:38:42 UTC (rev 197) @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2001-2003 Peter J Jones (pj...@pm...) + * All Rights Reserved + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name of the Author nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR + * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* + * The following code demonstrates how to use the xsltwrapp code to trasform + * an XML document into something else using XSLT. + */ + +// xsltwrapp include +#include <xsltwrapp/xsltwrapp.h> + +// standard includes +#include <iostream> +#include <exception> + +int main (void) { + try { + // parse the input XML document + xml::tree_parser parser("example.xml"); + xml::document &doc = parser.get_document(); + + // parse the stylesheet + xslt::stylesheet style("example.xsl"); + + // transform the XML document using the stylesheet + xml::document &result = style.apply(doc); + + std::cout << result; + + } catch (const std::exception &e) { + std::cerr << e.what() << "\n"; + return 1; + } + + return 0; +} Deleted: trunk/examples/04-xslt/example.cxx =================================================================== --- trunk/examples/04-xslt/example.cxx 2012-03-20 01:20:13 UTC (rev 196) +++ trunk/examples/04-xslt/example.cxx 2012-03-20 01:38:42 UTC (rev 197) @@ -1,65 +0,0 @@ -/* - * Copyright (C) 2001-2003 Peter J Jones (pj...@pm...) - * All Rights Reserved - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name of the Author nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR - * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -/* - * The following code demonstrates how to use the xsltwrapp code to trasform - * an XML document into something else using XSLT. - */ - -// xsltwrapp include -#include <xsltwrapp/xsltwrapp.h> - -// standard includes -#include <iostream> -#include <exception> - -int main (void) { - try { - // parse the input XML document - xml::tree_parser parser("example.xml"); - xml::document &doc = parser.get_document(); - - // parse the stylesheet - xslt::stylesheet style("example.xsl"); - - // transform the XML document using the stylesheet - xml::document &result = style.apply(doc); - - std::cout << result; - - } catch (const std::exception &e) { - std::cerr << e.what() << "\n"; - return 1; - } - - return 0; -} Modified: trunk/tests/Makefile.am =================================================================== --- trunk/tests/Makefile.am 2012-03-20 01:20:13 UTC (rev 196) +++ trunk/tests/Makefile.am 2012-03-20 01:38:42 UTC (rev 197) @@ -10,16 +10,16 @@ test_SOURCES = \ test.h \ - test_main.cxx \ - attributes/test_attributes.cxx \ - document/test_document.cxx \ - event/test_event.cxx \ - node/test_node.cxx \ - tree/test_tree.cxx + test_main.cc \ + attributes/test_attributes.cc \ + document/test_document.cc \ + event/test_event.cc \ + node/test_node.cc \ + tree/test_tree.cc if WITH_XSLT LIBS += $(top_builddir)/src/libxsltwrapp.la -test_SOURCES += xslt/test_xslt.cxx +test_SOURCES += xslt/test_xslt.cc endif EXTRA_DIST = \ Copied: trunk/tests/attributes/test_attributes.cc (from rev 188, trunk/tests/attributes/test_attributes.cxx) =================================================================== --- trunk/tests/attributes/test_attributes.cc (rev 0) +++ trunk/tests/attributes/test_attributes.cc 2012-03-20 01:38:42 UTC (rev 197) @@ -0,0 +1,288 @@ +/* + * Copyright (C) 2001-2003 Peter J Jones (pj...@pm...) + * Copyright (C) 2009 Vaclav Slavik (vs...@gm...) + * All Rights Reserved + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name of the Author nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR + * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include "../test.h" + + +BOOST_AUTO_TEST_SUITE( attributes ) + +/* + * Test to see if the xml::attributes function can see all the attributes of + * a node. + */ + +static void do_attr_read(const std::string& prefix) +{ + std::ostringstream ostr; + + xml::tree_parser parser(test_file_path(prefix + ".xml").c_str()); + + const xml::attributes &attrs = parser.get_document().get_root_node().get_attributes(); + xml::attributes::const_iterator i=attrs.begin(), end=attrs.end(); + for (; i!=end; ++i) + { + ostr << i->get_name() << "=" << i->get_value() << "\n"; + } + + BOOST_CHECK( is_same_as_file(ostr, prefix + ".out") ); +} + +BOOST_AUTO_TEST_CASE( read ) +{ + do_attr_read("attributes/data/01a"); + do_attr_read("attributes/data/01b"); + do_attr_read("attributes/data/01c"); +} + + +/* + * Test to see if the xml::attributes::insert function works. + */ + +BOOST_AUTO_TEST_CASE( insert ) +{ + xml::tree_parser parser(test_file_path("attributes/data/02.xml").c_str()); + + xml::attributes &attrs = parser.get_document().get_root_node().get_attributes(); + attrs.insert("b", "b"); + + BOOST_CHECK( is_same_as_file(parser.get_document(), "attributes/data/02.out") ); +} + + +/* + * Test to see if the xml::attributes::find works. + */ + +static bool do_attr_find(const xml::document& doc, + const char *to_find, + const char *expected_value) +{ + const xml::attributes &attrs = doc.get_root_node().get_attributes(); + xml::attributes::const_iterator i = attrs.find(to_find); + + if ( i == attrs.end() ) + return false; + + BOOST_CHECK_EQUAL( i->get_name(), to_find ); + BOOST_CHECK_EQUAL( i->get_value(), expected_value ); + + return true; +} + +BOOST_AUTO_TEST_CASE( find ) +{ + xml::tree_parser parser(test_file_path("attributes/data/03.xml").c_str()); + const xml::document& doc = parser.get_document(); + + BOOST_CHECK( do_attr_find(doc, "one", "1") == true ); + BOOST_CHECK( do_attr_find(doc, "two", "2") == true ); + BOOST_CHECK( do_attr_find(doc, "three", "3") == true ); + BOOST_CHECK( do_attr_find(doc, "missing", NULL) == false ); + BOOST_CHECK( do_attr_find(doc, "also_missing", NULL) == false ); +} + + +/* + * Test to see if the xml::attributes::remove(iterator) works. + */ + +static void do_remove_by_iter(const char *name, const char *outfile) +{ + xml::tree_parser parser(test_file_path("attributes/data/04.xml").c_str()); + + xml::attributes &attrs = parser.get_document().get_root_node().get_attributes(); + xml::attributes::iterator i = attrs.find(name); + + BOOST_REQUIRE( i != attrs.end() ); + attrs.erase(i); + + BOOST_CHECK( is_same_as_file(parser.get_document(), outfile) ); +} + +BOOST_AUTO_TEST_CASE( remove_by_iter ) +{ + do_remove_by_iter("attr_one", "attributes/data/04a.out"); + do_remove_by_iter("attr_two", "attributes/data/04b.out"); + do_remove_by_iter("attr_three", "attributes/data/04c.out"); + do_remove_by_iter("attr_four", "attributes/data/04d.out"); +} + + +/* + * Test to see if the xml::attributes::remove(const char*) works. + */ + +static void do_remove_by_name(const char *name, const char *outfile) +{ + xml::tree_parser parser(test_file_path("attributes/data/04.xml").c_str()); + + xml::attributes &attrs = parser.get_document().get_root_node().get_attributes(); + + attrs.erase(name); + + BOOST_CHECK( is_same_as_file(parser.get_document(), outfile) ); +} + +BOOST_AUTO_TEST_CASE( remove_by_name ) +{ + do_remove_by_name("attr_one", "attributes/data/04a.out"); + do_remove_by_name("attr_two", "attributes/data/04b.out"); + do_remove_by_name("attr_three", "attributes/data/04c.out"); + do_remove_by_name("attr_four", "attributes/data/04d.out"); +} + + +/* + * Test to see if xml::attributes::find() can see DTD default attributes + */ + +BOOST_AUTO_TEST_CASE( find_dtd_default_attr ) +{ + xml::tree_parser parser(test_file_path("attributes/data/09.xml").c_str()); + + BOOST_CHECK( parser.get_document().has_internal_subset() ); + BOOST_CHECK( parser.get_document().validate() ); + + const xml::attributes &attrs = + parser.get_document().get_root_node().get_attributes(); + + { + xml::attributes::const_iterator i = attrs.find("one"); + BOOST_REQUIRE( i != attrs.end() ); + BOOST_CHECK_EQUAL( i->get_value(), "1" ); + ++i; + BOOST_CHECK( i == attrs.end() ); + } + + { + xml::attributes::const_iterator i = attrs.find("two"); + BOOST_REQUIRE( i != attrs.end() ); + BOOST_CHECK_EQUAL( i->get_value(), "two" ); + ++i; + BOOST_CHECK( i == attrs.end() ); + } + + { + xml::attributes::const_iterator i = attrs.find("three"); + BOOST_REQUIRE( i != attrs.end() ); + BOOST_CHECK_EQUAL( i->get_value(), "three" ); + ++i; + BOOST_CHECK( i == attrs.end() ); + } +} + + +/* + * Test to see if xml::attributes::find() will die when DTD default + * attributes are really implied. + */ + +BOOST_AUTO_TEST_CASE( dtd_implied ) +{ + xml::tree_parser parser(test_file_path("attributes/data/10.xml").c_str()); + + BOOST_CHECK( parser.get_document().has_internal_subset() ); + BOOST_CHECK( parser.get_document().validate() ); + + const xml::attributes &attrs = + parser.get_document().get_root_node().get_attributes(); + + BOOST_CHECK( attrs.find("optional") == attrs.end() ); +} + + +/* + * Test to see if the xml::attributes copy constructor works. + */ + +BOOST_AUTO_TEST_CASE( attr_copy_ctor ) +{ + std::ostringstream ostr; + xml::tree_parser parser(test_file_path("attributes/data/08.xml").c_str()); + + // make a copy + xml::attributes attrs = parser.get_document().get_root_node().get_attributes(); + xml::attributes::const_iterator i = attrs.begin(), end = attrs.end(); + + for ( ; i != end; ++i ) + ostr << i->get_name() << "=" << i->get_value() << "\n"; + + BOOST_CHECK( is_same_as_file(ostr, "attributes/data/08.out") ); +} + +BOOST_AUTO_TEST_SUITE_END() + + +/* + * Test to see if the xml::attributes::empty() works. + */ + +BOOST_AUTO_TEST_CASE( attr_empty_a ) +{ + xml::tree_parser parser(test_file_path("attributes/data/06a.xml").c_str()); + + xml::attributes &attrs = parser.get_document().get_root_node().get_attributes(); + + BOOST_CHECK( attrs.empty() ); +} + +BOOST_AUTO_TEST_CASE( attr_empty_b ) +{ + xml::tree_parser parser(test_file_path("attributes/data/06b.xml").c_str()); + + xml::attributes &attrs = parser.get_document().get_root_node().get_attributes(); + + BOOST_CHECK( !attrs.empty() ); +} + + +/* + * Test to see if xml::attributes::size() works. + */ + +static int do_get_attr_size(const char *testfile) +{ + xml::tree_parser parser(test_file_path(testfile).c_str()); + + xml::attributes &attrs = parser.get_document().get_root_node().get_attributes(); + return attrs.size(); +} + +BOOST_AUTO_TEST_CASE( attr_size ) +{ + BOOST_CHECK_EQUAL( do_get_attr_size("attributes/data/07a.xml"), 0 ); + BOOST_CHECK_EQUAL( do_get_attr_size("attributes/data/07b.xml"), 1 ); + BOOST_CHECK_EQUAL( do_get_attr_size("attributes/data/07c.xml"), 2 ); + BOOST_CHECK_EQUAL( do_get_attr_size("attributes/data/07d.xml"), 3 ); +} Deleted: trunk/tests/attributes/test_attributes.cxx =================================================================== --- trunk/tests/attributes/test_attributes.cxx 2012-03-20 01:20:13 UTC (rev 196) +++ trunk/tests/attributes/test_attributes.cxx 2012-03-20 01:38:42 UTC (rev 197) @@ -1,288 +0,0 @@ -/* - * Copyright (C) 2001-2003 Peter J Jones (pj...@pm...) - * Copyright (C) 2009 Vaclav Slavik (vs...@gm...) - * All Rights Reserved - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name of the Author nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR - * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include "../test.h" - - -BOOST_AUTO_TEST_SUITE( attributes ) - -/* - * Test to see if the xml::attributes function can see all the attributes of - * a node. - */ - -static void do_attr_read(const std::string& prefix) -{ - std::ostringstream ostr; - - xml::tree_parser parser(test_file_path(prefix + ".xml").c_str()); - - const xml::attributes &attrs = parser.get_document().get_root_node().get_attributes(); - xml::attributes::const_iterator i=attrs.begin(), end=attrs.end(); - for (; i!=end; ++i) - { - ostr << i->get_name() << "=" << i->get_value() << "\n"; - } - - BOOST_CHECK( is_same_as_file(ostr, prefix + ".out") ); -} - -BOOST_AUTO_TEST_CASE( read ) -{ - do_attr_read("attributes/data/01a"); - do_attr_read("attributes/data/01b"); - do_attr_read("attributes/data/01c"); -} - - -/* - * Test to see if the xml::attributes::insert function works. - */ - -BOOST_AUTO_TEST_CASE( insert ) -{ - xml::tree_parser parser(test_file_path("attributes/data/02.xml").c_str()); - - xml::attributes &attrs = parser.get_document().get_root_node().get_attributes(); - attrs.insert("b", "b"); - - BOOST_CHECK( is_same_as_file(parser.get_document(), "attributes/data/02.out") ); -} - - -/* - * Test to see if the xml::attributes::find works. - */ - -static bool do_attr_find(const xml::document& doc, - const char *to_find, - const char *expected_value) -{ - const xml::attributes &attrs = doc.get_root_node().get_attributes(); - xml::attributes::const_iterator i = attrs.find(to_find); - - if ( i == attrs.end() ) - return false; - - BOOST_CHECK_EQUAL( i->get_name(), to_find ); - BOOST_CHECK_EQUAL( i->get_value(), expected_value ); - - return true; -} - -BOOST_AUTO_TEST_CASE( find ) -{ - xml::tree_parser parser(test_file_path("attributes/data/03.xml").c_str()); - const xml::document& doc = parser.get_document(); - - BOOST_CHECK( do_attr_find(doc, "one", "1") == true ); - BOOST_CHECK( do_attr_find(doc, "two", "2") == true ); - BOOST_CHECK( do_attr_find(doc, "three", "3") == true ); - BOOST_CHECK( do_attr_find(doc, "missing", NULL) == false ); - BOOST_CHECK( do_attr_find(doc, "also_missing", NULL) == false ); -} - - -/* - * Test to see if the xml::attributes::remove(iterator) works. - */ - -static void do_remove_by_iter(const char *name, const char *outfile) -{ - xml::tree_parser parser(test_file_path("attributes/data/04.xml").c_str()); - - xml::attributes &attrs = parser.get_document().get_root_node().get_attributes(); - xml::attributes::iterator i = attrs.find(name); - - BOOST_REQUIRE( i != attrs.end() ); - attrs.erase(i); - - BOOST_CHECK( is_same_as_file(parser.get_document(), outfile) ); -} - -BOOST_AUTO_TEST_CASE( remove_by_iter ) -{ - do_remove_by_iter("attr_one", "attributes/data/04a.out"); - do_remove_by_iter("attr_two", "attributes/data/04b.out"); - do_remove_by_iter("attr_three", "attributes/data/04c.out"); - do_remove_by_iter("attr_four", "attributes/data/04d.out"); -} - - -/* - * Test to see if the xml::attributes::remove(const char*) works. - */ - -static void do_remove_by_name(const char *name, const char *outfile) -{ - xml::tree_parser parser(test_file_path("attributes/data/04.xml").c_str()); - - xml::attributes &attrs = parser.get_document().get_root_node().get_attributes(); - - attrs.erase(name); - - BOOST_CHECK( is_same_as_file(parser.get_document(), outfile) ); -} - -BOOST_AUTO_TEST_CASE( remove_by_name ) -{ - do_remove_by_name("attr_one", "attributes/data/04a.out"); - do_remove_by_name("attr_two", "attributes/data/04b.out"); - do_remove_by_name("attr_three", "attributes/data/04c.out"); - do_remove_by_name("attr_four", "attributes/data/04d.out"); -} - - -/* - * Test to see if xml::attributes::find() can see DTD default attributes - */ - -BOOST_AUTO_TEST_CASE( find_dtd_default_attr ) -{ - xml::tree_parser parser(test_file_path("attributes/data/09.xml").c_str()); - - BOOST_CHECK( parser.get_document().has_internal_subset() ); - BOOST_CHECK( parser.get_document().validate() ); - - const xml::attributes &attrs = - parser.get_document().get_root_node().get_attributes(); - - { - xml::attributes::const_iterator i = attrs.find("one"); - BOOST_REQUIRE( i != attrs.end() ); - BOOST_CHECK_EQUAL( i->get_value(), "1" ); - ++i; - BOOST_CHECK( i == attrs.end() ); - } - - { - xml::attributes::const_iterator i = attrs.find("two"); - BOOST_REQUIRE( i != attrs.end() ); - BOOST_CHECK_EQUAL( i->get_value(), "two" ); - ++i; - BOOST_CHECK( i == attrs.end() ); - } - - { - xml::attributes::const_iterator i = attrs.find("three"); - BOOST_REQUIRE( i != attrs.end() ); - BOOST_CHECK_EQUAL( i->get_value(), "three" ); - ++i; - BOOST_CHECK( i == attrs.end() ); - } -} - - -/* - * Test to see if xml::attributes::find() will die when DTD default - * attributes are really implied. - */ - -BOOST_AUTO_TEST_CASE( dtd_implied ) -{ - xml::tree_parser parser(test_file_path("attributes/data/10.xml").c_str()); - - BOOST_CHECK( parser.get_document().has_internal_subset() ); - BOOST_CHECK( parser.get_document().validate() ); - - const xml::attributes &attrs = - parser.get_document().get_root_node().get_attributes(); - - BOOST_CHECK( attrs.find("optional") == attrs.end() ); -} - - -/* - * Test to see if the xml::attributes copy constructor works. - */ - -BOOST_AUTO_TEST_CASE( attr_copy_ctor ) -{ - std::ostringstream ostr; - xml::tree_parser parser(test_file_path("attributes/data/08.xml").c_str()); - - // make a copy - xml::attributes attrs = parser.get_document().get_root_node().get_attributes(); - xml::attributes::const_iterator i = attrs.begin(), end = attrs.end(); - - for ( ; i != end; ++i ) - ostr << i->get_name() << "=" << i->get_value() << "\n"; - - BOOST_CHECK( is_same_as_file(ostr, "attributes/data/08.out") ); -} - -BOOST_AUTO_TEST_SUITE_END() - - -/* - * Test to see if the xml::attributes::empty() works. - */ - -BOOST_AUTO_TEST_CASE( attr_empty_a ) -{ - xml::tree_parser parser(test_file_path("attributes/data/06a.xml").c_str()); - - xml::attributes &attrs = parser.get_document().get_root_node().get_attributes(); - - BOOST_CHECK( attrs.empty() ); -} - -BOOST_AUTO_TEST_CASE( attr_empty_b ) -{ - xml::tree_parser parser(test_file_path("attributes/data/06b.xml").c_str()); - - xml::attributes &attrs = parser.get_document().get_root_node().get_attributes(); - - BOOST_CHECK( !attrs.empty() ); -} - - -/* - * Test to see if xml::attributes::size() works. - */ - -static int do_get_attr_size(const char *testfile) -{ - xml::tree_parser parser(test_file_path(testfile).c_str()); - - xml::attributes &attrs = parser.get_document().get_root_node().get_attributes(); - return attrs.size(); -} - -BOOST_AUTO_TEST_CASE( attr_size ) -{ - BOOST_CHECK_EQUAL( do_get_attr_size("attributes/data/07a.xml"), 0 ); - BOOST_CHECK_EQUAL( do_get_attr_size("attributes/data/07b.xml"), 1 ); - BOOST_CHECK_EQUAL( do_get_attr_size("attributes/data/07c.xml"), 2 ); - BOOST_CHECK_EQUAL( do_get_attr_size("attributes/data/07d.xml"), 3 ); -} Copied: trunk/tests/document/test_document.cc (from rev 186, trunk/tests/document/test_document.cxx) =================================================================== --- trunk/tests/document/test_document.cc (rev 0) +++ trunk/tests/document/test_document.cc 2012-03-20 01:38:42 UTC (rev 197) @@ -0,0 +1,439 @@ +/* + * Copyright (C) 2001-2003 Peter J Jones (pj...@pm...) + * Copyright (C) 2009 Vaclav Slavik (vs...@fa...) + * All Rights Reserved + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name of the Author nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR + * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include "../test.h" + +#include <boost/iostreams/filtering_stream.hpp> +#include <boost/iostreams/filter/gzip.hpp> + +BOOST_AUTO_TEST_SUITE( document ) + +/* + * This test checks xml::document iteration. + */ + +BOOST_AUTO_TEST_CASE( dump_type ) +{ + xml::init::substitute_entities(false); + + xml::tree_parser parser(test_file_path("document/data/01.xml").c_str()); + + std::ostringstream ostr; + xml::node::iterator i = parser.get_document().begin(), + end = parser.get_document().end(); + for (; i!=end; ++i) + dump_node_type(ostr, *i); + + BOOST_CHECK( is_same_as_file(ostr, "document/data/01.out") ); +} + + +/* + * This test checks xml::document default constructor. + */ + +BOOST_AUTO_TEST_CASE( default_ctor ) +{ + xml::document doc; + BOOST_CHECK( is_same_as_file( doc, "document/data/02.out") ); +} + + +/* + * This test checks xml::document constructor that takes the name of the root + * node. + */ + +BOOST_AUTO_TEST_CASE( ctor_root_name ) +{ + xml::document doc("root"); + BOOST_CHECK( is_same_as_file( doc, "document/data/03.out") ); +} + + +/* + * This test checks xml::document constructor that takes a node. + */ + +BOOST_AUTO_TEST_CASE( ctor_root_node ) +{ + xml::node n("root", "pcdata"); + xml::document doc(n); + BOOST_CHECK( is_same_as_file( doc, "document/data/04.out") ); +} + + +/* + * This test checks xml::document copy constructor. + */ + +BOOST_AUTO_TEST_CASE( copy_ctor ) +{ + xml::node n("root", "pcdata"); + xml::document doc(n); + + xml::document doc_copy(doc); + + BOOST_CHECK( is_same_as_file( doc_copy, "document/data/04.out") ); +} + + +/* + * This test checks xml::document assignment operator. + */ + +BOOST_AUTO_TEST_CASE( assignment_operator ) +{ + xml::node n("root", "pcdata"); + xml::document doc(n); + + xml::document doc_copy; + doc_copy = doc; + + BOOST_CHECK( is_same_as_file( doc_copy, "document/data/04.out") ); +} + + +/* + * This test checks xml::document::get_root_node. + */ + +BOOST_AUTO_TEST_CASE( get_root_node ) +{ + xml::node n("root", "pcdata"); + xml::document doc(n); + + BOOST_CHECK( is_same_as_file( doc.get_root_node(), "document/data/04.out") ); +} + + +/* + * This test checks xml::document::set_root_node(). + */ + +BOOST_AUTO_TEST_CASE( set_root_node ) +{ + std::ostringstream ostr; + + xml::node n("root", "pcdata"); + + xml::document doc; + ostr << doc; // blank document + + doc.set_root_node(n); + ostr << doc; + + BOOST_CHECK( is_same_as_file( ostr, "document/data/08.out") ); +} + + +/* + * This test checks xml::document::get_version(). + */ + +BOOST_AUTO_TEST_CASE( get_version ) +{ + xml::tree_parser parser(test_file_path("document/data/09.xml").c_str()); + + BOOST_CHECK_EQUAL( parser.get_document().get_version(), "1.1" ); +} + + +/* + * This test checks xml::document::set_version(). + */ + +BOOST_AUTO_TEST_CASE( set_version ) +{ + xml::document doc("root"); + doc.set_version("1.1"); + + BOOST_CHECK( is_same_as_file( doc, "document/data/10.out") ); +} + + +/* + * This test checks xml::document::get_encoding(). + */ + +BOOST_AUTO_TEST_CASE( get_encoding ) +{ + xml::tree_parser parser(test_file_path("document/data/11.xml").c_str()); + + BOOST_CHECK_EQUAL( parser.get_document().get_encoding(), "UTF-8" ); +} + + +/* + * This test checks xml::document::set_encoding(). + */ + +BOOST_AUTO_TEST_CASE( set_encoding ) +{ + xml::document doc("root"); + doc.set_encoding("UTF-8"); + + BOOST_CHECK( is_same_as_file( doc, "document/data/12.out") ); +} + + +/* + * This test checks xml::document::get_is_standalone(). + */ + +BOOST_AUTO_TEST_CASE( get_is_standalone ) +{ + xml::tree_parser parser1(test_file_path("document/data/13a.xml").c_str()); + BOOST_CHECK_EQUAL( parser1.get_document().get_is_standalone(), false ); + + xml::tree_parser parser2(test_file_path("document/data/13b.xml").c_str()); + BOOST_CHECK_EQUAL( parser2.get_document().get_is_standalone(), true ); +} + + +/* + * This test checks xml::document::set_is_standalone(). + */ + +BOOST_AUTO_TEST_CASE( set_is_standalone ) +{ + xml::document doc1("root"); + doc1.set_is_standalone(true); + BOOST_CHECK( is_same_as_file( doc1, "document/data/13a.out") ); + + xml::document doc2("root"); + doc2.set_is_standalone(false); + BOOST_CHECK( is_same_as_file( doc2, "document/data/13b.out") ); +} + + +/* + * This test checks xml::document::process_xinclude() + */ +BOOST_AUTO_TEST_CASE( process_xinclude ) +{ + xml::tree_parser parser(test_file_path("document/data/14.xml").c_str()); + + BOOST_CHECK( parser.get_document().process_xinclude() ); + BOOST_CHECK( is_same_as_file( parser.get_document(), "document/data/14.out") ); +} + + +/* + * This test checks xml::document::size() + */ + +BOOST_AUTO_TEST_CASE( size ) +{ + xml::document doc_01("root"); + BOOST_CHECK_EQUAL( doc_01.size(), 1 ); + + doc_01.push_back(xml::node(xml::node::comment("This is a comment"))); + BOOST_CHECK_EQUAL( doc_01.size(), 2 ); + + xml::document doc_02(doc_01); + BOOST_CHECK_EQUAL( doc_02.size(), 2 ); + + xml::document doc_03; + BOOST_CHECK_EQUAL( doc_03.size(), 1 ); + + xml::node n("root"); + xml::document doc_04(n); + BOOST_CHECK_EQUAL( doc_04.size(), 1 ); +} + + +/* + * This test checks xml::document::push_back and insert + */ + +BOOST_AUTO_TEST_CASE( push_back_and_insert ) +{ + xml::document doc("root"); + + doc.push_back(xml::node(xml::node::comment(" Comment From push_back "))); + + xml::node::iterator n(doc.insert(xml::node(xml::node::comment("This Will Be Changed")))); + n->set_content(" Comment From insert "); + + n = doc.insert(doc.begin(), xml::node(xml::node::pi("test"))); + n->set_content("one=\"1\""); + + BOOST_CHECK( is_same_as_file( doc, "document/data/17.out") ); +} + + +/* + * This test checks xml::document::push_back and insert to make sure they + * throw exceptions + */ + +BOOST_AUTO_TEST_CASE( push_back_and_insert_throw ) +{ + xml::document doc("root"); + + BOOST_CHECK_THROW + ( + doc.push_back(xml::node("noway")), + xml::exception + ); + + BOOST_CHECK_THROW + ( + doc.insert(xml::node("noway")), + xml::exception + ); + + BOOST_CHECK_THROW + ( + doc.insert(doc.end(), xml::node("noway")), + xml::exception + ); +} + + +/* + * This test checks xml::document::replace() + */ + +BOOST_AUTO_TEST_CASE( replace ) +{ + xml::document doc("root"); + + xml::node::iterator n(doc.insert(xml::node(xml::node::comment(" To Be Replaced ")))); + doc.replace(n, xml::node(xml::node::comment(" This is the replacement comment "))); + + BOOST_CHECK( is_same_as_file( doc, "document/data/19.out") ); +} + + +/* + * This test checks xml::document::replace() to make sure it throws exceptions + */ + +BOOST_AUTO_TEST_CASE( replace_throw ) +{ + xml::document doc("root"); + xml::node::iterator n(doc.insert(xml::node(xml::node::comment(" To Be Replaced ")))); + + BOOST_CHECK_THROW + ( + doc.replace(n, xml::node("noway")), + xml::exception + ); + + BOOST_CHECK_THROW + ( + doc.replace(doc.begin(), xml::node(xml::node::comment(" no way "))), + xml::exception + ); +} + + +/* + * This test checks xml::document::erase(). + */ + +BOOST_AUTO_TEST_CASE( erase ) +{ + xml::document doc("root"); + doc.push_back(xml::node(xml::node::comment(" Comment from push_back "))); + + xml::node::iterator n(doc.insert(xml::node(xml::node::comment(" You should not see me ")))); + doc.erase(n); + + BOOST_CHECK( is_same_as_file(doc, "document/data/21.out") ); +} + +/* + * This test checks xml::document::erase() to make sure it throws an + * exception. + */ + +BOOST_AUTO_TEST_CASE( cant_erase_root ) +{ + xml::document doc("root"); + doc.push_back(xml::node(xml::node::comment(" Comment from push_back "))); + + BOOST_CHECK_THROW + ( + doc.erase(doc.begin(), doc.end()), + xml::exception + ); +} + + +static const char *TEST_FILE = "test_temp_file"; + +/* + * These tests check xml::docment::save_to_file() + */ + +BOOST_AUTO_TEST_CASE( save_to_file ) +{ + xml::document doc("root"); + doc.get_root_node().push_back(xml::node("child")); + + doc.save_to_file(TEST_FILE); + + std::ifstream stream(TEST_FILE); + BOOST_CHECK( is_same_as_file(read_file_into_string(stream), "document/data/15.out") ); + + remove(TEST_FILE); +} + + +#ifndef __SUNPRO_CC // SunCC can't compile gzip_decompressor +BOOST_AUTO_TEST_CASE( save_to_file_gzip ) +{ + xml::document doc("root"); + doc.get_root_node().push_back(xml::node("child")); + + doc.save_to_file(TEST_FILE, 9); + + // verify that the file was can be read back as compressed + std::ifstream stream(TEST_FILE); + boost::iostreams::filtering_stream<boost::iostreams::input> filter; + filter.push(boost::iostreams::gzip_decompressor()); + filter.push(stream); + BOOST_CHECK( is_same_as_file(read_file_into_string(filter), "document/data/15.out") ); + + // ...and by libxml2 directly too + xml::tree_parser parser(TEST_FILE); + + remove(TEST_FILE); +} +#endif // !__SUNPRO_CC + + +BOOST_AUTO_TEST_SUITE_END() Deleted: trunk/tests/document/test_document.cxx =================================================================== --- trunk/tests/document/test_document.cxx 2012-03-20 01:20:13 UTC (rev 196) +++ trunk/tests/document/test_document.cxx 2012-03-20 01:38:42 UTC (rev 197) @@ -1,439 +0,0 @@ -/* - * Copyright (C) 2001-2003 Peter J Jones (pj...@pm...) - * Copyright (C) 2009 Vaclav Slavik (vs...@fa...) - * All Rights Reserved - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name of the Author nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR - * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include "../test.h" - -#include <boost/iostreams/filtering_stream.hpp> -#include <boost/iostreams/filter/gzip.hpp> - -BOOST_AUTO_TEST_SUITE( document ) - -/* - * This test checks xml::document iteration. - */ - -BOOST_AUTO_TEST_CASE( dump_type ) -... [truncated message content] |
From: <tbr...@us...> - 2012-03-20 01:20:20
|
Revision: 196 http://xmlwrapp.svn.sourceforge.net/xmlwrapp/?rev=196&view=rev Author: tbrowder2 Date: 2012-03-20 01:20:13 +0000 (Tue, 20 Mar 2012) Log Message: ----------- change C++ source file extensions from cxx to cc Modified Paths: -------------- trunk/src/Makefile.am Modified: trunk/src/Makefile.am =================================================================== --- trunk/src/Makefile.am 2012-03-19 23:02:47 UTC (rev 195) +++ trunk/src/Makefile.am 2012-03-20 01:20:13 UTC (rev 196) @@ -12,23 +12,23 @@ libxmlwrapp_la_LDFLAGS = -version-info 6:0:1 -no-undefined libxmlwrapp_la_SOURCES = \ - libxml/ait_impl.cxx \ + libxml/ait_impl.cc \ libxml/ait_impl.h \ - libxml/attributes.cxx \ - libxml/document.cxx \ - libxml/dtd_impl.cxx \ + libxml/attributes.cc \ + libxml/document.cc \ + libxml/dtd_impl.cc \ libxml/dtd_impl.h \ - libxml/event_parser.cxx \ - libxml/init.cxx \ - libxml/node.cxx \ - libxml/nodes_view.cxx \ - libxml/node_iterator.cxx \ + libxml/event_parser.cc \ + libxml/init.cc \ + libxml/node.cc \ + libxml/nodes_view.cc \ + libxml/node_iterator.cc \ libxml/node_iterator.h \ - libxml/node_manip.cxx \ + libxml/node_manip.cc \ libxml/node_manip.h \ libxml/pimpl_base.h \ - libxml/tree_parser.cxx \ - libxml/utility.cxx \ + libxml/tree_parser.cc \ + libxml/utility.cc \ libxml/utility.h @@ -39,8 +39,8 @@ libxsltwrapp_la_LDFLAGS = -version-info 3:0:0 -no-undefined libxsltwrapp_la_SOURCES = \ - libxslt/init.cxx \ + libxslt/init.cc \ libxslt/result.h \ - libxslt/stylesheet.cxx + libxslt/stylesheet.cc endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tbr...@us...> - 2012-03-19 23:02:56
|
Revision: 195 http://xmlwrapp.svn.sourceforge.net/xmlwrapp/?rev=195&view=rev Author: tbrowder2 Date: 2012-03-19 23:02:47 +0000 (Mon, 19 Mar 2012) Log Message: ----------- change C++ source file suffix from .cxx to .cc Added Paths: ----------- trunk/src/libxml/ait_impl.cc trunk/src/libxml/attributes.cc trunk/src/libxml/document.cc trunk/src/libxml/dtd_impl.cc trunk/src/libxml/event_parser.cc trunk/src/libxml/init.cc trunk/src/libxml/node.cc trunk/src/libxml/node_iterator.cc trunk/src/libxml/node_manip.cc trunk/src/libxml/nodes_view.cc trunk/src/libxml/tree_parser.cc trunk/src/libxml/utility.cc trunk/src/libxslt/init.cc trunk/src/libxslt/stylesheet.cc Removed Paths: ------------- trunk/src/libxml/ait_impl.cxx trunk/src/libxml/attributes.cxx trunk/src/libxml/document.cxx trunk/src/libxml/dtd_impl.cxx trunk/src/libxml/event_parser.cxx trunk/src/libxml/init.cxx trunk/src/libxml/node.cxx trunk/src/libxml/node_iterator.cxx trunk/src/libxml/node_manip.cxx trunk/src/libxml/nodes_view.cxx trunk/src/libxml/tree_parser.cxx trunk/src/libxml/utility.cxx trunk/src/libxslt/init.cxx trunk/src/libxslt/stylesheet.cxx Copied: trunk/src/libxml/ait_impl.cc (from rev 186, trunk/src/libxml/ait_impl.cxx) =================================================================== --- trunk/src/libxml/ait_impl.cc (rev 0) +++ trunk/src/libxml/ait_impl.cc 2012-03-19 23:02:47 UTC (rev 195) @@ -0,0 +1,459 @@ +/* + * Copyright (C) 2001-2003 Peter J Jones (pj...@pm...) + * All Rights Reserved + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name of the Author nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR + * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +// xmlwrapp includes +#include "ait_impl.h" +#include "utility.h" +#include "xmlwrapp/attributes.h" +#include "xmlwrapp/exception.h" + +// standard includes +#include <algorithm> + +// libxml2 includes +#include <libxml/tree.h> + +namespace xml +{ + +using namespace impl; + +// ------------------------------------------------------------------------ +// xml::impl::ait_impl +// ------------------------------------------------------------------------ + +namespace impl +{ + +ait_impl::ait_impl(xmlNodePtr node, xmlAttrPtr prop) + : xmlnode_(node), xmlattr_(prop), fake_(false) +{ + attr_.set_data(xmlnode_, xmlattr_); +} + + +ait_impl::ait_impl(const char *name, const char *value, bool) + : xmlnode_(0), xmlattr_(0), fake_(true) +{ + // in this constructor and in the functions to follow, the last + // parameter, the bool, is only used to create a unique signature + attr_.set_data(name, value, true); +} + + +ait_impl::ait_impl(const ait_impl& other) + : xmlnode_(other.xmlnode_), xmlattr_(other.xmlattr_), fake_(other.fake_) +{ + if (fake_) + attr_.set_data(other.attr_.get_name(), other.attr_.get_value(), true); + else + attr_.set_data(xmlnode_, xmlattr_); +} + + +ait_impl& ait_impl::operator=(const ait_impl& other) +{ + ait_impl tmp(other); + + std::swap(xmlnode_, tmp.xmlnode_); + std::swap(xmlattr_, tmp.xmlattr_); + std::swap(fake_, tmp.fake_); + attr_.swap(tmp.attr_); + + return *this; +} + + +attributes::attr* ait_impl::get() +{ + return &attr_; +} + + +xmlAttrPtr ait_impl::get_raw_attr() +{ + return xmlattr_; +} + + +ait_impl& ait_impl::operator++() +{ + if (xmlattr_) + xmlattr_ = xmlattr_->next; + else + fake_ = false; + + attr_.set_data(xmlnode_, xmlattr_); + return *this; +} + + +ait_impl ait_impl::operator++(int) +{ + ait_impl tmp(xmlnode_, xmlattr_); + ++(*this); + return tmp; +} + +} // namespace impl + + +// ------------------------------------------------------------------------ +// xml::attributes::iterator +// ------------------------------------------------------------------------ + +attributes::iterator::iterator() +{ + pimpl_ = new ait_impl(0, 0); +} + + +attributes::iterator::iterator(void *node, void *prop) +{ + pimpl_ = new ait_impl(static_cast<xmlNodePtr>(node), static_cast<xmlAttrPtr>(prop)); +} + + +attributes::iterator::iterator(const char *name, const char *value, bool) +{ + pimpl_ = new ait_impl(name, value, true); +} + + +attributes::iterator::iterator (const iterator &other) +{ + pimpl_ = new ait_impl(*other.pimpl_); +} + + +attributes::iterator& attributes::iterator::operator=(const iterator& other) +{ + iterator tmp(other); + swap(tmp); + return *this; +} + + +void attributes::iterator::swap(iterator& other) +{ + std::swap(pimpl_, other.pimpl_); +} + + +attributes::iterator::~iterator() +{ + delete pimpl_; +} + + +void* attributes::iterator::get_raw_attr() +{ + return pimpl_->get_raw_attr(); +} + + +attributes::iterator::reference attributes::iterator::operator*() const +{ + return *(pimpl_->get()); +} + + +attributes::iterator::pointer attributes::iterator::operator->() const +{ + return pimpl_->get(); +} + + +attributes::iterator& attributes::iterator::operator++() +{ + ++(*pimpl_); + return *this; +} + + +attributes::iterator attributes::iterator::operator++(int) +{ + iterator tmp(*this); + ++(*this); + return tmp; +} + + +// ------------------------------------------------------------------------ +// xml::attributes::const_iterator +// ------------------------------------------------------------------------ + +attributes::const_iterator::const_iterator() +{ + pimpl_ = new ait_impl(0, 0); +} + + +attributes::const_iterator::const_iterator(void *node, void *prop) +{ + pimpl_ = new ait_impl(static_cast<xmlNodePtr>(node), static_cast<xmlAttrPtr>(prop)); +} + + +attributes::const_iterator::const_iterator(const char *name, const char *value, bool) +{ + pimpl_ = new ait_impl(name, value, true); +} + + +attributes::const_iterator::const_iterator(const const_iterator& other) +{ + pimpl_ = new ait_impl(*other.pimpl_); +} + + +attributes::const_iterator::const_iterator(const iterator& other) +{ + pimpl_ = new ait_impl(*other.pimpl_); +} + + +attributes::const_iterator& attributes::const_iterator::operator=(const const_iterator& other) +{ + const_iterator tmp(other); + swap(tmp); + return *this; +} + + +void attributes::const_iterator::swap(const_iterator& other) +{ + std::swap(pimpl_, other.pimpl_); +} + + +attributes::const_iterator::~const_iterator() +{ + delete pimpl_; +} + + +void* attributes::const_iterator::get_raw_attr() +{ + return pimpl_->get_raw_attr(); +} + + +attributes::const_iterator::reference attributes::const_iterator::operator*() const +{ + return *(pimpl_->get()); +} + + +attributes::const_iterator::pointer attributes::const_iterator::operator->() const +{ + return pimpl_->get(); +} + + +attributes::const_iterator& attributes::const_iterator::operator++() +{ + ++(*pimpl_); + return *this; +} + + +attributes::const_iterator attributes::const_iterator::operator++(int) +{ + const_iterator tmp(*this); + ++(*this); + return tmp; +} + + +// ------------------------------------------------------------------------ +// xml::attributes::attr +// ------------------------------------------------------------------------ + +attributes::attr::attr() : node_(0), prop_(0) +{ +} + + +attributes::attr::attr(const attr& other) + : node_(other.node_), + prop_(other.prop_), + name_(other.name_), + value_(other.value_) +{ +} + + +attributes::attr& attributes::attr::operator=(const attr& other) +{ + attr tmp(other); + swap(tmp); + return *this; +} + + +void attributes::attr::swap(attr& other) +{ + std::swap(node_, other.node_); + std::swap(prop_, other.prop_); + name_.swap(other.name_); + value_.swap(other.value_); +} + + +void attributes::attr::set_data(void *node, void *prop) +{ + node_ = node; + prop_ = prop; + name_.erase(); + value_.erase(); +} + + +void attributes::attr::set_data(const char *name, const char *value, bool) +{ + node_ = 0; + prop_ = 0; + name_ = name; + value_ = value; +} + + +const char* attributes::attr::get_name() const +{ + if (!name_.empty()) + return name_.c_str(); // we were given a name not a node + + if (!node_ || !prop_) + throw xml::exception("access to invalid attributes::attr object!"); + + return reinterpret_cast<const char*>(static_cast<xmlAttrPtr>(prop_)->name); +} + + +const char* attributes::attr::get_value() const +{ + if (!value_.empty()) + return value_.c_str(); // we were given a value, not a node + + if (!node_ || !prop_) + throw xml::exception("access to invalid attributes::attr object!"); + + xmlChar *tmpstr = xmlNodeListGetString(reinterpret_cast<xmlNodePtr>(node_)->doc, reinterpret_cast<xmlAttrPtr>(prop_)->children, 1); + if (tmpstr == 0) + return ""; + + xmlchar_helper helper(tmpstr); + value_.assign(helper.get()); + return value_.c_str(); +} + +// ------------------------------------------------------------------------ +// helper friend functions and operators +// ------------------------------------------------------------------------ + +bool operator==(const attributes::iterator& lhs, const attributes::iterator& rhs) +{ + return *(lhs.pimpl_) == *(rhs.pimpl_); +} + +bool operator!=(const attributes::iterator& lhs, const attributes::iterator& rhs) +{ + return !(lhs == rhs); +} + +bool operator==(const attributes::const_iterator& lhs, const attributes::const_iterator& rhs) +{ + return *(lhs.pimpl_) == *(rhs.pimpl_); +} + +bool operator!=(const attributes::const_iterator& lhs, const attributes::const_iterator& rhs) +{ + return !(lhs == rhs); +} + + +namespace impl +{ + +xmlAttrPtr find_prop(xmlNodePtr xmlnode, const char *name) +{ + xmlAttrPtr prop = xmlnode->properties; + + for (; prop; prop = prop->next ) + { + if (xmlStrEqual(prop->name, reinterpret_cast<const xmlChar*>(name))) + return prop; + } + + return 0; +} + + +xmlAttributePtr find_default_prop(xmlNodePtr xmlnode, const char *name) +{ + if (xmlnode->doc != 0) + { + xmlAttributePtr dtd_attr=0; + + if (xmlnode->doc->intSubset != 0) + { + dtd_attr = xmlGetDtdAttrDesc(xmlnode->doc->intSubset, xmlnode->name, reinterpret_cast<const xmlChar*>(name)); + } + + if (dtd_attr == 0 && xmlnode->doc->extSubset != 0) + { + dtd_attr = xmlGetDtdAttrDesc(xmlnode->doc->extSubset, xmlnode->name, reinterpret_cast<const xmlChar*>(name)); + } + + if (dtd_attr != 0 && dtd_attr->defaultValue != 0) + return dtd_attr; + } + + return 0; +} + +bool operator==(const ait_impl& lhs, const ait_impl& rhs) +{ + if (lhs.fake_ || rhs.fake_) + return false; + return lhs.xmlattr_ == rhs.xmlattr_; +} + +bool operator!=(const ait_impl& lhs, const ait_impl& rhs) +{ + return !(lhs == rhs); +} + +} // namespace impl + +} // namespace xml Deleted: trunk/src/libxml/ait_impl.cxx =================================================================== --- trunk/src/libxml/ait_impl.cxx 2012-03-19 19:25:15 UTC (rev 194) +++ trunk/src/libxml/ait_impl.cxx 2012-03-19 23:02:47 UTC (rev 195) @@ -1,459 +0,0 @@ -/* - * Copyright (C) 2001-2003 Peter J Jones (pj...@pm...) - * All Rights Reserved - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name of the Author nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR - * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -// xmlwrapp includes -#include "ait_impl.h" -#include "utility.h" -#include "xmlwrapp/attributes.h" -#include "xmlwrapp/exception.h" - -// standard includes -#include <algorithm> - -// libxml2 includes -#include <libxml/tree.h> - -namespace xml -{ - -using namespace impl; - -// ------------------------------------------------------------------------ -// xml::impl::ait_impl -// ------------------------------------------------------------------------ - -namespace impl -{ - -ait_impl::ait_impl(xmlNodePtr node, xmlAttrPtr prop) - : xmlnode_(node), xmlattr_(prop), fake_(false) -{ - attr_.set_data(xmlnode_, xmlattr_); -} - - -ait_impl::ait_impl(const char *name, const char *value, bool) - : xmlnode_(0), xmlattr_(0), fake_(true) -{ - // in this constructor and in the functions to follow, the last - // parameter, the bool, is only used to create a unique signature - attr_.set_data(name, value, true); -} - - -ait_impl::ait_impl(const ait_impl& other) - : xmlnode_(other.xmlnode_), xmlattr_(other.xmlattr_), fake_(other.fake_) -{ - if (fake_) - attr_.set_data(other.attr_.get_name(), other.attr_.get_value(), true); - else - attr_.set_data(xmlnode_, xmlattr_); -} - - -ait_impl& ait_impl::operator=(const ait_impl& other) -{ - ait_impl tmp(other); - - std::swap(xmlnode_, tmp.xmlnode_); - std::swap(xmlattr_, tmp.xmlattr_); - std::swap(fake_, tmp.fake_); - attr_.swap(tmp.attr_); - - return *this; -} - - -attributes::attr* ait_impl::get() -{ - return &attr_; -} - - -xmlAttrPtr ait_impl::get_raw_attr() -{ - return xmlattr_; -} - - -ait_impl& ait_impl::operator++() -{ - if (xmlattr_) - xmlattr_ = xmlattr_->next; - else - fake_ = false; - - attr_.set_data(xmlnode_, xmlattr_); - return *this; -} - - -ait_impl ait_impl::operator++(int) -{ - ait_impl tmp(xmlnode_, xmlattr_); - ++(*this); - return tmp; -} - -} // namespace impl - - -// ------------------------------------------------------------------------ -// xml::attributes::iterator -// ------------------------------------------------------------------------ - -attributes::iterator::iterator() -{ - pimpl_ = new ait_impl(0, 0); -} - - -attributes::iterator::iterator(void *node, void *prop) -{ - pimpl_ = new ait_impl(static_cast<xmlNodePtr>(node), static_cast<xmlAttrPtr>(prop)); -} - - -attributes::iterator::iterator(const char *name, const char *value, bool) -{ - pimpl_ = new ait_impl(name, value, true); -} - - -attributes::iterator::iterator (const iterator &other) -{ - pimpl_ = new ait_impl(*other.pimpl_); -} - - -attributes::iterator& attributes::iterator::operator=(const iterator& other) -{ - iterator tmp(other); - swap(tmp); - return *this; -} - - -void attributes::iterator::swap(iterator& other) -{ - std::swap(pimpl_, other.pimpl_); -} - - -attributes::iterator::~iterator() -{ - delete pimpl_; -} - - -void* attributes::iterator::get_raw_attr() -{ - return pimpl_->get_raw_attr(); -} - - -attributes::iterator::reference attributes::iterator::operator*() const -{ - return *(pimpl_->get()); -} - - -attributes::iterator::pointer attributes::iterator::operator->() const -{ - return pimpl_->get(); -} - - -attributes::iterator& attributes::iterator::operator++() -{ - ++(*pimpl_); - return *this; -} - - -attributes::iterator attributes::iterator::operator++(int) -{ - iterator tmp(*this); - ++(*this); - return tmp; -} - - -// ------------------------------------------------------------------------ -// xml::attributes::const_iterator -// ------------------------------------------------------------------------ - -attributes::const_iterator::const_iterator() -{ - pimpl_ = new ait_impl(0, 0); -} - - -attributes::const_iterator::const_iterator(void *node, void *prop) -{ - pimpl_ = new ait_impl(static_cast<xmlNodePtr>(node), static_cast<xmlAttrPtr>(prop)); -} - - -attributes::const_iterator::const_iterator(const char *name, const char *value, bool) -{ - pimpl_ = new ait_impl(name, value, true); -} - - -attributes::const_iterator::const_iterator(const const_iterator& other) -{ - pimpl_ = new ait_impl(*other.pimpl_); -} - - -attributes::const_iterator::const_iterator(const iterator& other) -{ - pimpl_ = new ait_impl(*other.pimpl_); -} - - -attributes::const_iterator& attributes::const_iterator::operator=(const const_iterator& other) -{ - const_iterator tmp(other); - swap(tmp); - return *this; -} - - -void attributes::const_iterator::swap(const_iterator& other) -{ - std::swap(pimpl_, other.pimpl_); -} - - -attributes::const_iterator::~const_iterator() -{ - delete pimpl_; -} - - -void* attributes::const_iterator::get_raw_attr() -{ - return pimpl_->get_raw_attr(); -} - - -attributes::const_iterator::reference attributes::const_iterator::operator*() const -{ - return *(pimpl_->get()); -} - - -attributes::const_iterator::pointer attributes::const_iterator::operator->() const -{ - return pimpl_->get(); -} - - -attributes::const_iterator& attributes::const_iterator::operator++() -{ - ++(*pimpl_); - return *this; -} - - -attributes::const_iterator attributes::const_iterator::operator++(int) -{ - const_iterator tmp(*this); - ++(*this); - return tmp; -} - - -// ------------------------------------------------------------------------ -// xml::attributes::attr -// ------------------------------------------------------------------------ - -attributes::attr::attr() : node_(0), prop_(0) -{ -} - - -attributes::attr::attr(const attr& other) - : node_(other.node_), - prop_(other.prop_), - name_(other.name_), - value_(other.value_) -{ -} - - -attributes::attr& attributes::attr::operator=(const attr& other) -{ - attr tmp(other); - swap(tmp); - return *this; -} - - -void attributes::attr::swap(attr& other) -{ - std::swap(node_, other.node_); - std::swap(prop_, other.prop_); - name_.swap(other.name_); - value_.swap(other.value_); -} - - -void attributes::attr::set_data(void *node, void *prop) -{ - node_ = node; - prop_ = prop; - name_.erase(); - value_.erase(); -} - - -void attributes::attr::set_data(const char *name, const char *value, bool) -{ - node_ = 0; - prop_ = 0; - name_ = name; - value_ = value; -} - - -const char* attributes::attr::get_name() const -{ - if (!name_.empty()) - return name_.c_str(); // we were given a name not a node - - if (!node_ || !prop_) - throw xml::exception("access to invalid attributes::attr object!"); - - return reinterpret_cast<const char*>(static_cast<xmlAttrPtr>(prop_)->name); -} - - -const char* attributes::attr::get_value() const -{ - if (!value_.empty()) - return value_.c_str(); // we were given a value, not a node - - if (!node_ || !prop_) - throw xml::exception("access to invalid attributes::attr object!"); - - xmlChar *tmpstr = xmlNodeListGetString(reinterpret_cast<xmlNodePtr>(node_)->doc, reinterpret_cast<xmlAttrPtr>(prop_)->children, 1); - if (tmpstr == 0) - return ""; - - xmlchar_helper helper(tmpstr); - value_.assign(helper.get()); - return value_.c_str(); -} - -// ------------------------------------------------------------------------ -// helper friend functions and operators -// ------------------------------------------------------------------------ - -bool operator==(const attributes::iterator& lhs, const attributes::iterator& rhs) -{ - return *(lhs.pimpl_) == *(rhs.pimpl_); -} - -bool operator!=(const attributes::iterator& lhs, const attributes::iterator& rhs) -{ - return !(lhs == rhs); -} - -bool operator==(const attributes::const_iterator& lhs, const attributes::const_iterator& rhs) -{ - return *(lhs.pimpl_) == *(rhs.pimpl_); -} - -bool operator!=(const attributes::const_iterator& lhs, const attributes::const_iterator& rhs) -{ - return !(lhs == rhs); -} - - -namespace impl -{ - -xmlAttrPtr find_prop(xmlNodePtr xmlnode, const char *name) -{ - xmlAttrPtr prop = xmlnode->properties; - - for (; prop; prop = prop->next ) - { - if (xmlStrEqual(prop->name, reinterpret_cast<const xmlChar*>(name))) - return prop; - } - - return 0; -} - - -xmlAttributePtr find_default_prop(xmlNodePtr xmlnode, const char *name) -{ - if (xmlnode->doc != 0) - { - xmlAttributePtr dtd_attr=0; - - if (xmlnode->doc->intSubset != 0) - { - dtd_attr = xmlGetDtdAttrDesc(xmlnode->doc->intSubset, xmlnode->name, reinterpret_cast<const xmlChar*>(name)); - } - - if (dtd_attr == 0 && xmlnode->doc->extSubset != 0) - { - dtd_attr = xmlGetDtdAttrDesc(xmlnode->doc->extSubset, xmlnode->name, reinterpret_cast<const xmlChar*>(name)); - } - - if (dtd_attr != 0 && dtd_attr->defaultValue != 0) - return dtd_attr; - } - - return 0; -} - -bool operator==(const ait_impl& lhs, const ait_impl& rhs) -{ - if (lhs.fake_ || rhs.fake_) - return false; - return lhs.xmlattr_ == rhs.xmlattr_; -} - -bool operator!=(const ait_impl& lhs, const ait_impl& rhs) -{ - return !(lhs == rhs); -} - -} // namespace impl - -} // namespace xml Copied: trunk/src/libxml/attributes.cc (from rev 186, trunk/src/libxml/attributes.cxx) =================================================================== --- trunk/src/libxml/attributes.cc (rev 0) +++ trunk/src/libxml/attributes.cc 2012-03-19 23:02:47 UTC (rev 195) @@ -0,0 +1,266 @@ +/* + * Copyright (C) 2001-2003 Peter J Jones (pj...@pm...) + * All Rights Reserved + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name of the Author nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR + * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +// xmlwrapp includes +#include "xmlwrapp/attributes.h" +#include "ait_impl.h" +#include "pimpl_base.h" + +// standard includes +#include <new> +#include <algorithm> + +// libxml2 includes +#include <libxml/tree.h> + +namespace xml +{ + +using namespace xml::impl; + +// ------------------------------------------------------------------------ +// xml::attributes::pimpl +// ------------------------------------------------------------------------ + +struct attributes::pimpl : public pimpl_base<attributes::pimpl> +{ + pimpl() : owner_(true) + { + xmlnode_ = xmlNewNode(0, reinterpret_cast<const xmlChar*>("blank")); + if (!xmlnode_) + throw std::bad_alloc(); + } + + pimpl(xmlNodePtr node) : xmlnode_(node), owner_(false) {} + + pimpl(const pimpl& other) : owner_(true) + { + xmlnode_ = xmlNewNode(0, reinterpret_cast<const xmlChar*>("blank")); + if (!xmlnode_) + throw std::bad_alloc(); + + xmlAttrPtr i=other.xmlnode_->properties; + xmlAttrPtr copy; + + // work around bug in libxml + for ( ; i != 0; i = i->next ) + { + if ( (copy = xmlCopyProp(0, i)) == 0) + { + xmlFreeNode(xmlnode_); + throw std::bad_alloc(); + } + + copy->prev = 0; + copy->next = 0; + xmlAddChild(xmlnode_, reinterpret_cast<xmlNodePtr>(copy)); + } + } + + ~pimpl() + { + release(); + } + + void release() + { + if (owner_ && xmlnode_) + xmlFreeNode(xmlnode_); + } + + xmlNodePtr xmlnode_; + bool owner_; +}; + + +// ------------------------------------------------------------------------ +// xml::attributes +// ------------------------------------------------------------------------ + +attributes::attributes() +{ + pimpl_ = new pimpl; +} + + +attributes::attributes(int) +{ + pimpl_ = new pimpl(0); +} + + +attributes::attributes(const attributes& other) +{ + pimpl_ = new pimpl(*other.pimpl_); +} + + +attributes& attributes::operator=(const attributes& other) +{ + attributes tmp(other); + swap(tmp); + return *this; +} + + +void attributes::swap(attributes& other) +{ + std::swap(pimpl_, other.pimpl_); +} + + +attributes::~attributes() +{ + delete pimpl_; +} + + +void* attributes::get_data() +{ + return pimpl_->xmlnode_; +} + + +void attributes::set_data(void *node) +{ + xmlNodePtr x = static_cast<xmlNodePtr>(node); + + pimpl_->release(); + pimpl_->owner_ = false; + pimpl_->xmlnode_ = x; +} + + +attributes::iterator attributes::begin() +{ + return iterator(pimpl_->xmlnode_, pimpl_->xmlnode_->properties); +} + + +attributes::const_iterator attributes::begin() const +{ + return const_iterator(pimpl_->xmlnode_, pimpl_->xmlnode_->properties); +} + + +attributes::iterator attributes::end() +{ + return iterator(); +} + + +attributes::const_iterator attributes::end() const +{ + return const_iterator(); +} + + +void attributes::insert(const char *name, const char *value) +{ + xmlSetProp(pimpl_->xmlnode_, + reinterpret_cast<const xmlChar*>(name), + reinterpret_cast<const xmlChar*>(value)); +} + + +attributes::iterator attributes::find(const char *name) +{ + xmlAttrPtr prop = find_prop(pimpl_->xmlnode_, name); + if ( prop != 0 ) + return iterator(pimpl_->xmlnode_, prop); + + xmlAttributePtr dtd_prop = find_default_prop(pimpl_->xmlnode_, name); + if ( dtd_prop != 0 ) + return iterator(name, reinterpret_cast<const char*>(dtd_prop->defaultValue), true); + + return iterator(); +} + + +attributes::const_iterator attributes::find(const char *name) const +{ + xmlAttrPtr prop = find_prop(pimpl_->xmlnode_, name); + if (prop != 0) + return const_iterator(pimpl_->xmlnode_, prop); + + xmlAttributePtr dtd_prop = find_default_prop(pimpl_->xmlnode_, name); + + if (dtd_prop != 0) + { + return const_iterator(name, reinterpret_cast<const char*>(dtd_prop->defaultValue), true); + } + + return const_iterator(); +} + + +attributes::iterator attributes::erase (iterator to_erase) +{ + xmlNodePtr prop = static_cast<xmlNodePtr>(to_erase.get_raw_attr()); + if (prop == 0) + return iterator(); // handle fake and bad iterators + ++to_erase; + + xmlUnlinkNode(prop); + xmlFreeNode(prop); + + return to_erase; +} + + +void attributes::erase(const char *name) +{ + xmlUnsetProp(pimpl_->xmlnode_, reinterpret_cast<const xmlChar*>(name)); +} + + +bool attributes::empty() const +{ + return pimpl_->xmlnode_->properties == 0; +} + + +attributes::size_type attributes::size() const +{ + size_type count = 0; + + xmlAttrPtr prop = pimpl_->xmlnode_->properties; + while (prop != 0) + { + ++count; + prop = prop->next; + } + + return count; +} + +} // namespace xml Deleted: trunk/src/libxml/attributes.cxx =================================================================== --- trunk/src/libxml/attributes.cxx 2012-03-19 19:25:15 UTC (rev 194) +++ trunk/src/libxml/attributes.cxx 2012-03-19 23:02:47 UTC (rev 195) @@ -1,266 +0,0 @@ -/* - * Copyright (C) 2001-2003 Peter J Jones (pj...@pm...) - * All Rights Reserved - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name of the Author nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR - * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -// xmlwrapp includes -#include "xmlwrapp/attributes.h" -#include "ait_impl.h" -#include "pimpl_base.h" - -// standard includes -#include <new> -#include <algorithm> - -// libxml2 includes -#include <libxml/tree.h> - -namespace xml -{ - -using namespace xml::impl; - -// ------------------------------------------------------------------------ -// xml::attributes::pimpl -// ------------------------------------------------------------------------ - -struct attributes::pimpl : public pimpl_base<attributes::pimpl> -{ - pimpl() : owner_(true) - { - xmlnode_ = xmlNewNode(0, reinterpret_cast<const xmlChar*>("blank")); - if (!xmlnode_) - throw std::bad_alloc(); - } - - pimpl(xmlNodePtr node) : xmlnode_(node), owner_(false) {} - - pimpl(const pimpl& other) : owner_(true) - { - xmlnode_ = xmlNewNode(0, reinterpret_cast<const xmlChar*>("blank")); - if (!xmlnode_) - throw std::bad_alloc(); - - xmlAttrPtr i=other.xmlnode_->properties; - xmlAttrPtr copy; - - // work around bug in libxml - for ( ; i != 0; i = i->next ) - { - if ( (copy = xmlCopyProp(0, i)) == 0) - { - xmlFreeNode(xmlnode_); - throw std::bad_alloc(); - } - - copy->prev = 0; - copy->next = 0; - xmlAddChild(xmlnode_, reinterpret_cast<xmlNodePtr>(copy)); - } - } - - ~pimpl() - { - release(); - } - - void release() - { - if (owner_ && xmlnode_) - xmlFreeNode(xmlnode_); - } - - xmlNodePtr xmlnode_; - bool owner_; -}; - - -// ------------------------------------------------------------------------ -// xml::attributes -// ------------------------------------------------------------------------ - -attributes::attributes() -{ - pimpl_ = new pimpl; -} - - -attributes::attributes(int) -{ - pimpl_ = new pimpl(0); -} - - -attributes::attributes(const attributes& other) -{ - pimpl_ = new pimpl(*other.pimpl_); -} - - -attributes& attributes::operator=(const attributes& other) -{ - attributes tmp(other); - swap(tmp); - return *this; -} - - -void attributes::swap(attributes& other) -{ - std::swap(pimpl_, other.pimpl_); -} - - -attributes::~attributes() -{ - delete pimpl_; -} - - -void* attributes::get_data() -{ - return pimpl_->xmlnode_; -} - - -void attributes::set_data(void *node) -{ - xmlNodePtr x = static_cast<xmlNodePtr>(node); - - pimpl_->release(); - pimpl_->owner_ = false; - pimpl_->xmlnode_ = x; -} - - -attributes::iterator attributes::begin() -{ - return iterator(pimpl_->xmlnode_, pimpl_->xmlnode_->properties); -} - - -attributes::const_iterator attributes::begin() const -{ - return const_iterator(pimpl_->xmlnode_, pimpl_->xmlnode_->properties); -} - - -attributes::iterator attributes::end() -{ - return iterator(); -} - - -attributes::const_iterator attributes::end() const -{ - return const_iterator(); -} - - -void attributes::insert(const char *name, const char *value) -{ - xmlSetProp(pimpl_->xmlnode_, - reinterpret_cast<const xmlChar*>(name), - reinterpret_cast<const xmlChar*>(value)); -} - - -attributes::iterator attributes::find(const char *name) -{ - xmlAttrPtr prop = find_prop(pimpl_->xmlnode_, name); - if ( prop != 0 ) - return iterator(pimpl_->xmlnode_, prop); - - xmlAttributePtr dtd_prop = find_default_prop(pimpl_->xmlnode_, name); - if ( dtd_prop != 0 ) - return iterator(name, reinterpret_cast<const char*>(dtd_prop->defaultValue), true); - - return iterator(); -} - - -attributes::const_iterator attributes::find(const char *name) const -{ - xmlAttrPtr prop = find_prop(pimpl_->xmlnode_, name); - if (prop != 0) - return const_iterator(pimpl_->xmlnode_, prop); - - xmlAttributePtr dtd_prop = find_default_prop(pimpl_->xmlnode_, name); - - if (dtd_prop != 0) - { - return const_iterator(name, reinterpret_cast<const char*>(dtd_prop->defaultValue), true); - } - - return const_iterator(); -} - - -attributes::iterator attributes::erase (iterator to_erase) -{ - xmlNodePtr prop = static_cast<xmlNodePtr>(to_erase.get_raw_attr()); - if (prop == 0) - return iterator(); // handle fake and bad iterators - ++to_erase; - - xmlUnlinkNode(prop); - xmlFreeNode(prop); - - return to_erase; -} - - -void attributes::erase(const char *name) -{ - xmlUnsetProp(pimpl_->xmlnode_, reinterpret_cast<const xmlChar*>(name)); -} - - -bool attributes::empty() const -{ - return pimpl_->xmlnode_->properties == 0; -} - - -attributes::size_type attributes::size() const -{ - size_type count = 0; - - xmlAttrPtr prop = pimpl_->xmlnode_->properties; - while (prop != 0) - { - ++count; - prop = prop->next; - } - - return count; -} - -} // namespace xml Copied: trunk/src/libxml/document.cc (from rev 186, trunk/src/libxml/document.cxx) =================================================================== --- trunk/src/libxml/document.cc (rev 0) +++ trunk/src/libxml/document.cc 2012-03-19 23:02:47 UTC (rev 195) @@ -0,0 +1,513 @@ +/* + * Copyright (C) 2001-2003 Peter J Jones (pj...@pm...) + * All Rights Reserved + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name of the Author nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR + * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +// xmlwrapp includes +#include "xmlwrapp/document.h" +#include "xmlwrapp/node.h" +#include "xmlwrapp/exception.h" + +#include "utility.h" +#include "dtd_impl.h" +#include "node_manip.h" + +// standard includes +#include <new> +#include <memory> +#include <iterator> +#include <iostream> +#include <algorithm> +#include <stdexcept> + +// libxml includes +#include <libxml/tree.h> +#include <libxml/xinclude.h> + +// bring in private libxslt stuff (see bug #1927398) +#include "../libxslt/result.h" + +namespace xml +{ + +using namespace impl; + +namespace +{ + const char DEFAULT_ENCODING[] = "ISO-8859-1"; +} + +// ------------------------------------------------------------------------ +// xml::impl::doc_impl +// ------------------------------------------------------------------------ + +namespace impl +{ + +struct doc_impl +{ + doc_impl() + : doc_(0), xslt_result_(0) + { + xmlDocPtr tmpdoc; + if ( (tmpdoc = xmlNewDoc(0)) == 0) + throw std::bad_alloc(); + set_doc_data(tmpdoc, true); + } + + + doc_impl(const char *root_name) + : doc_(0), xslt_result_(0), root_(root_name) + { + xmlDocPtr tmpdoc; + if ( (tmpdoc = xmlNewDoc(0)) == 0) + throw std::bad_alloc(); + set_doc_data(tmpdoc, true); + } + + + doc_impl(const doc_impl& other) + : doc_(0), xslt_result_(0) + { + xmlDocPtr tmpdoc; + if ( (tmpdoc = xmlCopyDoc(other.doc_, 1)) == 0) + throw std::bad_alloc(); + set_doc_data(tmpdoc, false); + } + + + void set_doc_data(xmlDocPtr newdoc, bool root_is_okay) + { + if (doc_) + xmlFreeDoc(doc_); + doc_ = newdoc; + + if (doc_->version) + version_ = reinterpret_cast<const char*>(doc_->version); + if (doc_->encoding) + encoding_ = reinterpret_cast<const char*>(doc_->encoding); + + if (root_is_okay) + { + xmlDocSetRootElement(doc_, static_cast<xmlNodePtr>(root_.release_node_data())); + } + else + { + xmlNodePtr libxml_root_node = xmlDocGetRootElement(doc_); + + if (libxml_root_node) + { + root_.set_node_data(libxml_root_node); + } + else + { + node tmpnode; + root_.swap(tmpnode); + + xmlDocSetRootElement(doc_, static_cast<xmlNodePtr>(root_.release_node_data())); + } + } + } + + + void set_root_node(const node& n) + { + node &non_const_node = const_cast<node&>(n); + xmlNodePtr new_root_node = xmlCopyNode(static_cast<xmlNodePtr>(non_const_node.get_node_data()), 1); + if (!new_root_node) + throw std::bad_alloc(); + + xmlNodePtr old_root_node = xmlDocSetRootElement(doc_, new_root_node); + root_.set_node_data(new_root_node); + if (old_root_node) + xmlFreeNode(old_root_node); + + xslt_result_ = 0; + } + + + ~doc_impl() + { + if (doc_) + xmlFreeDoc(doc_); + delete xslt_result_; + } + + xmlDocPtr doc_; + xslt::impl::result *xslt_result_; + node root_; + std::string version_; + mutable std::string encoding_; +}; + +} // namespace impl + + +// ------------------------------------------------------------------------ +// xml::document +// ------------------------------------------------------------------------ + +document::document() +{ + pimpl_ = new doc_impl; +} + + +document::document(const char *root_name) +{ + pimpl_ = new doc_impl(root_name); +} + + +document::document(const node& n) +{ + std::auto_ptr<doc_impl> ap(pimpl_ = new doc_impl); + pimpl_->set_root_node(n); + ap.release(); +} + + +document::document(const document& other) +{ + pimpl_ = new doc_impl(*(other.pimpl_)); +} + + +document& document::operator=(const document& other) +{ + document tmp(other); + swap(tmp); + return *this; +} + + +void document::swap(document& other) +{ + std::swap(pimpl_, other.pimpl_); +} + + +document::~document() +{ + delete pimpl_; +} + + +const node& document::get_root_node() const +{ + return pimpl_->root_; +} + + +node& document::get_root_node() +{ + return pimpl_->root_; +} + + +void document::set_root_node(const node& n) +{ + pimpl_->set_root_node(n); +} + + +const std::string& document::get_version() const +{ + return pimpl_->version_; +} + + +void document::set_version(const char *version) +{ + const xmlChar *old_version = pimpl_->doc_->version; + if ( (pimpl_->doc_->version = xmlStrdup(reinterpret_cast<const xmlChar*>(version))) == 0) + throw std::bad_alloc(); + + pimpl_->version_ = version; + if (old_version) + xmlFree(const_cast<char*>(reinterpret_cast<const char*>(old_version))); +} + + +const std::string& document::get_encoding() const +{ + if (pimpl_->encoding_.empty()) + pimpl_->encoding_ = DEFAULT_ENCODING; + return pimpl_->encoding_; +} + + +void document::set_encoding(const char *encoding) +{ + pimpl_->encoding_ = encoding; + + if (pimpl_->doc_->encoding) + xmlFree(const_cast<xmlChar*>(pimpl_->doc_->encoding)); + + pimpl_->doc_->encoding = xmlStrdup(reinterpret_cast<const xmlChar*>(encoding)); + + if (!pimpl_->doc_->encoding) + throw std::bad_alloc(); +} + + +bool document::get_is_standalone() const +{ + return pimpl_->doc_->standalone == 1; +} + + +void document::set_is_standalone(bool sa) +{ + pimpl_->doc_->standalone = sa ? 1 : 0; +} + + +bool document::process_xinclude() +{ + // xmlXIncludeProcess does not return what is says it does + return xmlXIncludeProcess(pimpl_->doc_) >= 0; +} + + +bool document::has_internal_subset() const +{ + return pimpl_->doc_->intSubset != 0; +} + + +bool document::has_external_subset() const +{ + return pimpl_->doc_->extSubset != 0; +} + + +bool document::validate() +{ + dtd_impl dtd; + return dtd.validate(pimpl_->doc_); +} + + +bool document::validate(const char *dtdname) +{ + dtd_impl dtd(dtdname); + + if (!dtd.error_.empty()) + return false; + if (!dtd.validate(pimpl_->doc_)) + return false; + + // remove the old DTD + if (pimpl_->doc_->extSubset != 0) + xmlFreeDtd(pimpl_->doc_->extSubset); + + pimpl_->doc_->extSubset = dtd.release(); + + return true; +} + + +document::size_type document::size() const +{ + using namespace std; + return distance(begin(), end()); +} + + +node::iterator document::begin() +{ + return node::iterator(pimpl_->doc_->children); +} + + +node::const_iterator document::begin() const +{ + return node::const_iterator(pimpl_->doc_->children); +} + + +node::iterator document::end() +{ + return node::iterator(0); +} + + +node::const_iterator document::end() const +{ + return node::const_iterator(0); +} + + +void document::push_back(const node& child) +{ + if (child.get_type() == node::type_element) + throw xml::exception("xml::document::push_back can't take element type nodes"); + + impl::node_insert + ( + reinterpret_cast<xmlNodePtr>(pimpl_->doc_), + 0, + static_cast<xmlNodePtr>(const_cast<node&>(child).get_node_data()) + ); +} + + +node::iterator document::insert(const node& n) +{ + if (n.get_type() == node::type_element) + throw xml::exception("xml::document::insert can't take element type nodes"); + + return node::iterator(xml::impl::node_insert(reinterpret_cast<xmlNodePtr>(pimpl_->doc_), 0, static_cast<xmlNodePtr>(const_cast<node&>(n).get_node_data()))); +} + + +node::iterator document::insert(node::iterator position, const node& n) +{ + if (n.get_type() == node::type_element) + throw xml::exception("xml::document::insert can't take element type nodes"); + + return node::iterator(xml::impl::node_insert(reinterpret_cast<xmlNodePtr>(pimpl_->doc_), static_cast<xmlNodePtr>(position.get_raw_node()), static_cast<xmlNodePtr>(const_cast<node&>(n).get_node_data()))); +} + + +node::iterator document::replace(node::iterator old_node, const node& new_node) +{ + if (old_node->get_type() == node::type_element || new_node.get_type() == node::type_element) + { + throw xml::exception("xml::document::replace can't replace element type nodes"); + } + + return node::iterator(xml::impl::node_replace(static_cast<xmlNodePtr>(old_node.get_raw_node()), static_cast<xmlNodePtr>(const_cast<node&>(new_node).get_node_data()))); +} + + +node::iterator document::erase(node::iterator to_erase) +{ + if (to_erase->get_type() == node::type_element) + throw xml::exception("xml::document::erase can't erase element type nodes"); + return node::iterator(xml::impl::node_erase(static_cast<xmlNodePtr>(to_erase.get_raw_node()))); +} + + +node::iterator document::erase(node::iterator first, node::iterator last) +{ + while (first != last) + first = erase(first); + return first; +} + + +void document::save_to_string(std::string& s) const +{ + xmlChar *xml_string; + int xml_string_length; + + if (pimpl_->xslt_result_ != 0) + { + pimpl_->xslt_result_->save_to_string(s); + return; + } + + const char *enc = pimpl_->encoding_.empty() ? 0 : pimpl_->encoding_.c_str(); + xmlDocDumpFormatMemoryEnc(pimpl_->doc_, &xml_string, &xml_string_length, enc, 1); + + xmlchar_helper helper(xml_string); + if (xml_string_length) + s.assign(helper.get(), xml_string_length); +} + + +bool document::save_to_file(const char *filename, int compression_level) const +{ + std::swap(pimpl_->doc_->compression, compression_level); + + if (pimpl_->xslt_result_ != 0) + { + bool rc = pimpl_->xslt_result_->save_to_file(filename, compression_level); + std::swap(pimpl_->doc_->compression, compression_level); + + return rc; + } + + const char *enc = pimpl_->encoding_.empty() ? 0 : pimpl_->encoding_.c_str(); + bool rc = xmlSaveFormatFileEnc(filename, pimpl_->doc_, enc, 1) > 0; + std::swap(pimpl_->doc_->compression, compression_level); + + return rc; +} + + +void document::set_doc_data(void *data) +{ + // we own the doc now, don't free it! + pimpl_->set_doc_data(static_cast<xmlDocPtr>(data), false); + pimpl_->xslt_result_ = 0; +} + + +void document::set_doc_data_from_xslt(void *data, xslt::impl::result *xr) +{ + // this document came from a XSLT transformation + pimpl_->set_doc_data(static_cast<xmlDocPtr>(data), false); + pimpl_->xslt_result_ = xr; +} + + +void* document::get_doc_data() +{ + return pimpl_->doc_; +} + + +void* document::get_doc_data_read_only() const +{ + return pimpl_->doc_; +} + + +void* document::release_doc_data() +{ + xmlDocPtr xmldoc = pimpl_->doc_; + pimpl_->doc_ = 0; + + return xmldoc; +} + + +std::ostream& operator<<(std::ostream& stream, const document& doc) +{ + std::string xmldata; + doc.save_to_string(xmldata); + stream << xmldata; + return stream; +} + +} // namespace xml Deleted: trunk/src/libxml/document.cxx =================================================================== --- trunk/src/libxml/document.cxx 2012-03-19 19:25:15 UTC (rev 194) +++ trunk/src/libxml/document.cxx 2012-03-19 23:02:47 UTC (rev 195) @@ -1,513 +0,0 @@ -/* - * Copyright (C) 2001-2003 Peter J Jones (pj...@pm...) - * All Rights Reserved - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name of the Author nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR - * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -// xmlwrapp includes -#include "xmlwrapp/document.h" -#include "xmlwrapp/node.h" -#include "xmlwrapp/exception.h" - -#include "utility.h" -#include "dtd_impl.h" -#include "node_manip.h" - -// standard includes -#include <new> -#include <memory> -#include <iterator> -#include <iostream> -#include <algorithm> -#include <stdexcept> - -// libxml includes -#include <libxml/tree.h> -#include <libxml/xinclude.h> - -// bring in private libxslt stuff (see bug #1927398) -#include "../libxslt/result.h" - -namespace xml -{ - -using namespace impl; - -namespace -{ - const char DEFAULT_ENCODING[] = "ISO-8859-1"; -} - -// ------------------------------------------------------------------------ -// xml::impl::doc_impl -// ------------------------------------------------------------------------ - -namespace impl -{ - -struct doc_impl -{ - doc_impl() - : doc_(0), xslt_result_(0) - { - xmlDocPtr tmpdoc; - if ( (tmpdoc = xmlNewDoc(0)) == 0) - throw std::bad_alloc(); - set_doc_data(tmpdoc, true); - } - - - doc_impl(const char *root_name) - : doc_(0), xslt_result_(0), root_(root_name) - { - xmlDocPtr tmpdoc; - if ( (tmpdoc = xmlNewDoc(0)) == 0) - throw std::bad_alloc(); - set_doc_data(tmpdoc, true); - } - - - doc_impl(const doc_impl& other) - : doc_(0), xslt_result_(0) - { - xmlDocPtr tmpdoc; - if ( (tmpdoc = xmlCopyDoc(other.doc_, 1)) == 0) - throw std::bad_alloc(); - set_doc_data(tmpdoc, false); - } - - - void set_doc_data(xmlDocPtr newdoc, bool root_is_okay) - { - if (doc_) - xmlFreeDoc(doc_); - doc_ = newdoc; - - if (doc_->version) - version_ = reinterpret_cast<const char*>(doc_->version); - if (doc_->encoding) - encoding_ = reinterpret_cast<const char*>(doc_->encoding); - - if (root_is_okay) - { - xmlDocSetRootElement(doc_, static_cast<xmlNodePtr>(root_.release_node_data())); - } - else - { - xmlNodePtr libxml_root_node = xmlDocGetRootElement(doc_); - - if (libxml_root_node) - { - root_.set_node_data(libxml_root_node); - } - else - { - node tmpnode; - root_.swap(tmpnode); - - xmlDocSetRootElement(doc_, static_cast<xmlNodePtr>(root_.release_node_data())); - } - } - } - - - void set_root_node(const node& n) - { - node &non_const_node = const_cast<node&>(n); - xmlNodePtr new_root_node = xmlCopyNode(static_cast<xmlNodePtr>(non_const_node.get_node_data()), 1); - if (!new_root_node) - throw std::bad_alloc(); - - xmlNodePtr old_root_node = xmlDocSetRootElement(doc_, new_root_node); - root_.set_node_data(new_root_node); - if (old_root_node) - xmlFreeNode(old_root_node); - - xslt_result_ = 0; - } - - - ~doc_impl() - { - if (doc_) - xmlFreeDoc(doc_); - delete xslt_result_; - } - - xmlDocPtr doc_; - xslt::impl::result *xslt_result_; - node root_; - std::string version_; - mutable std::string encoding_; -}; - -} // namespace impl - - -// ------------------------------------------------------------------------ -// xml::document -// ------------------------------------------------------------------------ - -document::document() -{ - pimpl_ = new doc_impl; -} - - -document::document(const char *root_name) -{ - pimpl_ = new doc_impl(root_name); -} - - -document::document(const node& n) -{ - std::auto_ptr<doc_impl> ap(pimpl_ = new doc_impl); - pimpl_->set_root_node(n); - ap.release(); -} - - -document::document(const document& other) -{ - pimpl_ = new doc_impl(*(other.pimpl_)); -} - - -document& document::operator=(const document& other) -{ - document tmp(other); - swap(tmp); - return *this; -} - - -void document::swap(document& other) -{ - std::swap(pimpl_, other.pimpl_); -} - - -document::~document() -{ - delete pimpl_; -} - - -const node& document::get_root_node() const -{ - return pimpl_->root_; -} - - -node& document::get_root_node() -{ - return pimpl_->root_; -} - - -void document::set_root_node(const node& n) -{ - pimpl_->set_root_node(n); -} - - -const std::string& document::get_version() const -{ - return pimpl_->version_; -} - - -void document::set_version(const char *version) -{ - const xmlChar *old_version = pimpl_->doc_->version; - if ( (pimpl_->doc_->version = xmlStrdup(reinterpret_cast<const xmlChar*>(version))) == 0) - throw std::bad_alloc(); - - pimpl_->version_ = version; - if (old_version) - xmlFree(const_cast<char*>(reinterpret_cast<const char*>(old_version))); -} - - -const std::string& document::get_encoding() const -{ - if (pimpl_->encoding_.empty()) - pimpl_->encoding_ = DEFAULT_ENCODING; - return pimpl_->encoding_; -} - - -void document::set_encoding(const char *encoding) -{ - pimpl_->encoding_ = encoding; - - if (pimpl_->doc_->encoding) - xmlFree(const_cast<xmlChar*>(pimpl_->doc_->encoding)); - - pimpl_->doc_->encoding = xmlStrdup(reinterpret_cast<const xmlChar*>(encoding)); - - if (!pimpl_->doc_->encoding) - throw std::bad_alloc(); -} - - -bool document::get_is_standalone() const -{ - return pimpl_->doc_->standalone == 1; -} - - -void document::set_is_standalone(bool sa) -{ - pimpl_->doc_->standalone = sa ? 1 : 0; -} - - -bool document::process_xinclude() -{ - // xmlXIncludeProcess does not return what is says it does - return xmlXIncludeProcess(pimpl_->doc_) >= 0; -} - - -bool document::has_internal_subset() const -{ - return pimpl_->doc_->intSubset != 0; -} - - -bool document::has_external_subset() const -{ - return pimpl_->doc_->extSubset != 0; -} - - -bool document::validate() -{ - dtd_impl dtd; - return dtd.validate(pimpl_->doc_); -} - - -bool document::validate(const char *dtdname) -{ - dtd_impl dtd(dtdname); - - if (!dtd.error_.empty()) - return false; - if (!dtd.validate(pimpl_->doc_)) - return false; - - // remove the old DTD - if (pimpl_->doc_->extSubset != 0) - xmlFreeDtd(pimpl_->doc_->extSubset); - - pimpl_->doc_->extSubset = dtd.release(); - - return true; -} - - -document::size_type document::size() const -{ - using namespace std; - return distance(begin(), end()); -} - - -node::iterator document::begin() -{ - return node::iterator(pimpl_->doc_->children); -} - - -node::const_iterator document::begin() const -{ - return node::const_iterator(pimpl_->doc_->children); -} - - -node::iterator document::end() -{ - return node::iterator(0); -} - - -node::const_iterator document::end() const -{ - return node::const_iterator(0); -} - - -void document::push_back(const node& child) -{ - if (child.get_type() == node::type_element) - throw xml::exception("xml::document::push_back can't take element type nodes"); - - impl::node_insert - ( - reinterpret_cast<xmlNodePtr>(pimpl_->doc_), - 0, - static_cast<xmlNodePtr>(const_cast<node&>(child).get_node_data()) - ); -} - - -node::iterator document::insert(const node& n) -{ - if (n.get_type() == node::type_element) - throw xml::exception("xml::document::insert can't take element type nodes"); - - return node::iterator(xml::impl::node_insert(reinterpret_cast<xmlNodePtr>(pimpl_->doc_), 0, static_cast<xmlNodePtr>(const_cast<node&>(n).get_node_data()))); -} - - -node::iterator document::insert(node::iterator position, const node& n) -{ - if (n.get_type() == node::type_element) - throw xml::exception("xml::document::insert can't take element type nodes"); - - return node::iterator(xml::impl::node_insert(reinterpret_cast<xmlNodePtr>(pimpl_->doc_), static_cast<xmlNodePtr>(position.get_raw_node()), static_cast<xmlNodePtr>(const_cast<node&>(n).get_node_data()))); -} - - -node::iterator document::replace(node::iterator old_node, const node& new_node) -{ - if (old_node->get_type() == node::type_element || new_node.get_type() == node::type_element) - { - throw xml::exception("xml::document::replace can't replace element type nodes"); - } - - return node::iterator(xml::impl::node_replace(static_cast<xmlNodePtr>(old_node.get_raw_node()), static_cast<xmlNodePtr>(const_cast<node&>(new_node).get_node_data()))); -} - - -node::iterator document::erase(node::iterator to_erase) -{ - if (to_erase->get_type() == node::type_element) - throw xml::exception("xml::document::erase can't erase element type nodes"); - return node::iterator(xml::impl::node_erase(static_cast<xmlNodePtr>(to_erase.get_raw_node()))); -} - - -n... [truncated message content] |
From: <tbr...@us...> - 2012-03-19 19:25:21
|
Revision: 194 http://xmlwrapp.svn.sourceforge.net/xmlwrapp/?rev=194&view=rev Author: tbrowder2 Date: 2012-03-19 19:25:15 +0000 (Mon, 19 Mar 2012) Log Message: ----------- add another item TODO Modified Paths: -------------- trunk/TODO Modified: trunk/TODO =================================================================== --- trunk/TODO 2012-03-18 21:59:49 UTC (rev 193) +++ trunk/TODO 2012-03-19 19:25:15 UTC (rev 194) @@ -9,6 +9,8 @@ tasks. This is not an official list of tasks that will be completed; instead it's more like a developer scratch pad for recording ideas. +* add UTF-8 string option (via the ICU project) + * complete XPath support * convert to a CMake build system This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tbr...@us...> - 2012-03-18 21:59:55
|
Revision: 193 http://xmlwrapp.svn.sourceforge.net/xmlwrapp/?rev=193&view=rev Author: tbrowder2 Date: 2012-03-18 21:59:49 +0000 (Sun, 18 Mar 2012) Log Message: ----------- add more CMake file and dirs borrowed from BRL-CAD Added Paths: ----------- trunk/include/conf/ trunk/include/conf/CONFIG_TIMESTAMP trunk/include/conf/CONFIG_TIME_DAY trunk/include/conf/CONFIG_TIME_MONTH trunk/include/conf/CONFIG_TIME_YEAR trunk/include/conf/MAJOR trunk/include/conf/MINOR trunk/include/conf/PATCH trunk/misc/ trunk/misc/CMake/ Added: trunk/include/conf/CONFIG_TIMESTAMP =================================================================== --- trunk/include/conf/CONFIG_TIMESTAMP (rev 0) +++ trunk/include/conf/CONFIG_TIMESTAMP 2012-03-18 21:59:49 UTC (rev 193) @@ -0,0 +1 @@ +Sun, 18 Mar 2012 16:46:55 -0500 \ No newline at end of file Added: trunk/include/conf/CONFIG_TIME_DAY =================================================================== --- trunk/include/conf/CONFIG_TIME_DAY (rev 0) +++ trunk/include/conf/CONFIG_TIME_DAY 2012-03-18 21:59:49 UTC (rev 193) @@ -0,0 +1 @@ +18 \ No newline at end of file Added: trunk/include/conf/CONFIG_TIME_MONTH =================================================================== --- trunk/include/conf/CONFIG_TIME_MONTH (rev 0) +++ trunk/include/conf/CONFIG_TIME_MONTH 2012-03-18 21:59:49 UTC (rev 193) @@ -0,0 +1 @@ +03 \ No newline at end of file Added: trunk/include/conf/CONFIG_TIME_YEAR =================================================================== --- trunk/include/conf/CONFIG_TIME_YEAR (rev 0) +++ trunk/include/conf/CONFIG_TIME_YEAR 2012-03-18 21:59:49 UTC (rev 193) @@ -0,0 +1 @@ +2012 \ No newline at end of file Added: trunk/include/conf/MAJOR =================================================================== --- trunk/include/conf/MAJOR (rev 0) +++ trunk/include/conf/MAJOR 2012-03-18 21:59:49 UTC (rev 193) @@ -0,0 +1 @@ +0 \ No newline at end of file Added: trunk/include/conf/MINOR =================================================================== --- trunk/include/conf/MINOR (rev 0) +++ trunk/include/conf/MINOR 2012-03-18 21:59:49 UTC (rev 193) @@ -0,0 +1 @@ +7 \ No newline at end of file Added: trunk/include/conf/PATCH =================================================================== --- trunk/include/conf/PATCH (rev 0) +++ trunk/include/conf/PATCH 2012-03-18 21:59:49 UTC (rev 193) @@ -0,0 +1 @@ +0 \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tbr...@us...> - 2012-03-18 21:56:39
|
Revision: 192 http://xmlwrapp.svn.sourceforge.net/xmlwrapp/?rev=192&view=rev Author: tbrowder2 Date: 2012-03-18 21:56:31 +0000 (Sun, 18 Mar 2012) Log Message: ----------- add top-level starting CMake file borrowed from BRL-CAD project Added Paths: ----------- trunk/CMakeLists.txt Added: trunk/CMakeLists.txt =================================================================== --- trunk/CMakeLists.txt (rev 0) +++ trunk/CMakeLists.txt 2012-03-18 21:56:31 UTC (rev 192) @@ -0,0 +1,2120 @@ +# C M A K E L I S T S . T X T +# +# This file is based on a modified version of the one used +# by the BRL-CAD project (http://brlcad.org). +# +# This file defines the toplevel CMake build logic for xmlwrapp. +# As best as is reasonably possible, proper ordering and +# separation of tests and settings should be maintained per the +# recommended standard layout. The tests should be added to the +# labeled sections below so that they are organized as follows: +# +# 0) information on the package and toplevel CMake settings +# 1) define top level options +# 2) check programs +# 3) check compiler characteristics +# 4) check libraries +# 5) check headers +# 6) check types/structures +# 7) check functions +# 8) check system services +# 9) output a summary +# +# The output summary should report key information about the final +# configuration of the build. Comprehensive information is available +# in the CMake cache file in the build directory, so just hit the +# high points in the summary. + + +# ******************************************************************* +# *** Top Level Settings *** +# ******************************************************************* +# This file contains the top level CMakeLists.txt logic for the +# xmlwrapp software package. + +# We want to support a "distclean" build target that will clear all +# CMake-generated files from a source directory in the case of an +# in-source-dir configuration. Not recommended, but we'll try to +# recover if it happens. +define_property(GLOBAL PROPERTY CMAKE_DISTCLEAN_FILES_LIST BRIEF_DOCS "All CMake generated files" FULL_DOCS "List of all files generated by CMake") + +macro(DISTCLEAN) + foreach(item ${ARGN}) + get_property(CMAKE_DISTCLEAN_TARGET_LIST GLOBAL PROPERTY CMAKE_DISTCLEAN_TARGET_LIST) + set_property(GLOBAL APPEND PROPERTY CMAKE_DISTCLEAN_TARGET_LIST ${item}) + endforeach(item ${ARGN}) +endmacro(DISTCLEAN) + +# First step - stash the initial CMakeCache.txt file, if it exists, for subsequent +# comparison +if(EXISTS ${CMAKE_BINARY_DIR}/CMakeCache.txt) + configure_file(${CMAKE_BINARY_DIR}/CMakeCache.txt ${CMAKE_BINARY_DIR}/CMakeCache.txt.prev COPY_ONLY) + DISTCLEAN(${CMAKE_BINARY_DIR}/CMakeCache.txt.prev) +endif(EXISTS ${CMAKE_BINARY_DIR}/CMakeCache.txt) +DISTCLEAN(${CMAKE_BINARY_DIR}/CMakeCache.txt) + +# Minimum required version of CMake +cmake_minimum_required(VERSION 2.8.4) +if(COMMAND CMAKE_POLICY) + CMAKE_POLICY(SET CMP0003 NEW) + CMAKE_POLICY(SET CMP0007 OLD) + if(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION} VERSION_GREATER 2.8.3) + CMAKE_POLICY(SET CMP0017 OLD) + endif(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION} VERSION_GREATER 2.8.3) +endif(COMMAND CMAKE_POLICY) + +# set CMake project name +project(XMLWRAPP) + +set(XMLWRAPP "XMLWRAPP") + +#--------------------------------------------------------------------- +# Write out entries to populate a tm struct to be used for time deltas +# later +if(NOT IS_SUBBUILD) + set(DELTA_START "${CMAKE_BINARY_DIR}/CMakeTmp/DELTA_START") + configure_file(${CMAKE_SOURCE_DIR}/misc/CMake/test_srcs/timedelta_start.c.in ${CMAKE_BINARY_DIR}/CMakeTmp/timedelta_start.c) + TRY_RUN(TIME_RESULT TIME_COMPILED + ${CMAKE_BINARY_DIR}/CMakeTmp + ${CMAKE_BINARY_DIR}/CMakeTmp/timedelta_start.c + OUTPUT_VARIABLE COMPILEMESSAGES) +endif(NOT IS_SUBBUILD) + + +#--------------------------------------------------------------------- +# If it exists, load an XMLWRAPP.GLOBAL file. This allows +# advanced users to specify options or preferences they want to always +# use by default even when doing clean BRL-CAD builds without a +# CMakeCache.txt file - for example, to always enable all local libs +# the following line can be added to XMLWRAPP_CONFIG.GLOBAL: +# +# set(XMLWRAPP_BUNDLED_LIBS "Bundled" CACHE STRING "Enable all local libs") + +# The user's configuration file can be defined by environment variable +# "XMLWRAPP_USER_GLOBAL_CONFIG_FILE" or, in its absence, by a file named +# "XMLWRAPP_CONFIG.GLOBAL" located either above or in the XMLWRAPP +# source directory. +set(XMLWRAPP_USER_GLOBAL_CONFIG_FILE "$ENV{XMLWRAPP_USER_GLOBAL_CONFIG_FILE}") +if(XMLWRAPP_USER_GLOBAL_CONFIG_FILE AND EXISTS ${XMLWRAPP_USER_GLOBAL_CONFIG_FILE}) + message("Reading user preference file '${XMLWRAPP_USER_GLOBAL_CONFIG_FILE}'") + include(${XMLWRAPP_USER_GLOBAL_CONFIG_FILE}) +elseif(EXISTS ${XMLWRAPP_SOURCE_DIR}/../XMLWRAPP_CONFIG.GLOBAL) + message("Reading user preference file '${XMLWRAPP_SOURCE_DIR}/../XMLWRAPP_CONFIG.GLOBAL'") + include(${XMLWRAPP_SOURCE_DIR}/../XMLWRAPP_CONFIG.GLOBAL) +elseif(EXISTS ${XMLWRAPP_SOURCE_DIR}/XMLWRAPP_CONFIG.GLOBAL) + message("Reading user preference file '${XMLWRAPP_SOURCE_DIR}/XMLWRAPP_CONFIG.GLOBAL'") + include(${XMLWRAPP_SOURCE_DIR}/XMLWRAPP_CONFIG.GLOBAL) +else(XMLWRAPP_USER_GLOBAL_CONFIG_FILE AND EXISTS ${XMLWRAPP_USER_GLOBAL_CONFIG_FILE}) + if(XMLWRAPP_USER_GLOBAL_CONFIG_FILE) + message(WARNING "User preference file ${XMLWRAPP_USER_GLOBAL_CONFIG_FILE} specified but not found...") + endif(XMLWRAPP_USER_GLOBAL_CONFIG_FILE) +endif(XMLWRAPP_USER_GLOBAL_CONFIG_FILE AND EXISTS ${XMLWRAPP_USER_GLOBAL_CONFIG_FILE}) + +# Allow the XMLWRAPP_ROOT environment variable to set CMAKE_INSTALL_PREFIX +# but be noisy about it. This is generally not a good idea. +find_program(SLEEP_EXEC sleep) +mark_as_advanced(SLEEP_EXEC) +set(XMLWRAPP_ROOT "$ENV{XMLWRAPP_ROOT}") +if(XMLWRAPP_ROOT) + if(NOT XMLWRAPP_ROOT_OVERRIDE) + message(WARNING "}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}\nXMLWRAPP_ROOT should only be used to override an install directory at runtime. XMLWRAPP_ROOT is presently set to \"${XMLWRAPP_ROOT}\" It is *highly* recommended that XMLWRAPP_ROOT be unset and not used.\n}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}") + if(CMAKE_INSTALL_PREFIX AND NOT CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT ) + if(${XMLWRAPP_ROOT} STREQUAL "${CMAKE_INSTALL_PREFIX}") + message("XMLWRAPP_ROOT is not necessary and may cause unexpected behavior") + else(${XMLWRAPP_ROOT} STREQUAL "${CMAKE_INSTALL_PREFIX}") + message(FATAL_ERROR "XMLWRAPP_ROOT environment variable conflicts with CMAKE_INSTALL_PREFIX") + endif(${XMLWRAPP_ROOT} STREQUAL "${CMAKE_INSTALL_PREFIX}") + endif(CMAKE_INSTALL_PREFIX AND NOT CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT ) + if(SLEEP_EXEC) + execute_process(COMMAND ${SLEEP_EXEC} 2) + endif(SLEEP_EXEC) + endif(NOT XMLWRAPP_ROOT_OVERRIDE) +endif(XMLWRAPP_ROOT) +if(NOT XMLWRAPP_ROOT_OVERRIDE) + if(XMLWRAPP_ROOT STREQUAL "/usr" OR ${CMAKE_INSTALL_PREFIX} STREQUAL "/usr") + message(WARNING "}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}\nIt is STRONGLY recommended that you DO NOT install XMLWRAPP into /usr as XMLWRAPP provides several libraries that may conflict with other libraries (e.g. librt, libbu, libbn) on certain system configurations.\nSince our libraries predate all those that we're known to conflict with and are at the very core of our geometry services and project heritage, we have no plans to change the names of our libraries at this time.\nINSTALLING INTO /usr CAN MAKE A SYSTEM COMPLETELY UNUSABLE. If you choose to continue installing into /usr, you do so entirely at your own risk. You have been warned.\n}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}") + if(SLEEP_EXEC) + message("Pausing 15 seconds...") + execute_process(COMMAND ${SLEEP_EXEC} 15) + endif(SLEEP_EXEC) + if(${CMAKE_INSTALL_PREFIX} STREQUAL "/usr") + message(FATAL_ERROR "If you wish to proceed using /usr as your prefix, define XMLWRAPP_ROOT_OVERRIDE=1 for CMake") + endif(${CMAKE_INSTALL_PREFIX} STREQUAL "/usr") + endif(XMLWRAPP_ROOT STREQUAL "/usr" OR ${CMAKE_INSTALL_PREFIX} STREQUAL "/usr") +endif(NOT XMLWRAPP_ROOT_OVERRIDE) + +# While we're at it, complain if XMLWRAPP_DATA is set +set(XMLWRAPP_DATA_ENV "$ENV{XMLWRAPP_DATA}") +if(XMLWRAPP_DATA_ENV) + message(WARNING "}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}\nXMLWRAPP_DATA should only be used to override an install directory at runtime. XMLWRAPP_DATA is presently set to \"${XMLWRAPP_DATA_ENV}\" It is *highly* recommended that XMLWRAPP_DATA be unset and not used.\n}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}") + if(SLEEP_EXEC) + execute_process(COMMAND ${SLEEP_EXEC} 2) + endif(SLEEP_EXEC) +endif(XMLWRAPP_DATA_ENV) + +# Searching the system for packages presents something of a dilemma - +# in most situations it is Very Bad for a XMLWRAPP build to be using +# older versions of libraries in install directories as search results. +# Generally, the desired behavior is to ignore whatever libraries are +# in the install directories, and only use external library results if +# they are something already found on the system due to non-XMLWRAPP +# installation (source compile, package managers, etc.). Unfortunately, +# CMake's standard behavior is to add a CMAKE_INSTALL_PREFIX to the +# search path once defined, resulting in (for us) an unexpected behavior +# of returning old installed libraries when CMake is re-run in a +# directory. +# +# To work around this, there are two possible approaches. One, +# identified by Maik Beckmann, operates on CMAKE_SYSTEM_PREFIX_PATH: +# +# http://www.cmake.org/pipermail/cmake/2010-October/040292.html +# +# The other, pointed out by Michael Hertling, uses the +# CMake_[SYSTEM_]IGNORE_PATH variables. +# +# http://www.cmake.org/pipermail/cmake/2011-May/044503.html +# +# XMLWRAPP initially operated on CMAKE_SYSTEM_PREFIX_PATH, but has +# switched to using the *_IGNORE_PATH variables. This requires +# CMake 2.8.3 or later. +# +# The complication with ignoring install paths is if we are +# installing to a "legitimate" system search path - i.e. our +# CMAKE_INSTALL_PREFIX value is standard enough that it is a legitimate +# search target for find_package. In this case, we can't exclude +# accidental hits on our libraries without also excluding legitimate +# find_package results. So the net results are: +# +# 1. If you are planning to install to a system directory (typically +# a bad idea but the settings are legal) clean out the old system +# first or accept that the old libraries will be found and used. +# +# 2. For more custom paths, the logic below will avoid the value +# of CMAKE_INSTALL_PREFIX in find_package searches +# +# (Note: CMAKE_INSTALL_PREFIX must be checked in the case where someone +# sets it on the command line prior to CMake being run. XMLWRAPP_PREFIX +# preserves the CMAKE_INSTALL_PREFIX setting from the previous CMake run. +# CMAKE_INSTALL_PREFIX does not seem to be immediately set in this context +# when CMake is re-run unless specified explicitly on the command line. +# To ensure the previous (and internally set) CMAKE_INSTALL_PREFIX value +# is available, XMLWRAPP_PREFIX is used to store the value in the cache.) + +if(CMAKE_INSTALL_PREFIX) + if(NOT ${CMAKE_INSTALL_PREFIX} STREQUAL "/usr" AND NOT ${CMAKE_INSTALL_PREFIX} STREQUAL "/usr/local") + get_filename_component(PATH_NORMALIZED ${CMAKE_INSTALL_PREFIX}/lib ABSOLUTE) + set(CMAKE_SYSTEM_IGNORE_PATH ${PATH_NORMALIZED}) + endif(NOT ${CMAKE_INSTALL_PREFIX} STREQUAL "/usr" AND NOT ${CMAKE_INSTALL_PREFIX} STREQUAL "/usr/local") +endif(CMAKE_INSTALL_PREFIX) +if(XMLWRAPP_PREFIX) + if(NOT ${XMLWRAPP_PREFIX} STREQUAL "/usr" AND NOT ${XMLWRAPP_PREFIX} STREQUAL "/usr/local") + get_filename_component(PATH_NORMALIZED ${XMLWRAPP_PREFIX}/lib ABSOLUTE) + set(CMAKE_SYSTEM_IGNORE_PATH ${PATH_NORMALIZED}) + endif(NOT ${XMLWRAPP_PREFIX} STREQUAL "/usr" AND NOT ${XMLWRAPP_PREFIX} STREQUAL "/usr/local") +endif(XMLWRAPP_PREFIX) +mark_as_advanced(CMAKE_SYSTEM_IGNORE_PATH) + +# Define CMake routines for bookkeeping of build files +include(${CMAKE_SOURCE_DIR}/misc/CMake/CMakeFiles.cmake) + +#--------------------------------------------------------------------- +# Define the current XMLWRAPP version. +# See HACKING for details on how to properly update the version + +file(READ ${XMLWRAPP_SOURCE_DIR}/include/conf/MAJOR XMLWRAPP_MAJOR_VERSION) +string(STRIP ${XMLWRAPP_MAJOR_VERSION} XMLWRAPP_MAJOR_VERSION) +file(READ ${XMLWRAPP_SOURCE_DIR}/include/conf/MINOR XMLWRAPP_MINOR_VERSION) +string(STRIP ${XMLWRAPP_MINOR_VERSION} XMLWRAPP_MINOR_VERSION) +file(READ ${XMLWRAPP_SOURCE_DIR}/include/conf/PATCH XMLWRAPP_PATCH_VERSION) +string(STRIP ${XMLWRAPP_PATCH_VERSION} XMLWRAPP_PATCH_VERSION) + +set(XMLWRAPP_VERSION "${XMLWRAPP_MAJOR_VERSION}.${XMLWRAPP_MINOR_VERSION}.${XMLWRAPP_PATCH_VERSION}") + +#--------------------------------------------------------------------- +# Define relative install locations. Don't set these if they have already +# been set by some other means (like a higher level CMakeLists.txt file +# including this one.) + +# The location in which to install XMLWRAPP executables. +if(NOT BIN_DIR) + set(BIN_DIR bin) +endif(NOT BIN_DIR) + +# The location in which to install XMLWRAPP header files. +if(NOT INCLUDE_DIR) + set(INCLUDE_DIR include) +endif(NOT INCLUDE_DIR) + +# The location in which to install XMLWRAPP libraries. +if(NOT LIB_DIR) + set(LIB_DIR lib) +endif(NOT LIB_DIR) + +# The location in which to install XMLWRAPP configuration files. +if(NOT CONF_DIR) + set(CONF_DIR etc) +endif(NOT CONF_DIR) + +# The location in which to install CMake scripts for packaging XMLWRAPP. +if(NOT PACKAGE_DIR) + set(PACKAGE_DIR lib) +endif(NOT PACKAGE_DIR) + +# The location in which to install XMLWRAPP data files +if(NOT DATA_DIR) + set(DATA_DIR share/xmlwrapp/${XMLWRAPP_VERSION}) +endif(NOT DATA_DIR) + +# The location in which to install XMLWRAPP Manual pages +if(NOT MAN_DIR) + set(MAN_DIR ${DATA_DIR}/man) +endif(NOT MAN_DIR) + +# The location in which to install XMLWRAPP documentation files +if(NOT DOC_DIR) + set(DOC_DIR ${DATA_DIR}/doc) +endif(NOT DOC_DIR) + + + +#--------------------------------------------------------------------- +# By default (as of version 2.8.2) CMake does not provide access to +# global lists of executable and library targets. This is useful +# in a number of situations related to formulating custom rules and +# target dependency management. To avoid the necessity of replacing +# add_library and add_executable calls with custom macros, override +# the function names and call the _add_* functions to access the CMake +# functionality previously available under the add_* functions. See +# http://www.cmake.org/pipermail/cmake/2010-September/039388.html + +# To allow a hypothetical parent build to disable this mechanism and +# replace it, we wrap the whole show in an IF conditional. To avoid +# the distcheck setup, the parent file should define the variable +# IS_SUBBUILD to ON. Note that this also disables the +# liblib prefix check in add_library, making that the responsibility +# of the parent build as well, and disables the mechanism for ensuring +# that the timing code runs at the correct points during the build. + +# We also need to provide bookkeeping logic here for the distribution +# verification or "distcheck" routines that will validate the state +# of the source tree against that expected and accounted for in the +# build files. The global coverage needed for the purpose results in +# the add_library/add_executable command override mechanism having +# to serve two purposes at once; since we only override these functions +# once the logic for both jobs is intertwined below. + +if(NOT IS_SUBBUILD) + # Functions in CMake have local variable scope, + # hence the use of properties to allow access to directory-specific + # and global information scopes. + define_property(GLOBAL PROPERTY CMAKE_LIBRARY_TARGET_LIST BRIEF_DOCS "libtarget list" FULL_DOCS "Library target list") + define_property(GLOBAL PROPERTY CMAKE_EXEC_TARGET_LIST BRIEF_DOCS "exec target list" FULL_DOCS "Executable target list") + define_property(GLOBAL PROPERTY CMAKE_CUSTOM_TARGET_LIST BRIEF_DOCS "custom target list" FULL_DOCS "Custom target list") + define_property(GLOBAL PROPERTY CMAKE_EXTERNAL_TARGET_LIST BRIEF_DOCS "external target list" FULL_DOCS "External target list") + mark_as_advanced(CMAKE_LIBRARY_TARGET_LIST) + mark_as_advanced(CMAKE_EXEC_TARGET_LIST) + mark_as_advanced(CMAKE_CUSTOM_TARGET_LIST) + mark_as_advanced(CMAKE_EXTERNAL_TARGET_LIST) + + # Need build_files_list to be clear each CMake run + file(WRITE ${CMAKE_BINARY_DIR}/build_files_list.txt "") + + # Override and wrap add_library. While we're at it, avoid doubling up + # on the lib prefix for libraries if the target name is lib<target> + function(add_library name) + get_property(CMAKE_LIBRARY_TARGET_LIST GLOBAL PROPERTY CMAKE_LIBRARY_TARGET_LIST) + _add_library(${name} ${ARGN}) + CMAKEFILES(${ARGN}) + if(${name} MATCHES "^lib*") + set_target_properties(${name} PROPERTIES PREFIX "") + endif(${name} MATCHES "^lib*") + set_property(GLOBAL APPEND PROPERTY CMAKE_LIBRARY_TARGET_LIST ${name}) + endfunction(add_library) + + # Override and wrap add_executable + function(add_executable name) + get_property(CMAKE_EXEC_TARGET_LIST GLOBAL PROPERTY CMAKE_EXEC_TARGET_LIST) + _add_executable(${name} ${ARGN}) + CMAKEFILES(${ARGN}) + set_property(GLOBAL APPEND PROPERTY CMAKE_EXEC_TARGET_LIST ${name}) + endfunction(add_executable) + + # Override and wrap add_custom_target + function(add_custom_target name) + get_property(CMAKE_CUSTOM_TARGET_LIST GLOBAL PROPERTY CMAKE_CUSTOM_TARGET_LIST) + _add_custom_target(${name} ${ARGN}) + set_property(GLOBAL APPEND PROPERTY CMAKE_CUSTOM_TARGET_LIST ${name}) + endfunction(add_custom_target) + + # Note that at the moment we do not need to override CMake's external + # project mechanisms because CMake does not use them, but if that changes + # in the future an override will need to be added here - probably of the + # ExternalProject_Add functionality. + + # Override and wrap configure_file. In the case of a configure_file, we'll + # check that the file is part of the source tree and not itself a + # generated file, but not reject full-path entries since there are quite a + # few of them. + function(configure_file file targetfile) + _configure_file(${file} ${targetfile} ${ARGN}) + GET_FILENAME_COMPONENT(ITEM_ABS ${file} ABSOLUTE) + set(TEST_BUILD_PATH "${CMAKE_BINARY_DIR}/") + set(TEST_SOURCE_PATH "${CMAKE_SOURCE_DIR}/") + string(REGEX REPLACE "^${TEST_BUILD_PATH}" "" BUILD_DIR_TRIMMED "${ITEM_ABS}") + if(${ITEM_ABS} STREQUAL ${BUILD_DIR_TRIMMED}) + string(REGEX REPLACE "^${TEST_SOURCE_PATH}" "" SOURCE_DIR_TRIMMED "${ITEM_ABS}") + if(NOT ${ITEM_ABS} STREQUAL ${SOURCE_DIR_TRIMMED}) + file(APPEND ${CMAKE_BINARY_DIR}/cmakefiles.cmake "${ITEM_ABS}\n") + endif(NOT ${ITEM_ABS} STREQUAL ${SOURCE_DIR_TRIMMED}) + endif(${ITEM_ABS} STREQUAL ${BUILD_DIR_TRIMMED}) + if(NOT ${targetfile} MATCHES "distclean") + DISTCLEAN(${targetfile}) + endif(NOT ${targetfile} MATCHES "distclean") + endfunction(configure_file) + + # Override and wrap add_subdirctory. + function(add_subdirectory name) + _add_subdirectory(${name} ${ARGN}) + file(APPEND ${CMAKE_BINARY_DIR}/cmakefiles.cmake "${CMAKE_CURRENT_SOURCE_DIR}/${name}\n") + file(APPEND ${CMAKE_BINARY_DIR}/cmakefiles.cmake "${CMAKE_CURRENT_SOURCE_DIR}/${name}/CMakeLists.txt\n") + DISTCLEAN(${CMAKE_CURRENT_BINARY_DIR}/${name}/CMakeFiles) + DISTCLEAN(${CMAKE_CURRENT_BINARY_DIR}/${name}/cmake_install.cmake) + DISTCLEAN(${CMAKE_CURRENT_BINARY_DIR}/${name}/Makefile) + endfunction(add_subdirectory) + +endif(NOT IS_SUBBUILD) + +file(REMOVE ${CMAKE_BINARY_DIR}/cmakefiles.cmake) +file(REMOVE ${CMAKE_BINARY_DIR}/cmakedirs.cmake) + +# We wrap the message function to also append ALL messages to CMakeOutput.log, +# as well as printing them on the console output. +if(NOT IS_SUBBUILD) + function(message) + _message(${ARGN}) + string(REGEX REPLACE ";" ": " msg "${ARGV}") + file(APPEND ${XMLWRAPP_BINARY_DIR}/CMakeFiles/CMakeOutput.log "${msg}\n") + endfunction(message) +endif(NOT IS_SUBBUILD) + +#--------------------------------------------------------------------- +# CMake derives much of its functionality from modules, typically +# stored in one directory - let CMake know where to find them. If we +# are a subbuild, let the parent's CMAKE_MODULE_PATH supply files before +# our own, otherwise misc/CMake takes first priority. +set(XMLWRAPP_CMAKE_DIR "${XMLWRAPP_SOURCE_DIR}/misc/CMake") +if(IS_SUBBUILD) + set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${XMLWRAPP_CMAKE_DIR}") +else(IS_SUBBUILD) + set(CMAKE_MODULE_PATH "${XMLWRAPP_CMAKE_DIR};${CMAKE_MODULE_PATH}") +endif(IS_SUBBUILD) + +# There are collections of macro definitions in misc/CMake that +# don't make sense to load with find_package - define a convenience +# macro to do what we want in such cases. +include(${XMLWRAPP_CMAKE_DIR}/LoadMacros.cmake) + +# Load utility macros that will be used throughout the XMLWRAPP +# build logic +include(${XMLWRAPP_CMAKE_DIR}/XMLWRAPP_Options.cmake) +include(${XMLWRAPP_CMAKE_DIR}/XMLWRAPP_Util.cmake) +include(CheckTypeSize) + +#--------------------------------------------------------------------- +# Save the current LC_ALL, LC_MESSAGES, and LANG environment variables +# and set them to "C" so things like date output are as expected. +set(_orig_lc_all $ENV{LC_ALL}) +set(_orig_lc_messages $ENV{LC_MESSAGES}) +set(_orig_lang $ENV{LANG}) +if(_orig_lc_all) + set(ENV{LC_ALL} C) +endif(_orig_lc_all) +if(_orig_lc_messages) + set(ENV{LC_MESSAGES} C) +endif(_orig_lc_messages) +if(_orig_lang) + set(ENV{LANG} C) +endif(_orig_lang) + +#--------------------------------------------------------------------- +# Unfortunately, CMake doesn't give you variables with current day, +# month, etc. There are several possible approaches to this, but most +# (e.g. the date command) are not cross platform. We build a small C +# file which writes out the needed values to files in the build +# directory. Those files are then read and stripped by CMake. +set(CONFIG_TIME_DAY_FILE "${XMLWRAPP_BINARY_DIR}/include/conf/CONFIG_TIME_DAY") +set(CONFIG_TIME_MONTH_FILE "${XMLWRAPP_BINARY_DIR}/include/conf/CONFIG_TIME_MONTH") +set(CONFIG_TIME_YEAR_FILE "${XMLWRAPP_BINARY_DIR}/include/conf/CONFIG_TIME_YEAR") +set(CONFIG_TIMESTAMP_FILE "${XMLWRAPP_BINARY_DIR}/include/conf/CONFIG_TIMESTAMP") +DISTCLEAN(${CONFIG_TIME_DAY_FILE} ${CONFIG_TIME_MONTH_FILE} + ${CONFIG_TIME_YEAR_FILE} ${CONFIG_TIMESTAMP_FILE}) +file(MAKE_DIRECTORY "${XMLWRAPP_BINARY_DIR}/include") +file(MAKE_DIRECTORY "${XMLWRAPP_BINARY_DIR}/include/conf") +configure_file(${XMLWRAPP_CMAKE_DIR}/test_srcs/time.c.in ${CMAKE_BINARY_DIR}/CMakeTmp/time.c) +TRY_RUN(TIME_RESULT TIME_COMPILED + ${CMAKE_BINARY_DIR}/CMakeTmp + ${CMAKE_BINARY_DIR}/CMakeTmp/time.c + OUTPUT_VARIABLE COMPILEMESSAGES) +if(TIME_RESULT MATCHES "^0$") + file(READ ${CONFIG_TIME_DAY_FILE} CONFIG_DAY) + string(STRIP ${CONFIG_DAY} CONFIG_DAY) + file(READ ${CONFIG_TIME_MONTH_FILE} CONFIG_MONTH) + string(STRIP ${CONFIG_MONTH} CONFIG_MONTH) + file(READ ${CONFIG_TIME_YEAR_FILE} CONFIG_YEAR) + string(STRIP ${CONFIG_YEAR} CONFIG_YEAR) + set(CONFIG_DATE "${CONFIG_YEAR}${CONFIG_MONTH}${CONFIG_DAY}") +else(TIME_RESULT MATCHES "^0$") + message(FATAL_ERROR "Code to determine current date and time failed!\n") +endif(TIME_RESULT MATCHES "^0$") + +#--------------------------------------------------------------------- +# print out the title with a pretty box computed to wrap around +BOX_PRINT("*** Configuring XMLWRAPP Release ${XMLWRAPP_VERSION}, Build ${CONFIG_DATE} ***" "*") + +#--------------------------------------------------------------------- +# We want to check /usr/local by default, so add it +set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} /usr/local) +set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} /usr/local/include) + +#--------------------------------------------------------------------- +# In the case of CMake, we're usually doing one of several Build +# Types. It's very rare to want to NOT specify a build type, so +# make it a little more work to do so. +if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_BUILD_TYPE_MSG) + message("CMake build type not set - performing Debug build.") + message("* To use optimized settings intended for a package or system install,") + message(" specify a Release build (on the command line, -DCMAKE_BUILD_TYPE=Release).") + message("* To force CMake to not set build type, specify -DCMAKE_BUILD_TYPE=NONE") + set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Build Type" FORCE) + set(CMAKE_BUILD_TYPE_MSG TRUE CACHE INTERNAL "Printed build type info message") +endif(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_BUILD_TYPE_MSG) +set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS Debug Release) + +if(CMAKE_BUILD_TYPE MATCHES "NONE") + set(CMAKE_BUILD_TYPE "") +endif(CMAKE_BUILD_TYPE MATCHES "NONE") + +#--------------------------------------------------------------------- +# The location in which to install XMLWRAPP. Only do this if +# CMAKE_INSTALL_PREFIX hasn't been set already, to try and allow +# parent builds (if any) some control. +if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT OR NOT CMAKE_INSTALL_PREFIX) + if(NOT WIN32) + if("${CMAKE_BUILD_TYPE}" MATCHES "Release") + set(CMAKE_INSTALL_PREFIX "/usr/xmlwrapp/rel-${XMLWRAPP_VERSION}") + elseif("${CMAKE_BUILD_TYPE}" MATCHES "Debug") + set(CMAKE_INSTALL_PREFIX "/usr/xmlwrapp/dev-${XMLWRAPP_VERSION}") + else("${CMAKE_BUILD_TYPE}" MATCHES "Release") + set(CMAKE_INSTALL_PREFIX "/usr/xmlwrapp") + endif("${CMAKE_BUILD_TYPE}" MATCHES "Release") + endif(NOT WIN32) + set(CMAKE_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX} CACHE STRING "XMLWRAPP install prefix" FORCE) + set(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT 0) +endif(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT OR NOT CMAKE_INSTALL_PREFIX) +set(XMLWRAPP_PREFIX ${CMAKE_INSTALL_PREFIX} CACHE STRING "XMLWRAPP install prefix") +mark_as_advanced(XMLWRAPP_PREFIX) + +# If we've got a Release build with a Debug path or vice versa, change it - that +# is probably the most "expected" behavior. +if("${CMAKE_BUILD_TYPE}" MATCHES "Release" AND ${CMAKE_INSTALL_PREFIX} STREQUAL "/usr/xmlwrapp/dev-${XMLWRAPP_VERSION}") + set(CMAKE_INSTALL_PREFIX "/usr/xmlwrapp/rel-${XMLWRAPP_VERSION}" CACHE STRING "XMLWRAPP install prefix" FORCE) +endif("${CMAKE_BUILD_TYPE}" MATCHES "Release" AND ${CMAKE_INSTALL_PREFIX} STREQUAL "/usr/xmlwrapp/dev-${XMLWRAPP_VERSION}") +if("${CMAKE_BUILD_TYPE}" MATCHES "Debug" AND ${CMAKE_INSTALL_PREFIX} STREQUAL "/usr/xmlwrapp/rel-${XMLWRAPP_VERSION}") + set(CMAKE_INSTALL_PREFIX "/usr/xmlwrapp/dev-${XMLWRAPP_VERSION}" CACHE STRING "XMLWRAPP install prefix" FORCE) +endif("${CMAKE_BUILD_TYPE}" MATCHES "Debug" AND ${CMAKE_INSTALL_PREFIX} STREQUAL "/usr/xmlwrapp/rel-${XMLWRAPP_VERSION}") + + +#--------------------------------------------------------------------- +# The following logic is what allows binaries to run successfully in +# the build directory AND install directory. Thanks to plplot for +# identifying the necessity of setting CMAKE_INSTALL_NAME_DIR on OSX. +# Documentation of these options is available at +# http://www.cmake.org/Wiki/CMake_RPATH_handling + +# use, i.e. don't skip the full RPATH for the build tree +set(CMAKE_SKIP_BUILD_RPATH FALSE) + +# when building, don't use the install RPATH already +# (but later on when installing) +set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) + +# the RPATH/INSTALL_NAME_DIR to be used when installing +if (NOT APPLE) + set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${LIB_DIR}:\$ORIGIN/../${LIB_DIR}") +endif(NOT APPLE) +# On OSX, we need to set INSTALL_NAME_DIR instead of RPATH +# http://www.cmake.org/cmake/help/cmake-2-8-docs.html#variable:CMAKE_INSTALL_NAME_DIR +set(CMAKE_INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/${LIB_DIR}") + +# add the automatically determined parts of the RPATH which point to +# directories outside the build tree to the install RPATH +set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) + +#--------------------------------------------------------------------- +# Output directories - this is where built library and executable +# files will be placed after building but prior to install. The +# necessary variables change between single and multi configuration +# build systems, so it is necessary to handle both cases on a +# conditional basis. + +if(NOT CMAKE_CONFIGURATION_TYPES) + # If we're not doing multi-configuration, just set the three main + # variables to the correct values. + if(NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY) + set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${XMLWRAPP_BINARY_DIR}/${LIB_DIR} CACHE INTERNAL "Single output directory for building all libraries.") + endif(NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY) + if(NOT CMAKE_ARCHIVE_OUTPUT_DIRECTORY) + set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${XMLWRAPP_BINARY_DIR}/${LIB_DIR} CACHE INTERNAL "Single output directory for building all archives.") + endif(NOT CMAKE_ARCHIVE_OUTPUT_DIRECTORY) + if(NOT CMAKE_RUNTIME_OUTPUT_DIRECTORY) + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${XMLWRAPP_BINARY_DIR}/${BIN_DIR} CACHE INTERNAL "Single output directory for building all executables.") + endif(NOT CMAKE_RUNTIME_OUTPUT_DIRECTORY) +else(NOT CMAKE_CONFIGURATION_TYPES) + # Multi-configuration is more difficult. Not only do we need to + # properly set the output directories, but we also need to + # identify the "toplevel" directory for each configuration so + # we can place files, documentation, etc. in the correct + # relative positions. + foreach(CFG_TYPE ${CMAKE_CONFIGURATION_TYPES}) + string(TOUPPER "${CFG_TYPE}" CFG_TYPE_UPPER) + if(NOT "CMAKE_LIBRARY_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER}") + set("CMAKE_LIBRARY_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER}" ${XMLWRAPP_BINARY_DIR}/${CFG_TYPE}/${LIB_DIR} CACHE INTERNAL "Single output directory for building ${CFG_TYPE} libraries.") + endif(NOT "CMAKE_LIBRARY_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER}") + if(NOT "CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER}") + set("CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER}" ${XMLWRAPP_BINARY_DIR}/${CFG_TYPE}/${LIB_DIR} CACHE INTERNAL "Single output directory for building ${CFG_TYPE} archives.") + endif(NOT "CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER}") + if(NOT "CMAKE_RUNTIME_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER}") + set("CMAKE_RUNTIME_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER}" ${XMLWRAPP_BINARY_DIR}/${CFG_TYPE}/${BIN_DIR} CACHE INTERNAL "Single output directory for building ${CFG_TYPE} executables.") + endif(NOT "CMAKE_RUNTIME_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER}") + if(NOT "CMAKE_BINARY_DIR_${CFG_TYPE_UPPER}") + set("CMAKE_BINARY_DIR_${CFG_TYPE_UPPER}" ${XMLWRAPP_BINARY_DIR}/${CFG_TYPE} CACHE INTERNAL "Toplevel binary dir for ${CFG_TYPE} building.") + endif(NOT "CMAKE_BINARY_DIR_${CFG_TYPE_UPPER}") + if(NOT "XMLWRAPP_BINARY_DIR_${CFG_TYPE_UPPER}") + set("XMLWRAPP_BINARY_DIR_${CFG_TYPE_UPPER}" ${XMLWRAPP_BINARY_DIR}/${CFG_TYPE} CACHE INTERNAL "Toplevel binary dir for ${CFG_TYPE} building.") + endif(NOT "XMLWRAPP_BINARY_DIR_${CFG_TYPE_UPPER}") + endforeach() +endif(NOT CMAKE_CONFIGURATION_TYPES) + +#--------------------------------------------------------------------- +# We will need a xmlwrapp_config.h.in file to hold all the #cmakedefine +# statements, which will in turn be used to generate a xmlwrapp_conf.h +# file. In autotools this process is handled by autoheader - in the +# case of CMake we wrap the CHECK_* functions and the creation of the +# entry in the xmlwrapp_config.h.in file into one step via a macro. To +# run this macro, the config.h.in file must first be present, which +# we take care of here: + +set(CONFIG_H_FILE "${XMLWRAPP_BINARY_DIR}/include/xmlwrapp_config.h.in") +file(WRITE ${CONFIG_H_FILE} "/**** Define statements for CMake ****/\n") +file(APPEND ${CONFIG_H_FILE} "#ifndef __CONFIG_H__\n") +file(APPEND ${CONFIG_H_FILE} "#define __CONFIG_H__\n") + +# If we're building on Windows, start off with the config_win.h file +if(WIN32) + file(APPEND ${CONFIG_H_FILE} "#include \"config_win_cmake.h\"\n") +endif(WIN32) + +# Set up some of the define statements for path information and other basics +file(APPEND ${CONFIG_H_FILE} "#define PACKAGE \"xmlwrapp\"\n") +file(APPEND ${CONFIG_H_FILE} "#define PACKAGE_BUGREPORT \"http://xmlwrapp.org\"\n") +file(APPEND ${CONFIG_H_FILE} "#define PACKAGE_NAME \"XMLWRAPP\"\n") +file(APPEND ${CONFIG_H_FILE} "#define PACKAGE_STRING \"XMLWRAPP ${XMLWRAPP_VERSION}\"\n") +file(APPEND ${CONFIG_H_FILE} "#define PACKAGE_TARNAME \"xmlwrapp\"\n") +file(APPEND ${CONFIG_H_FILE} "#define XMLWRAPP_DATA \"${CMAKE_INSTALL_PREFIX}/${DATA_DIR}\"\n") +file(APPEND ${CONFIG_H_FILE} "#define XMLWRAPP_ROOT \"${CMAKE_INSTALL_PREFIX}\"\n") +file(APPEND ${CONFIG_H_FILE} "#define PACKAGE_VERSION \"${XMLWRAPP_VERSION}\"\n") +file(APPEND ${CONFIG_H_FILE} "#define VERSION \"${XMLWRAPP_VERSION}\"\n") + +# A variety of debugging messages in the code key off of the DEBUG +# definition - unlike the build flags, this is turned on and off based +# on the build type. A "Release" build with debugging compiler flags +# will still not print debugging messages conditionalized on DEBUG. +if("${CMAKE_BUILD_TYPE}" MATCHES "Debug") + file(APPEND ${CONFIG_H_FILE} "#define DEBUG 1\n") +endif("${CMAKE_BUILD_TYPE}" MATCHES "Debug") + +#---------------------------------------------------------------------- +# Decide whether to do a 32 or a 64 bit build. + +set(WORD_SIZE_LABEL "Compile as 32BIT or 64BIT?") +if(NOT XMLWRAPP_WORD_SIZE) + set(XMLWRAPP_WORD_SIZE "AUTO" CACHE STRING WORD_SIZE_LABEL) +endif(NOT XMLWRAPP_WORD_SIZE) +set_property(CACHE XMLWRAPP_WORD_SIZE PROPERTY STRINGS AUTO 32BIT 64BIT) +string(TOUPPER "${XMLWRAPP_WORD_SIZE}" XMLWRAPP_WORD_SIZE_UPPER) +set(XMLWRAPP_WORD_SIZE "${XMLWRAPP_WORD_SIZE_UPPER}" CACHE STRING WORD_SIZE_LABEL FORCE) +if(NOT XMLWRAPP_WORD_SIZE MATCHES "AUTO" AND NOT XMLWRAPP_WORD_SIZE MATCHES "64BIT" AND NOT XMLWRAPP_WORD_SIZE MATCHES "32BIT") + message(WARNING "Unknown value ${XMLWRAPP_WORD_SIZE} supplied for XMLWRAPP_WORD_SIZE - defaulting to AUTO") + message(WARNING "Valid options are AUTO, 32BIT and 64BIT") + set(XMLWRAPP_WORD_SIZE "AUTO" CACHE STRING WORD_SIZE_LABEL FORCE) +endif(NOT XMLWRAPP_WORD_SIZE MATCHES "AUTO" AND NOT XMLWRAPP_WORD_SIZE MATCHES "64BIT" AND NOT XMLWRAPP_WORD_SIZE MATCHES "32BIT") + +# calculate the size of a pointer if we haven't already +CHECK_TYPE_SIZE("void *" CMAKE_SIZEOF_VOID_P) + +# still not defined? +if(NOT CMAKE_SIZEOF_VOID_P) + message(WARNING "CMAKE_SIZEOF_VOID_P is not defined - assuming 32 bit platform") + set(CMAKE_SIZEOF_VOID_P 4) +endif(NOT CMAKE_SIZEOF_VOID_P) + +if(${XMLWRAPP_WORD_SIZE} MATCHES "AUTO") + if(${CMAKE_SIZEOF_VOID_P} MATCHES "^8$") + set(CMAKE_WORD_SIZE "64BIT") + set(XMLWRAPP_WORD_SIZE "64BIT (AUTO)" CACHE STRING WORD_SIZE_LABEL FORCE) + else(${CMAKE_SIZEOF_VOID_P} MATCHES "^8$") + if(${CMAKE_SIZEOF_VOID_P} MATCHES "^4$") + set(CMAKE_WORD_SIZE "32BIT") + set(XMLWRAPP_WORD_SIZE "32BIT (AUTO)" CACHE STRING WORD_SIZE_LABEL FORCE) + else(${CMAKE_SIZEOF_VOID_P} MATCHES "^4$") + if(${CMAKE_SIZEOF_VOID_P} MATCHES "^2$") + set(CMAKE_WORD_SIZE "16BIT") + set(XMLWRAPP_WORD_SIZE "16BIT (AUTO)" CACHE STRING WORD_SIZE_LABEL FORCE) + else(${CMAKE_SIZEOF_VOID_P} MATCHES "^2$") + set(CMAKE_WORD_SIZE "8BIT") + set(XMLWRAPP_WORD_SIZE "8BIT (AUTO)" CACHE STRING WORD_SIZE_LABEL FORCE) + endif(${CMAKE_SIZEOF_VOID_P} MATCHES "^2$") + endif(${CMAKE_SIZEOF_VOID_P} MATCHES "^4$") + endif(${CMAKE_SIZEOF_VOID_P} MATCHES "^8$") +else(${XMLWRAPP_WORD_SIZE} MATCHES "AUTO") + set(CMAKE_WORD_SIZE "${XMLWRAPP_WORD_SIZE}") +endif(${XMLWRAPP_WORD_SIZE} MATCHES "AUTO") +file(APPEND ${CONFIG_H_FILE} "#define SIZEOF_VOID_P ${CMAKE_SIZEOF_VOID_P}\n") + +# Enable/disable 64-bit build settings for MSVC, which is apparently +# determined at the CMake generator level - need to override other +# settings if the compiler disagrees with them. +if(MSVC) + if(CMAKE_CL_64) + if(NOT ${CMAKE_WORD_SIZE} MATCHES "64BIT") + set(CMAKE_WORD_SIZE "64BIT") + if(NOT "${XMLWRAPP_WORD_SIZE}" MATCHES "AUTO") + message(WARNING "Selected MSVC compiler is 64BIT - setting word size to 64BIT. To perform a 32BIT MSVC build, select the 32BIT MSVC CMake generator.") + set(XMLWRAPP_WORD_SIZE "64BIT" CACHE STRING WORD_SIZE_LABEL FORCE) + endif(NOT "${XMLWRAPP_WORD_SIZE}" MATCHES "AUTO") + endif(NOT ${CMAKE_WORD_SIZE} MATCHES "64BIT") + else(CMAKE_CL_64) + if(NOT ${CMAKE_WORD_SIZE} MATCHES "32BIT") + set(CMAKE_WORD_SIZE "32BIT") + if(NOT "${XMLWRAPP_WORD_SIZE}" MATCHES "AUTO") + message(WARNING "Selected MSVC compiler is 32BIT - setting word size to 32BIT. To perform a 64BIT MSVC build, select the 64BIT MSVC CMake generator.") + set(XMLWRAPP_WORD_SIZE "32BIT" CACHE STRING WORD_SIZE_LABEL FORCE) + endif(NOT "${XMLWRAPP_WORD_SIZE}" MATCHES "AUTO") + endif(NOT ${CMAKE_WORD_SIZE} MATCHES "32BIT") + endif(CMAKE_CL_64) +endif(MSVC) + +# Based on what we are doing, we may need to constrain our search paths +if(${CMAKE_WORD_SIZE} MATCHES "32BIT") + set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS OFF) +else(${CMAKE_WORD_SIZE} MATCHES "32BIT") + set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS ON) +endif(${CMAKE_WORD_SIZE} MATCHES "32BIT") + +# One of the problems with 32/64 building is we need to search anew +# for 64 bit libs after a 32 bit configure, or vice versa. +if(PREVIOUS_CONFIGURE_TYPE) + if(NOT ${PREVIOUS_CONFIGURE_TYPE} MATCHES ${CMAKE_WORD_SIZE}) + include(${CMAKE_SOURCE_DIR}/misc/CMake/ResetCache.cmake) + RESET_CACHE_file() + endif(NOT ${PREVIOUS_CONFIGURE_TYPE} MATCHES ${CMAKE_WORD_SIZE}) +endif(PREVIOUS_CONFIGURE_TYPE) + +set(PREVIOUS_CONFIGURE_TYPE ${CMAKE_WORD_SIZE} CACHE STRING "Previous configuration word size" FORCE) +mark_as_advanced(PREVIOUS_CONFIGURE_TYPE) + + +# ******************************************************************* +# *** Top Level Configure Options - Stage 1 of 9 *** +# ******************************************************************* +# +# Now we define the various options for XMLWRAPP - ways to enable and +# disable features, select which parts of the system to build, etc. +# As much as possible, sane default options are either selected or +# detected. Because documentation is autogenerated for XMLWRAPP +# options, be sure to initialize the file. +set(CONFIG_OPT_STRING "CONFIGURATION OPTIONS\n---------------------\n") +file(WRITE ${CMAKE_BINARY_DIR}/OPTIONS "${CONFIG_OPT_STRING}") + +# The XMLWRAPP CMake build will also generate a configure script +# that emulates the command option style of GNU Autotool's +# configure. Write the pre-defined header into the build-dir template +# to initialize the file. +file(REMOVE ${CMAKE_BINARY_DIR}/configure.new) +file(READ ${XMLWRAPP_SOURCE_DIR}/misc/CMake/configure_prefix.sh CONFIG_PREFIX) +file(WRITE ${CMAKE_BINARY_DIR}/configure.new.tmp "${CONFIG_PREFIX}") +file(COPY ${CMAKE_BINARY_DIR}/configure.new.tmp DESTINATION + ${CMAKE_BINARY_DIR}/CMakeFiles FILE_PERMISSIONS OWNER_READ OWNER_WRITE + OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) +file(REMOVE ${CMAKE_BINARY_DIR}/configure.new.tmp) +file(RENAME ${CMAKE_BINARY_DIR}/CMakeFiles/configure.new.tmp + ${CMAKE_BINARY_DIR}/configure.new) + +# Build shared libs by default. Mark this as advanced - turning off +# ALL shared library building is unlikely to result in a working build +# and is not a typical configuration. Note that turning this option off +# will not disable libraries specifically added as SHARED. +option(BUILD_SHARED_LIBS "Build shared libraries" ON) +mark_as_advanced(BUILD_SHARED_LIBS) + +# Build static libs by default unless we're debugging. Note: this +# option will not disable libraries specifically added as STATIC even +# when OFF. +AUTO_OPTION(XMLWRAPP_BUILD_STATIC_LIBS BUILD_STATIC_LIBS "OFF" "ON") + + +# On Mac OS X, it is common to have third party package managers +# present for easy software installation (currently we're aware of +# Fink and MacPorts). This can seriously complicate find_* results, +# so provide an option to specify whether or which of the third +# party setup to use. +include(${CMAKE_SOURCE_DIR}/misc/CMake/Fink_MacPorts.cmake) + +# Option for librtserver, used to help Java programs interface with librt. +option(XMLWRAPP_ENABLE_RTSERVER "Enable the librtserver target." OFF) + +# Turn off the xmlwrapp.dll build. +# It's an expert's setting at the moment. +option(XMLWRAPP_ENABLE_XMLWRAPP_LIBRARY "Build the xmlwrapp.dll" OFF) +mark_as_advanced(XMLWRAPP_ENABLE_XMLWRAPP_LIBRARY) + +# Global third party controls - these options enable and disable ALL +# local copies of libraries in src/other. Forcing all local +# libraries off is not usually recommended unless attempting to +# build packages for a distribution. If both of these options are +# on the enabling of local packages is the "senior" option and will +# force the system libs option to off. +set(XMLWRAPP_BUNDLED_LIBS_ALIASES "ENABLE_ALL") +set(XMLWRAPP_BUNDLED_LIBS_DESCRIPTION " +Enables compilation of all 3rd party sources that are provided within a XMLWRAPP +source distribution. If used this option sets all other 3rd party library +build flags to ON by default. However, that setting can be overridden by +manually setting individual variables. Default is \"AUTO\" - 3rd party sources +are compiled only if they are not detected as being available and functioning +as expected. +") +XMLWRAPP_OPTION(AUTO XMLWRAPP_BUNDLED_LIBS XMLWRAPP_BUNDLED_LIBS_ALIASES XMLWRAPP_BUNDLED_LIBS_DESCRIPTION) +set_property(CACHE XMLWRAPP_BUNDLED_LIBS PROPERTY STRINGS AUTO BUNDLED SYSTEM) +string(TOUPPER "${XMLWRAPP_BUNDLED_LIBS}" XMLWRAPP_BUNDLED_LIBS_UPPER) +set(XMLWRAPP_BUNDLED_LIBS "${XMLWRAPP_BUNDLED_LIBS_UPPER}" CACHE STRING "Build bundled libraries." FORCE) +if(${XMLWRAPP_BUNDLED_LIBS} MATCHES "ON") + set(XMLWRAPP_BUNDLED_LIBS "BUNDLED" CACHE STRING "Build bundled libraries." FORCE) +endif(${XMLWRAPP_BUNDLED_LIBS} MATCHES "ON") +if(${XMLWRAPP_BUNDLED_LIBS} MATCHES "OFF") + set(XMLWRAPP_BUNDLED_LIBS "SYSTEM" CACHE STRING "Build bundled libraries." FORCE) +endif(${XMLWRAPP_BUNDLED_LIBS} MATCHES "OFF") +if(NOT XMLWRAPP_BUNDLED_LIBS MATCHES "AUTO" AND NOT XMLWRAPP_BUNDLED_LIBS MATCHES "BUNDLED" AND NOT XMLWRAPP_BUNDLED_LIBS MATCHES "SYSTEM") + message(WARNING "Unknown value XMLWRAPP_BUNDLED_LIBS supplied for XMLWRAPP_BUNDLED_LIBS - defaulting to AUTO") + message(WARNING "Valid options are AUTO, BUNDLED and SYSTEM") + set(XMLWRAPP_BUNDLED_LIBS "AUTO" CACHE STRING "Build bundled libraries." FORCE) +endif(NOT XMLWRAPP_BUNDLED_LIBS MATCHES "AUTO" AND NOT XMLWRAPP_BUNDLED_LIBS MATCHES "BUNDLED" AND NOT XMLWRAPP_BUNDLED_LIBS MATCHES "SYSTEM") + +# Enable Aqua widgets on Mac OSX. This impacts Tcl/Tk building and OpenGL +# building. Not currently working - needs work in at least Tk and togl +# CMake logic (probably more), and the display manager/framebuffer codes are known to depend +# on either GLX or WGL specifically in their current forms. +option(XMLWRAPP_ENABLE_AQUA "Use Aqua instead of X11 whenever possible on OSX." OFF) +mark_as_advanced(XMLWRAPP_ENABLE_AQUA) + +# Install example XMLWRAPP Geometry Files +option(XMLWRAPP_INSTALL_EXAMPLE_GEOMETRY "Install the example XMLWRAPP geometry files." ON) + +# Enable features requiring X11 +if(WIN32) + option(XMLWRAPP_ENABLE_X11 "Use X11." OFF) + mark_as_advanced(XMLWRAPP_ENABLE_X11) +elseif(XMLWRAPP_ENABLE_AQUA) + option(XMLWRAPP_ENABLE_X11 "Use X11." OFF) +else(WIN32) + option(XMLWRAPP_ENABLE_X11 "Use X11." ON) +endif(WIN32) +if(XMLWRAPP_ENABLE_X11) + set(XMLWRAPP_ENABLE_AQUA OFF CACHE STRING "Don't use Aqua if we're doing X11" FORCE) + set(OPENGL_USE_AQUA OFF CACHE STRING "Don't use Aqua if we're doing X11" FORCE) +endif(XMLWRAPP_ENABLE_X11) +mark_as_advanced(OPENGL_USE_AQUA) + +# Enable/disable features requiring the Tk toolkit - usually this should +# be on, as a lot of functionality in XMLWRAPP depends on Tk +option(XMLWRAPP_ENABLE_TK "Enable features requiring the Tk toolkit" ON) +mark_as_advanced(XMLWRAPP_ENABLE_TK) +if(NOT WIN32) + if(APPLE) + if(NOT XMLWRAPP_ENABLE_X11 AND NOT XMLWRAPP_ENABLE_AQUA) + set(XMLWRAPP_ENABLE_TK OFF) + endif(NOT XMLWRAPP_ENABLE_X11 AND NOT XMLWRAPP_ENABLE_AQUA) + if(XMLWRAPP_ENABLE_X11) + set(TK_X11_GRAPHICS ON CACHE STRING "Need X11 Tk" FORCE) + endif(XMLWRAPP_ENABLE_X11) + else(APPLE) + if(NOT XMLWRAPP_ENABLE_X11) + set(XMLWRAPP_ENABLE_TK OFF) + else(NOT XMLWRAPP_ENABLE_X11) + set(TK_X11_GRAPHICS ON CACHE STRING "Need X11 Tk" FORCE) + endif(NOT XMLWRAPP_ENABLE_X11) + endif(APPLE) +endif(NOT WIN32) + +# Enable features requring OPENGL +# Be smart about this - if we don't have X11 or Aqua and we're +# not on Windows, we're non-graphical and that means OpenGL is +# a no-go. The Windows version would have to be some sort of +# option for the WIN32 graphics layer? Should probably think +# about that... for now, on Win32 don't try OpenGL if Tk is +# off. That'll hold until we get a non-Tk based GUI - then +# setting non-graphical on Windows will take more thought. +if(NOT WIN32) + if(APPLE) + if(NOT XMLWRAPP_ENABLE_X11 AND NOT XMLWRAPP_ENABLE_AQUA) + set(OPENGL_FOUND OFF) + set(XMLWRAPP_ENABLE_OPENGL OFF CACHE BOOL "Disabled - NOT XMLWRAPP_ENABLE_X11 AND NOT XMLWRAPP_ENABLE_AQUA" FORCE) + else(NOT XMLWRAPP_ENABLE_X11 AND NOT XMLWRAPP_ENABLE_AQUA) + include(${XMLWRAPP_CMAKE_DIR}/FindGL.cmake) + endif(NOT XMLWRAPP_ENABLE_X11 AND NOT XMLWRAPP_ENABLE_AQUA) + else(APPLE) + if(NOT XMLWRAPP_ENABLE_X11) + set(OPENGL_FOUND OFF) + set(XMLWRAPP_ENABLE_OPENGL OFF CACHE BOOL "Disabled - NOT XMLWRAPP_ENABLE_X11" FORCE) + else(NOT XMLWRAPP_ENABLE_X11) + include(${XMLWRAPP_CMAKE_DIR}/FindGL.cmake) + endif(NOT XMLWRAPP_ENABLE_X11) + endif(APPLE) +else(NOT WIN32) + if(XMLWRAPP_ENABLE_TK) + include(${XMLWRAPP_CMAKE_DIR}/FindGL.cmake) + else(XMLWRAPP_ENABLE_TK) + set(XMLWRAPP_ENABLE_OPENGL OFF CACHE BOOL "Disabled - WIN32 AND NOT XMLWRAPP_ENABLE_TK" FORCE) + endif(XMLWRAPP_ENABLE_TK) +endif(NOT WIN32) + +set(XMLWRAPP_ENABLE_OPENGL_ALIASES + ENABLE_OPENGL + ) +set(XMLWRAPP_ENABLE_OPENGL_DESCRIPTION " +Enable support for OpenGL based Display Managers in XMLWRAPP. +Default depends on whether OpenGL is successfully detected - +if it is, default is to enable. +") +XMLWRAPP_OPTION(${OPENGL_FOUND} XMLWRAPP_ENABLE_OPENGL XMLWRAPP_ENABLE_OPENGL_ALIASES XMLWRAPP_ENABLE_OPENGL_DESCRIPTION) + +# Enable RTGL. Requires an enabled OpenGL. +option(XMLWRAPP_ENABLE_RTGL "Enable experimental RTGL code." OFF) +mark_as_advanced(XMLWRAPP_ENABLE_RTGL) +if(NOT XMLWRAPP_ENABLE_OPENGL AND XMLWRAPP_ENABLE_RTGL) + message("RTGL requested, but OpenGL is not enabled - disabling") + set(XMLWRAPP_ENABLE_RTGL OFF CACHE BOOL "Enable experimental RTGL code." FORCE) +endif(NOT XMLWRAPP_ENABLE_OPENGL AND XMLWRAPP_ENABLE_RTGL) +if(NOT XMLWRAPP_ENABLE_X11 AND XMLWRAPP_ENABLE_RTGL) + message("RTGL currently works only with GLX, and X11 is not enabled - disabling") + set(XMLWRAPP_ENABLE_RTGL OFF CACHE BOOL "Enable experimental RTGL code." FORCE) +endif(NOT XMLWRAPP_ENABLE_X11 AND XMLWRAPP_ENABLE_RTGL) +if(XMLWRAPP_ENABLE_AQUA) + set(OPENGL_USE_AQUA ON CACHE STRING "Aqua enabled - use Aqua OpenGL" FORCE) +endif(XMLWRAPP_ENABLE_AQUA) + + +# Enable JOVE. +option(XMLWRAPP_ENABLE_JOVE "Enable jove editor build." OFF) +mark_as_advanced(XMLWRAPP_ENABLE_JOVE) + + +#---------------------------------------------------------------------- +# There are extra documentation files available requiring DocBook +# They are quite useful in graphical interfaces, but also add considerably +# to the overall build time. If necesssary XMLWRAPP provides its own +# xsltproc (see src/other/xmltools), so the html and man page +# outputs are always potentially available. PDF output, on the other hand, +# needs Apache FOP. FOP is not a candidate to bundle with XMLWRAPP for +# a number of reasons, so we simply check to see if it is present and set +# the options accordingly. + +# Do we have the environment variable set locally? +if(NOT "$ENV{APACHE_FOP}" STREQUAL "") + set(APACHE_FOP "$ENV{APACHE_FOP}") +endif(NOT "$ENV{APACHE_FOP}" STREQUAL "") +if(NOT APACHE_FOP) + find_program(APACHE_FOP fop DOC "path to the exec script for Apache FOP") +endif(NOT APACHE_FOP) +mark_as_advanced(APACHE_FOP) +# We care about the FOP version, unfortunately - find out what we have. +if(APACHE_FOP) + execute_process(COMMAND ${APACHE_FOP} -v OUTPUT_VARIABLE APACHE_FOP_INFO ERROR_QUIET) + string(REGEX REPLACE "FOP Version ([0-9\\.]*)" "\\1" APACHE_FOP_VERSION_REGEX "${APACHE_FOP_INFO}") + if(APACHE_FOP_VERSION_REGEX) + string(STRIP ${APACHE_FOP_VERSION_REGEX} APACHE_FOP_VERSION_REGEX) + endif(APACHE_FOP_VERSION_REGEX) + if(NOT "${APACHE_FOP_VERSION}" STREQUAL "${APACHE_FOP_VERSION_REGEX}") + message("-- Found Apache FOP: version ${APACHE_FOP_VERSION_REGEX}") + set(APACHE_FOP_VERSION ${APACHE_FOP_VERSION_REGEX} CACHE STRING "Apache FOP version" FORCE) + mark_as_advanced(APACHE_FOP_VERSION) + endif(NOT "${APACHE_FOP_VERSION}" STREQUAL "${APACHE_FOP_VERSION_REGEX}") +endif(APACHE_FOP) + +# The HTML output is used in the graphical help browsers in MGED and Archer, +# as well as being the most likely candidate for external viewers. Turn this +# on unless explicitly instructed otherwise by the user. +set(XMLWRAPP_EXTRADOCS_ALIASES + ENABLE_DOCS + ENABLE_EXTRA_DOCS + ENABLE_DOCBOOK + ) +set(XMLWRAPP_EXTRADOCS_DESCRIPTION " +The core option that enables and disables building of XMLWRAPP's DocBook +based documentation (includes manuals and man pages for commands, among +other things.) Defaults to ON, but only HTML and MAN formats are enabled +by default - PDF must be enabled separately by use of this option or one +of its aliases. Note that you may set environment variable APACHE_FOP +to point to your locally installed fop executable file (which on Linux is +usually a shell script with 0755 permissions). +") +XMLWRAPP_OPTION(ON XMLWRAPP_EXTRADOCS XMLWRAPP_EXTRADOCS_ALIASES XMLWRAPP_EXTRADOCS_DESCRIPTION) + +include(CMakeDependentOption) + +# By default, always do HTML output if we're doing extradocs output +CMAKE_DEPENDENT_OPTION(XMLWRAPP_EXTRADOCS_HTML "Build MAN page output from DocBook documentation" ON "XMLWRAPP_EXTRADOCS" OFF) +mark_as_advanced(XMLWRAPP_EXTRADOCS_HTML) + +# Normally, we'll turn on man page output by default, but there is +# no point in doing man page output for a Visual Studio build - the +# files aren't useful and it *seriously* increases the target build +# count/build time. Conditionalize on the CMake MSVC variable NOT +# being set. +CMAKE_DEPENDENT_OPTION(XMLWRAPP_EXTRADOCS_MAN "Build MAN page output from DocBook documentation" ON "XMLWRAPP_EXTRADOCS;NOT MSVC" OFF) +mark_as_advanced(XMLWRAPP_EXTRADOCS_MAN) + +# Don't do PDF by default, and hide the option unless the tools to do it are +# present. Provide an option to disable the PDF output for man pages without +# disabling the rest of the PDF output - PDF generation for hundreds of man +# pages can be expensive in time. +set(XMLWRAPP_EXTRADOCS_PDF_DESCRIPTION " +Option that enables building of XMLWRAPP's DocBook PDF-based documentation +(includes manuals and man pages for commands, among +other things.) Defaults to OFF. +Note that you may set environment variable APACHE_FOP +to point to your locally installed fop executable file (which on Linux is +usually a shell script with 0755 permissions). +") +set(XMLWRAPP_EXTRADOCS_PDF_MAN_DESCRIPTION " +Option that enables building of XMLWRAPP's DocBook PDF-based documentation +for man pages only. Defaults to OFF. +") +CMAKE_DEPENDENT_OPTION(XMLWRAPP_EXTRADOCS_PDF "Build PDF output from DocBook documentation" OFF "XMLWRAPP_EXTRADOCS;APACHE_FOP" OFF) +CMAKE_DEPENDENT_OPTION(XMLWRAPP_EXTRADOCS_PDF_MAN "Build PDF output from DocBook documentation for man pages" ON "XMLWRAPP_EXTRADOCS_PDF" OFF) + +# Don't do it by default, but provide an option to perform validation as part +# of the DocBook build - sort of a "strict flags" mode for DocBook +CMAKE_DEPENDENT_OPTION(XMLWRAPP_EXTRADOCS_VALIDATE "Perform validation for DocBook documentation" OFF "XMLWRAPP_EXTRADOCS" OFF) +mark_as_advanced(XMLWRAPP_EXTRADOCS_VALIDATE) + +#---------------------------------------------------------------------- +# The following are fine-grained options for enabling/disabling compiler +# and source code definition settings. Typically these are set to +# various configurations by the toplevel CMAKE_BUILD_TYPE setting, but +# can also be individually set. + +# Enable/disable runtime debugging - these are protections for +# minimizing the possibility of corrupted data files. Generally +# speaking these should be left on. +set(XMLWRAPP_ENABLE_RUNTIME_DEBUG_ALIASES + ENABLE_RUNTIME_DEBUG + ENABLE_RUN_TIME_DEBUG + ENABLE_RUNTIME_DEBUGGING + ENABLE_RUN_TIME_DEBUGGING) +set(XMLWRAPP_ENABLE_RUNTIME_DEBUG_DESCRIPTION " +Enables support for application and library debugging facilities. +Disabling the run-time debugging facilities can provide a significant +(10%-30%) performance boost at the expense of extensive error +checking (that in turn help prevent corruption of your data). +Default is "ON", and should only be disabled for read-only render +work where performance is critical. +") +XMLWRAPP_OPTION(ON XMLWRAPP_ENABLE_RUNTIME_DEBUG XMLWRAPP_ENABLE_RUNTIME_DEBUG_ALIASES XMLWRAPP_ENABLE_RUNTIME_DEBUG_DESCRIPTION) +mark_as_advanced(XMLWRAPP_ENABLE_RUNTIME_DEBUG) +if(NOT XMLWRAPP_ENABLE_RUNTIME_DEBUG) + message("}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}") + message("While disabling run-time debugging should increase") + message("performance, it will likewise remove several") + message("data-protection safeguards that are in place to") + message("minimize the possibility of corrupted data files") + message("in the inevitable event of a user encountering a bug.") + message("You have been warned. Proceed at your own risk.") + message("{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{") + file(APPEND ${CONFIG_H_FILE} "/*Define to not do anything for macros that only bomb on a fatal error. */\n") + file(APPEND ${CONFIG_H_FILE} "#define NO_BOMBING_MACROS 1\n") + file(APPEND ${CONFIG_H_FILE} "/*Define to not perform magic number checking */\n") + file(APPEND ${CONFIG_H_FILE} "#define NO_MAGIC_CHECKING 1\n") + file(APPEND ${CONFIG_H_FILE} "/*Define to not check for divide by zero during ray shots */\n") + file(APPEND ${CONFIG_H_FILE} "#define NO_BADRAY_CHECKING 1\n") + file(APPEND ${CONFIG_H_FILE} "/*Define to not provide run-time debug facilities via rt_g.debug */\n") + file(APPEND ${CONFIG_H_FILE} "#define NO_DEBUG_CHECKING 1\n") +endif(NOT XMLWRAPP_ENABLE_RUNTIME_DEBUG) + +# Enable debug flags during compilation +set(XMLWRAPP_FLAGS_DEBUG_ALIASES + ENABLE_DEBUG + ENABLE_FLAGS_DEBUG + ENABLE_DEBUG_FLAGS + ) +set(XMLWRAPP_FLAGS_DEBUG_DESCRIPTION " +Add compiler flags to aid in program debugging. Default depends on CMake +build type - defaults to ON for Debug, OFF for Release. +") +AUTO_OPTION(XMLWRAPP_FLAGS_DEBUG XMLWRAPP_DEBUG_BUILD "ON" "OFF") +OPTION_ALIASES(XMLWRAPP_FLAGS_DEBUG XMLWRAPP_FLAGS_DEBUG_ALIASES "BOOL") +OPTION_DESCRIPTION(XMLWRAPP_FLAGS_DEBUG XMLWRAPP_FLAGS_DEBUG_ALIASES XMLWRAPP_FLAGS_DEBUG_DESCRIPTION) + +# Build with compiler warning flags +set(XMLWRAPP_ENABLE_COMPILER_WARNINGS_ALIASES + ENABLE_WARNINGS + ENABLE_COMPILER_WARNINGS + ) +set(XMLWRAPP_ENABLE_COMPILER_WARNINGS_DESCRIPTION " +Use extra compiler warning flags when compiling C/C++ code. Defaults to ON. +") +XMLWRAPP_OPTION(ON XMLWRAPP_ENABLE_COMPILER_WARNINGS + XMLWRAPP_ENABLE_COMPILER_WARNINGS_ALIASES + XMLWRAPP_ENABLE_COMPILER_WARNINGS_DESCRIPTION) +mark_as_advanced(XMLWRAPP_ENABLE_COMPILER_WARNINGS) + +# Enable/disable strict compiler settings - these are limited to libraries that +# specifically inform the XMLWRAPP_ADDLIB macro they can be built with STRICT flags. + +set(XMLWRAPP_ENABLE_STRICT_ALIASES + ENABLE_STRICT + ENABLE_STRICT_COMPILE + ENABLE_STRICT_COMPILE_FLAGS) +set(XMLWRAPP_ENABLE_STRICT_DESCRIPTION " +Causes all compilation warnings for C code to be treated as errors. This is now +the default for XMLWRAPP source code, and developers should address issues +discovered by these flags whenever possible rather than disabling strict +mode. +") +XMLWRAPP_OPTION(ON XMLWRAPP_ENABLE_STRICT XMLWRAPP_ENABLE_STRICT_ALIASES XMLWRAPP_ENABLE_STRICT_DESCRIPTION) + +# The full XMLWRAPP strict flags are too much for a variety of system +# C++ headers presently (Dec. 2011) so we don't default to erroring out +# on warnings for C++ +option(XMLWRAPP_ENABLE_CXX_STRICT "Use strict compiler settings on cxx files in libraries that build with strict" OFF) +if(XMLWRAPP_ENABLE_STRICT) + mark_as_advanced(XMLWRAPP_ENABLE_STRICT) + mark_as_advanced(XMLWRAPP_ENABLE_CXX_STRICT) + file(APPEND ${CONFIG_H_FILE} "#define STRICT_FLAGS 1\n") +endif(XMLWRAPP_ENABLE_STRICT) + +# Build with compiler optimization flags. This should normally be on for release builds +AUTO_OPTION(XMLWRAPP_FLAGS_OPTIMIZATION XMLWRAPP_OPTIMIZED_BUILD "OFF" "ON") + +# By default, we don't want any error reports at all from src/other +option(XMLWRAPP_DISABLE_SRC_OTHER_WARN "Disable warnings for src/other" ON) +mark_as_advanced(XMLWRAPP_DISABLE_SRC_OTHER_WARN) + +# Build with full compiler lines visible by default (won't need make +# VERBOSE=1) on command line +option(XMLWRAPP_ENABLE_VERBOSE_PROGRESS "verbose output" OFF) +mark_as_advanced(XMLWRAPP_ENABLE_VERBOSE_PROGRESS) +if(XMLWRAPP_ENABLE_VERBOSE_PROGRESS) + set(CMAKE_VERBOSE_MAKEFILE ON) +endif(XMLWRAPP_ENABLE_VERBOSE_PROGRESS) + +# Build with profiling support +option(XMLWRAPP_ENABLE_PROFILING "Build with profiling support" OFF) +mark_as_advanced(XMLWRAPP_ENABLE_PROFILING) + +# Build with dtrace support +option(XMLWRAPP_ENABLE_DTRACE "Build with dtrace support" OFF) +mark_as_advanced(XMLWRAPP_ENABLE_DTRACE) +if(XMLWRAPP_ENABLE_DTRACE) + XMLWRAPP_INCLUDE_FILE(sys/sdt.h HAVE_SYS_SDT_H) + if(NOT HAVE_SYS_SDT_H) + set(XMLWRAPP_ENABLE_DTRACE OFF) + endif(NOT HAVE_SYS_SDT_H) +endif(XMLWRAPP_ENABLE_DTRACE) + +# Take advantage of parallel processors if available - highly recommended +option(XMLWRAPP_ENABLE_SMP "Enable SMP architecture parallel computation support" ON) +if(WIN32 AND XMLWRAPP_ENABLE_SMP) + message("SMP Support is not ready on Windows - disabling") + set(XMLWRAPP_ENABLE_SMP OFF) +endif(WIN32 AND XMLWRAPP_ENABLE_SMP) +mark_as_advanced(XMLWRAPP_ENABLE_SMP) +if(XMLWRAPP_ENABLE_SMP) + file(APPEND ${CONFIG_H_FILE} "#define PARALLEL 1\n") +endif(XMLWRAPP_ENABLE_SMP) + +# ******************************************************************* +# *** Check for Programs - Stage 2 of 9 *** +# ******************************************************************* + +# A variety of tools, such as the benchmark utilities, need +# a Bourne shell and other commands - check for them. +include(${XMLWRAPP_CMAKE_DIR}/FindShellDeps.cmake) + +# CMake can detect flex and bison, but apparently not generic lex/yacc. +# Solution is to make our own generic lex/yacc Find routines that look +# first for flex/bison, but will take whatever's available. Since the +# XMLWRAPP project isn't supposed to rely on flex/bison specific features +# anyway, there shouldn't be a problem. +include(${XMLWRAPP_CMAKE_DIR}/FindLEX.cmake) +include(${XMLWRAPP_CMAKE_DIR}/FindYACC.cmake) + + +# If using dtrace, we will need to find it +if(XMLWRAPP_ENABLE_DTRACE) + find_program(DTRACE_EXEC NAMES dtrace DOC "path to dtrace executable") +endif(XMLWRAPP_ENABLE_DTRACE) + + +# Load various wrapper macros for checking libraries, headers and +# functions +include(${XMLWRAPP_CMAKE_DIR}/XMLWRAPP_CheckFunctions.cmake) + + +# ******************************************************************* +# *** Check for Compiler Characteristics - Stage 3 of 9 *** +# ******************************************************************* + +... [truncated message content] |
From: <tbr...@us...> - 2012-03-18 21:55:13
|
Revision: 191 http://xmlwrapp.svn.sourceforge.net/xmlwrapp/?rev=191&view=rev Author: tbrowder2 Date: 2012-03-18 21:55:07 +0000 (Sun, 18 Mar 2012) Log Message: ----------- typo Modified Paths: -------------- trunk/TODO Modified: trunk/TODO =================================================================== --- trunk/TODO 2012-03-18 20:07:28 UTC (rev 190) +++ trunk/TODO 2012-03-18 21:55:07 UTC (rev 191) @@ -9,7 +9,7 @@ tasks. This is not an official list of tasks that will be completed; instead it's more like a developer scratch pad for recording ideas. -* complete Xpath support +* complete XPath support * convert to a CMake build system This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tbr...@us...> - 2012-03-18 20:07:34
|
Revision: 190 http://xmlwrapp.svn.sourceforge.net/xmlwrapp/?rev=190&view=rev Author: tbrowder2 Date: 2012-03-18 20:07:28 +0000 (Sun, 18 Mar 2012) Log Message: ----------- add an idea from the Feature Requests tracker Modified Paths: -------------- trunk/TODO Modified: trunk/TODO =================================================================== --- trunk/TODO 2012-03-18 20:03:32 UTC (rev 189) +++ trunk/TODO 2012-03-18 20:07:28 UTC (rev 190) @@ -9,6 +9,8 @@ tasks. This is not an official list of tasks that will be completed; instead it's more like a developer scratch pad for recording ideas. +* complete Xpath support + * convert to a CMake build system * develop a Debian package This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tbr...@us...> - 2012-03-18 20:03:38
|
Revision: 189 http://xmlwrapp.svn.sourceforge.net/xmlwrapp/?rev=189&view=rev Author: tbrowder2 Date: 2012-03-18 20:03:32 +0000 (Sun, 18 Mar 2012) Log Message: ----------- add a TODO list and populate it with some ideas Added Paths: ----------- trunk/TODO Added: trunk/TODO =================================================================== --- trunk/TODO (rev 0) +++ trunk/TODO 2012-03-18 20:03:32 UTC (rev 189) @@ -0,0 +1,22 @@ + -*- coding: utf-8 -*- + +xmlwrapp To Do List +=================== + +[thanks to the BRL-CAD project for the summary idea] + +This document contains a collection of desirable xmlwrapp development +tasks. This is not an official list of tasks that will be completed; +instead it's more like a developer scratch pad for recording ideas. + +* convert to a CMake build system + +* develop a Debian package + +* develop an RPM package + +* develop a package/port for FreeBSD + +* develop a package/port for OpenBSD + +* develop a package/port for NetBSD Property changes on: trunk/TODO ___________________________________________________________________ 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-18 19:50:53
|
Revision: 188 http://xmlwrapp.svn.sourceforge.net/xmlwrapp/?rev=188&view=rev Author: tbrowder2 Date: 2012-03-18 19:50:46 +0000 (Sun, 18 Mar 2012) Log Message: ----------- incorporate changes from forked version on github Modified Paths: -------------- trunk/LICENSE trunk/bootstrap trunk/include/xmlwrapp/exception.h trunk/include/xmlwrapp/export.h trunk/include/xmlwrapp/node.h trunk/include/xmlwrapp/nodes_view.h trunk/include/xmlwrapp/version.h trunk/platform/Win32/master.proj trunk/src/libxml/node.cxx trunk/src/libxml/node_iterator.cxx trunk/src/libxml/node_iterator.h trunk/src/libxml/nodes_view.cxx trunk/src/libxml/pimpl_base.h trunk/src/libxslt/result.h trunk/tests/Makefile.am trunk/tests/attributes/test_attributes.cxx trunk/tests/event/test_event.cxx trunk/tests/node/test_node.cxx trunk/tests/test.h trunk/tests/test_main.cxx trunk/tests/tree/test_tree.cxx trunk/tests/xslt/test_xslt.cxx Modified: trunk/LICENSE =================================================================== --- trunk/LICENSE 2012-03-18 19:49:33 UTC (rev 187) +++ trunk/LICENSE 2012-03-18 19:50:46 UTC (rev 188) @@ -1,5 +1,5 @@ Copyright (C) 2001-2003 Peter J Jones <pj...@pm...> -Copyright (C) 2009-2010 Vaclav Slavik <vs...@fa...> +Copyright (C) 2009-2010 Vaclav Slavik <vs...@gm...> All Rights Reserved Redistribution and use in source and binary forms, with or without Modified: trunk/bootstrap =================================================================== --- trunk/bootstrap 2012-03-18 19:49:33 UTC (rev 187) +++ trunk/bootstrap 2012-03-18 19:50:46 UTC (rev 188) @@ -42,13 +42,19 @@ exit 2 fi +if [ "${OSTYPE:0:6}" = "darwin" ]; then + LIBTOOLIZE=glibtoolize +else + LIBTOOLIZE=libtoolize +fi + # use --foreign with automake because we lack standard GNU NEWS and AUTHOR # files, if they're added we can "upgrade" to (default) GNU strictness. Use # --copy to allow simultaneous use on windows under mingw and cygwin platforms. # Symlinking of files under mingw does not work out for cygwin and vice-versa. echo "Setting up build system for xmlwrapp:" echo " - aclocal " && aclocal -I admin && \ -echo " - libtoolize " && libtoolize --copy --automake && \ +echo " - libtoolize " && $LIBTOOLIZE --copy --automake && \ echo " - autoconf " && autoconf && \ echo " - automake " && automake --add-missing --copy --foreign && \ echo " - doxygen " && (cd docs && doxygen) && \ Modified: trunk/include/xmlwrapp/exception.h =================================================================== --- trunk/include/xmlwrapp/exception.h 2012-03-18 19:49:33 UTC (rev 187) +++ trunk/include/xmlwrapp/exception.h 2012-03-18 19:50:46 UTC (rev 188) @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010 Vaclav Slavik <vs...@fa...> + * Copyright (C) 2010 Vaclav Slavik <vs...@gm...> * All Rights Reserved * * Redistribution and use in source and binary forms, with or without Modified: trunk/include/xmlwrapp/export.h =================================================================== --- trunk/include/xmlwrapp/export.h 2012-03-18 19:49:33 UTC (rev 187) +++ trunk/include/xmlwrapp/export.h 2012-03-18 19:50:46 UTC (rev 188) @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010 Vaclav Slavik <vs...@fa...> + * Copyright (C) 2010 Vaclav Slavik <vs...@gm...> * All Rights Reserved * * Redistribution and use in source and binary forms, with or without Modified: trunk/include/xmlwrapp/node.h =================================================================== --- trunk/include/xmlwrapp/node.h 2012-03-18 19:49:33 UTC (rev 187) +++ trunk/include/xmlwrapp/node.h 2012-03-18 19:50:46 UTC (rev 188) @@ -1,6 +1,6 @@ /* * Copyright (C) 2001-2003 Peter J Jones (pj...@pm...) - * 2009 Vaclav Slavik <vs...@fa...> + * 2009 Vaclav Slavik <vs...@gm...> * All Rights Reserved * * Redistribution and use in source and binary forms, with or without @@ -177,9 +177,11 @@ explicit node(const char *name); /** - Construct a new xml::node given a name and content. The content will - be used to create a new child text node. + Construct a new xml::node given a name and content. + The content, if it's not an empty string, will be used to create a new + child text node. + @param name The name of the new element. @param content The text that will be used to create a child node. */ Modified: trunk/include/xmlwrapp/nodes_view.h =================================================================== --- trunk/include/xmlwrapp/nodes_view.h 2012-03-18 19:49:33 UTC (rev 187) +++ trunk/include/xmlwrapp/nodes_view.h 2012-03-18 19:50:46 UTC (rev 188) @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009 Vaclav Slavik <vs...@fa...> + * Copyright (C) 2009 Vaclav Slavik <vs...@gm...> * All Rights Reserved * * Redistribution and use in source and binary forms, with or without Modified: trunk/include/xmlwrapp/version.h =================================================================== --- trunk/include/xmlwrapp/version.h 2012-03-18 19:49:33 UTC (rev 187) +++ trunk/include/xmlwrapp/version.h 2012-03-18 19:50:46 UTC (rev 188) @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009 Vaclav Slavik <vs...@fa...> + * Copyright (C) 2009 Vaclav Slavik <vs...@gm...> * All Rights Reserved * * Redistribution and use in source and binary forms, with or without Modified: trunk/platform/Win32/master.proj =================================================================== --- trunk/platform/Win32/master.proj 2012-03-18 19:49:33 UTC (rev 187) +++ trunk/platform/Win32/master.proj 2012-03-18 19:50:46 UTC (rev 188) @@ -5,9 +5,9 @@ <PropertyGroup> <VCVersion>9</VCVersion> - <VersionZlib>1.2.3</VersionZlib> + <VersionZlib>1.2.5</VersionZlib> <VersionIconv>1.9.2</VersionIconv> - <VersionLibxml2>2.7.6</VersionLibxml2> + <VersionLibxml2>2.7.8</VersionLibxml2> <VersionLibxslt>1.1.26</VersionLibxslt> </PropertyGroup> Modified: trunk/src/libxml/node.cxx =================================================================== --- trunk/src/libxml/node.cxx 2012-03-18 19:49:33 UTC (rev 187) +++ trunk/src/libxml/node.cxx 2012-03-18 19:50:46 UTC (rev 188) @@ -1,6 +1,6 @@ /* * Copyright (C) 2001-2003 Peter J Jones (pj...@pm...) - * 2009 Vaclav Slavik <vs...@fa...> + * 2009 Vaclav Slavik <vs...@gm...> * All Rights Reserved * * Redistribution and use in source and binary forms, with or without @@ -299,14 +299,17 @@ if (!pimpl_->xmlnode_) throw std::bad_alloc(); - xmlNodePtr content_node = xmlNewText(reinterpret_cast<const xmlChar*>(content)); - if (!content_node) - throw std::bad_alloc(); + if (std::strlen(content)) + { + xmlNodePtr content_node = xmlNewText(reinterpret_cast<const xmlChar*>(content)); + if (!content_node) + throw std::bad_alloc(); - if (!xmlAddChild(pimpl_->xmlnode_, content_node)) - { - xmlFreeNode(content_node); - throw std::bad_alloc(); + if (!xmlAddChild(pimpl_->xmlnode_, content_node)) + { + xmlFreeNode(content_node); + throw std::bad_alloc(); + } } ap.release(); Modified: trunk/src/libxml/node_iterator.cxx =================================================================== --- trunk/src/libxml/node_iterator.cxx 2012-03-18 19:49:33 UTC (rev 187) +++ trunk/src/libxml/node_iterator.cxx 2012-03-18 19:50:46 UTC (rev 188) @@ -1,6 +1,6 @@ /* * Copyright (C) 2001-2003 Peter J Jones (pj...@pm...) - * 2009 Vaclav Slavik <vs...@fa...> + * 2009 Vaclav Slavik <vs...@gm...> * All Rights Reserved * * Redistribution and use in source and binary forms, with or without Modified: trunk/src/libxml/node_iterator.h =================================================================== --- trunk/src/libxml/node_iterator.h 2012-03-18 19:49:33 UTC (rev 187) +++ trunk/src/libxml/node_iterator.h 2012-03-18 19:50:46 UTC (rev 188) @@ -1,6 +1,6 @@ /* * Copyright (C) 2001-2003 Peter J Jones (pj...@pm...) - * 2009 Vaclav Slavik <vs...@fa...> + * 2009 Vaclav Slavik <vs...@gm...> * All Rights Reserved * * Redistribution and use in source and binary forms, with or without Modified: trunk/src/libxml/nodes_view.cxx =================================================================== --- trunk/src/libxml/nodes_view.cxx 2012-03-18 19:49:33 UTC (rev 187) +++ trunk/src/libxml/nodes_view.cxx 2012-03-18 19:50:46 UTC (rev 188) @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009 Vaclav Slavik <vs...@fa...> + * Copyright (C) 2009 Vaclav Slavik <vs...@gm...> * All Rights Reserved * * Redistribution and use in source and binary forms, with or without Modified: trunk/src/libxml/pimpl_base.h =================================================================== --- trunk/src/libxml/pimpl_base.h 2012-03-18 19:49:33 UTC (rev 187) +++ trunk/src/libxml/pimpl_base.h 2012-03-18 19:50:46 UTC (rev 188) @@ -1,5 +1,5 @@ /* - * Copyright (C) 2008 Vaclav Slavik (vs...@fa...) + * Copyright (C) 2008 Vaclav Slavik (vs...@gm...) * All Rights Reserved * * Redistribution and use in source and binary forms, with or without Modified: trunk/src/libxslt/result.h =================================================================== --- trunk/src/libxslt/result.h 2012-03-18 19:49:33 UTC (rev 187) +++ trunk/src/libxslt/result.h 2012-03-18 19:50:46 UTC (rev 188) @@ -1,5 +1,5 @@ /* - * Copyright (C) 2008 Vadim Zeitlin (va...@ze...) + * Copyright (C) 2008 Vadim Zeitlin (vz-...@ze...) * All Rights Reserved * * Redistribution and use in source and binary forms, with or without Modified: trunk/tests/Makefile.am =================================================================== --- trunk/tests/Makefile.am 2012-03-18 19:49:33 UTC (rev 187) +++ trunk/tests/Makefile.am 2012-03-18 19:50:46 UTC (rev 188) @@ -3,8 +3,8 @@ AM_CPPFLAGS = -I$(top_srcdir)/include LIBS = $(top_builddir)/src/libxmlwrapp.la \ - -lboost_unit_test_framework \ - -lboost_iostreams + $(BOOST_UNIT_TEST_FRAMEWORK_LIBS) $(BOOST_UNIT_TEST_FRAMEWORK_LDFLAGS) \ + $(BOOST_IOSTREAMS_LIBS) $(BOOST_IOSTREAMS_LDFLAGS) noinst_PROGRAMS = test Modified: trunk/tests/attributes/test_attributes.cxx =================================================================== --- trunk/tests/attributes/test_attributes.cxx 2012-03-18 19:49:33 UTC (rev 187) +++ trunk/tests/attributes/test_attributes.cxx 2012-03-18 19:50:46 UTC (rev 188) @@ -1,6 +1,6 @@ /* * Copyright (C) 2001-2003 Peter J Jones (pj...@pm...) - * Copyright (C) 2009 Vaclav Slavik (vs...@fa...) + * Copyright (C) 2009 Vaclav Slavik (vs...@gm...) * All Rights Reserved * * Redistribution and use in source and binary forms, with or without Modified: trunk/tests/event/test_event.cxx =================================================================== --- trunk/tests/event/test_event.cxx 2012-03-18 19:49:33 UTC (rev 187) +++ trunk/tests/event/test_event.cxx 2012-03-18 19:50:46 UTC (rev 188) @@ -1,6 +1,6 @@ /* * Copyright (C) 2001-2003 Peter J Jones (pj...@pm...) - * Copyright (C) 2009 Vaclav Slavik (vs...@fa...) + * Copyright (C) 2009 Vaclav Slavik (vs...@gm...) * All Rights Reserved * * Redistribution and use in source and binary forms, with or without Modified: trunk/tests/node/test_node.cxx =================================================================== --- trunk/tests/node/test_node.cxx 2012-03-18 19:49:33 UTC (rev 187) +++ trunk/tests/node/test_node.cxx 2012-03-18 19:50:46 UTC (rev 188) @@ -1,6 +1,6 @@ /* * Copyright (C) 2001-2003 Peter J Jones (pj...@pm...) - * Copyright (C) 2009-2010 Vaclav Slavik (vs...@fa...) + * Copyright (C) 2009-2010 Vaclav Slavik (vs...@gm...) * All Rights Reserved * * Redistribution and use in source and binary forms, with or without Modified: trunk/tests/test.h =================================================================== --- trunk/tests/test.h 2012-03-18 19:49:33 UTC (rev 187) +++ trunk/tests/test.h 2012-03-18 19:50:46 UTC (rev 188) @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009 Vaclav Slavik (vs...@fa...) + * Copyright (C) 2009 Vaclav Slavik (vs...@gm...) * All Rights Reserved * * Redistribution and use in source and binary forms, with or without Modified: trunk/tests/test_main.cxx =================================================================== --- trunk/tests/test_main.cxx 2012-03-18 19:49:33 UTC (rev 187) +++ trunk/tests/test_main.cxx 2012-03-18 19:50:46 UTC (rev 188) @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009 Vaclav Slavik (vs...@fa...) + * Copyright (C) 2009 Vaclav Slavik (vs...@gm...) * All Rights Reserved * * Redistribution and use in source and binary forms, with or without Modified: trunk/tests/tree/test_tree.cxx =================================================================== --- trunk/tests/tree/test_tree.cxx 2012-03-18 19:49:33 UTC (rev 187) +++ trunk/tests/tree/test_tree.cxx 2012-03-18 19:50:46 UTC (rev 188) @@ -1,6 +1,6 @@ /* * Copyright (C) 2001-2003 Peter J Jones (pj...@pm...) - * Copyright (C) 2009 Vaclav Slavik (vs...@fa...) + * Copyright (C) 2009 Vaclav Slavik (vs...@gm...) * All Rights Reserved * * Redistribution and use in source and binary forms, with or without Modified: trunk/tests/xslt/test_xslt.cxx =================================================================== --- trunk/tests/xslt/test_xslt.cxx 2012-03-18 19:49:33 UTC (rev 187) +++ trunk/tests/xslt/test_xslt.cxx 2012-03-18 19:50:46 UTC (rev 188) @@ -1,6 +1,6 @@ /* * Copyright (C) 2001-2003 Peter J Jones (pj...@pm...) - * Copyright (C) 2009 Vaclav Slavik (vs...@fa...) + * Copyright (C) 2009 Vaclav Slavik (vs...@gm...) * All Rights Reserved * * Redistribution and use in source and binary forms, with or without This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tbr...@us...> - 2012-03-18 19:49:39
|
Revision: 187 http://xmlwrapp.svn.sourceforge.net/xmlwrapp/?rev=187&view=rev Author: tbrowder2 Date: 2012-03-18 19:49:33 +0000 (Sun, 18 Mar 2012) Log Message: ----------- update AUTHORS to reflect earliest contribution if known; list other contributors with no specifically documented input that can be found Modified Paths: -------------- trunk/AUTHORS Modified: trunk/AUTHORS =================================================================== --- trunk/AUTHORS 2011-07-07 18:40:43 UTC (rev 186) +++ trunk/AUTHORS 2012-03-18 19:49:33 UTC (rev 187) @@ -1,18 +1,60 @@ -Current maintainer: - Vaclav Slavik <vs...@fa...> +ORIGINAL ARCHITECT AND AUTHOR +----------------------------- -Past developers: - Peter J Jones <pj...@pm...> +Peter J. Jones <pj...@pm...> + +Current maintainer +------------------ + + Tom Browder <tom...@gm...> + +Past maintainers +---------------- + Eric Beyeler <eri...@us...> - Tom Browder <tbr...@us...> + Vaclav Slavik <vs...@gm...> + +Contributors +------------ -Other contributors: + August 2003 + Peter J. Jones <pj...@pm...> + nicknames pjones + + August 2003 + nicknames sbeasley + + September 2005 + Tom Browder <tom...@gm...> + nicknames tbrowder2 + + July 2007 + Tiziano Mueller <ti...@us...> + nicknames tiziano + + November 2008 + Vaclav Slavik <vs...@gm...> + nicknames vaclavslavik + + December 2009 + Vadim Zeitlin <va...@tt...> + nicknames vadz + + May 2009 + Michael Grundberg <mgr...@us...> + nicknames mgrundberg + +Contributors (undocumented contributions) +----------------------------------------- + Sergey Satskiy <ser...@gm...> - Vadim Zeitlin <va...@tt...> - Tiziano Mueller <ti...@us...> + Greg Chicares <gch...@sb...> + Daniel Evison + Frank Grimm + Gary Passero - Michael Grundberg <mgr...@us...> + Dmitriy Nikitinskiy This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <va...@us...> - 2011-07-07 18:40:51
|
Revision: 186 http://xmlwrapp.svn.sourceforge.net/xmlwrapp/?rev=186&view=rev Author: vadz Date: 2011-07-07 18:40:43 +0000 (Thu, 07 Jul 2011) Log Message: ----------- Add -no-undefined to libraries LDFLAGS to allow creating DLLs under Windows. Libtool refuses to even try to create shared libraries under Windows without -no-undefined and this even if --disable-static is specified when configuring. As we don't have any undefined symbols in our libraries, use -no-undefined to explicitly communicate this to libtool and convince it to build DLLs. Modified Paths: -------------- trunk/src/Makefile.am Modified: trunk/src/Makefile.am =================================================================== --- trunk/src/Makefile.am 2010-05-21 16:59:34 UTC (rev 185) +++ trunk/src/Makefile.am 2011-07-07 18:40:43 UTC (rev 186) @@ -9,7 +9,7 @@ libxmlwrapp_la_CPPFLAGS = $(AM_CPPFLAGS) $(LIBXML_CFLAGS) libxmlwrapp_la_LIBADD = $(LIBXML_LIBS) -libxmlwrapp_la_LDFLAGS = -version-info 6:0:1 +libxmlwrapp_la_LDFLAGS = -version-info 6:0:1 -no-undefined libxmlwrapp_la_SOURCES = \ libxml/ait_impl.cxx \ @@ -36,7 +36,7 @@ libxsltwrapp_la_CPPFLAGS = $(AM_CPPFLAGS) $(LIBEXSLT_CFLAGS) $(LIBXSLT_CFLAGS) libxsltwrapp_la_LIBADD = libxmlwrapp.la $(LIBEXSLT_LIBS) $(LIBXSLT_LIBS) -libxsltwrapp_la_LDFLAGS = -version-info 3:0:0 +libxsltwrapp_la_LDFLAGS = -version-info 3:0:0 -no-undefined libxsltwrapp_la_SOURCES = \ libxslt/init.cxx \ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <vac...@us...> - 2010-05-21 16:59:40
|
Revision: 185 http://xmlwrapp.svn.sourceforge.net/xmlwrapp/?rev=185&view=rev Author: vaclavslavik Date: 2010-05-21 16:59:34 +0000 (Fri, 21 May 2010) Log Message: ----------- Do global testsuite initialization properly. Instead of calling unit_test_main manually from main, do it the proper Boost.Test way: define BOOST_TEST_MAIN and have a global fixture for srcdir initialization. Modified Paths: -------------- trunk/tests/test_main.cxx Modified: trunk/tests/test_main.cxx =================================================================== --- trunk/tests/test_main.cxx 2010-04-29 12:21:58 UTC (rev 184) +++ trunk/tests/test_main.cxx 2010-05-21 16:59:34 UTC (rev 185) @@ -30,23 +30,21 @@ * SUCH DAMAGE. */ +#define BOOST_TEST_MAIN #include "test.h" #include <cstdlib> std::string srcdir = "."; -bool init_unit_test() +struct SrcdirConfig { - const char *s = std::getenv("srcdir"); - if ( s ) - srcdir = s; + SrcdirConfig() + { + const char *s = std::getenv("srcdir"); + if ( s ) + srcdir = s; + } +}; - return true; -} - -int main(int argc, char *argv[]) -{ - return boost::unit_test::unit_test_main(&init_unit_test, argc, argv); -} - +BOOST_GLOBAL_FIXTURE(SrcdirConfig); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <vac...@us...> - 2010-04-29 12:22:08
|
Revision: 184 http://xmlwrapp.svn.sourceforge.net/xmlwrapp/?rev=184&view=rev Author: vaclavslavik Date: 2010-04-29 12:21:58 +0000 (Thu, 29 Apr 2010) Log Message: ----------- Update libtool version info to reflect new APIs. Modified Paths: -------------- trunk/src/Makefile.am Modified: trunk/src/Makefile.am =================================================================== --- trunk/src/Makefile.am 2010-04-20 16:15:43 UTC (rev 183) +++ trunk/src/Makefile.am 2010-04-29 12:21:58 UTC (rev 184) @@ -9,7 +9,7 @@ libxmlwrapp_la_CPPFLAGS = $(AM_CPPFLAGS) $(LIBXML_CFLAGS) libxmlwrapp_la_LIBADD = $(LIBXML_LIBS) -libxmlwrapp_la_LDFLAGS = -version-info 5:1:0 +libxmlwrapp_la_LDFLAGS = -version-info 6:0:1 libxmlwrapp_la_SOURCES = \ libxml/ait_impl.cxx \ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <vac...@us...> - 2010-04-20 16:15:50
|
Revision: 183 http://xmlwrapp.svn.sourceforge.net/xmlwrapp/?rev=183&view=rev Author: vaclavslavik Date: 2010-04-20 16:15:43 +0000 (Tue, 20 Apr 2010) Log Message: ----------- Generate project files in msbuild file. If the project files are missing (e.g. in SVN checkout), run bakefile_gen to create them first. Modified Paths: -------------- trunk/platform/Win32/master.proj Modified: trunk/platform/Win32/master.proj =================================================================== --- trunk/platform/Win32/master.proj 2010-04-19 12:42:00 UTC (rev 182) +++ trunk/platform/Win32/master.proj 2010-04-20 16:15:43 UTC (rev 183) @@ -25,7 +25,7 @@ <Import Project="$(MSBuildExtensionsPath)\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets"/> - <Target Name="Build" DependsOnTargets="Deps" > + <Target Name="Build" DependsOnTargets="Deps;BakefileGen" > <Message Text="Building C++ library with Visual C++ $(VCVersion)..."/> <ItemGroup> <VCProjFiles Include="xmlwrapp_vc$(VCVersion)_*.vcproj"/> @@ -36,6 +36,11 @@ /> </Target> + <Target Name="BakefileGen" Condition="!Exists('xmlwrapp_vc$(VCVersion)_xmlwrapp.vcproj')"> + <Message Text="Running Bakefile to generate project files..."/> + <Exec Command="bakefile_gen"/> + </Target> + <Target Name="Deps"> <MakeDir Directories="download"/> <WebDownload Condition="!Exists('download\$(ZipZlib)')" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <vac...@us...> - 2010-04-19 12:42:06
|
Revision: 182 http://xmlwrapp.svn.sourceforge.net/xmlwrapp/?rev=182&view=rev Author: vaclavslavik Date: 2010-04-19 12:42:00 +0000 (Mon, 19 Apr 2010) Log Message: ----------- Add win32 msbuild script for downloading dependencies. This makes it a bit easier to build with VC++. Modified Paths: -------------- trunk/platform/Win32/README trunk/platform/Win32/xmlwrapp.bkl Added Paths: ----------- trunk/platform/Win32/master.proj Modified: trunk/platform/Win32/README =================================================================== --- trunk/platform/Win32/README 2010-04-10 08:39:59 UTC (rev 181) +++ trunk/platform/Win32/README 2010-04-19 12:42:00 UTC (rev 182) @@ -1,3 +1,8 @@ Please use Bakefile (http://www.bakefile.org) to generate Visual C++ project files. + + +For convience, master.proj msbuild project is included. This downloads all +dependencies. It requires MSBuild.Community.Tasks from +http://msbuildtasks.tigris.org/ (just install the MSI package). Added: trunk/platform/Win32/master.proj =================================================================== --- trunk/platform/Win32/master.proj (rev 0) +++ trunk/platform/Win32/master.proj 2010-04-19 12:42:00 UTC (rev 182) @@ -0,0 +1,78 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + + <!-- configurable settings --> + <PropertyGroup> + <VCVersion>9</VCVersion> + + <VersionZlib>1.2.3</VersionZlib> + <VersionIconv>1.9.2</VersionIconv> + <VersionLibxml2>2.7.6</VersionLibxml2> + <VersionLibxslt>1.1.26</VersionLibxslt> + </PropertyGroup> + + <PropertyGroup> + <LibxmlWinSite>ftp://ftp.zlatkovic.com/libxml</LibxmlWinSite> + <DirZlib>zlib-$(VersionZlib).win32</DirZlib> + <DirIconv>iconv-$(VersionIconv).win32</DirIconv> + <DirLibxml2>libxml2-$(VersionLibxml2).win32</DirLibxml2> + <DirLibxslt>libxslt-$(VersionLibxslt).win32</DirLibxslt> + <ZipZlib>$(DirZlib).zip</ZipZlib> + <ZipIconv>$(DirIconv).zip</ZipIconv> + <ZipLibxml2>$(DirLibxml2).zip</ZipLibxml2> + <ZipLibxslt>$(DirLibxslt).zip</ZipLibxslt> + </PropertyGroup> + + <Import Project="$(MSBuildExtensionsPath)\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets"/> + + <Target Name="Build" DependsOnTargets="Deps" > + <Message Text="Building C++ library with Visual C++ $(VCVersion)..."/> + <ItemGroup> + <VCProjFiles Include="xmlwrapp_vc$(VCVersion)_*.vcproj"/> + </ItemGroup> + <VCBuild SolutionFile="xmlwrapp_vc$(VCVersion).sln" + Projects="@(VCProjFiles)" + Configuration="$(Configuration)" + /> + </Target> + + <Target Name="Deps"> + <MakeDir Directories="download"/> + <WebDownload Condition="!Exists('download\$(ZipZlib)')" + FileName="download\$(ZipZlib)" + FileUri="$(LibxmlWinSite)//$(ZipZlib)"/> + <WebDownload Condition="!Exists('download\$(ZipIconv)')" + FileName="download\$(ZipIconv)" + FileUri="$(LibxmlWinSite)//$(ZipIconv)"/> + <WebDownload Condition="!Exists('download\$(ZipLibxml2)')" + FileName="download\$(ZipLibxml2)" + FileUri="$(LibxmlWinSite)//$(ZipLibxml2)"/> + <WebDownload Condition="!Exists('download\$(ZipLibxslt)')" + FileName="download\$(ZipLibxslt)" + FileUri="$(LibxmlWinSite)//$(ZipLibxslt)"/> + + <Unzip ZipFileName="download\$(ZipZlib)" TargetDirectory="download"/> + <Unzip ZipFileName="download\$(ZipIconv)" TargetDirectory="download"/> + <Unzip ZipFileName="download\$(ZipLibxml2)" TargetDirectory="download"/> + <Unzip ZipFileName="download\$(ZipLibxslt)" TargetDirectory="download"/> + + <ItemGroup> + <BinFiles Include="download\*.win32\bin\*"/> + <LibFiles Include="download\*.win32\lib\*"/> + <IncludeFiles Include="download\*.win32\include\*"/> + <IncludeFilesLibxml Include="download\*.win32\include\libxml\*"/> + <IncludeFilesLibxslt Include="download\*.win32\include\libxslt\*"/> + <IncludeFilesLibexslt Include="download\*.win32\include\libexslt\*"/> + </ItemGroup> + <Copy SkipUnchangedFiles="true" SourceFiles="@(BinFiles)" DestinationFolder="bin"/> + <Copy SkipUnchangedFiles="true" SourceFiles="@(LibFiles)" DestinationFolder="lib"/> + <Copy SkipUnchangedFiles="true" SourceFiles="@(IncludeFiles)" DestinationFolder="include"/> + <Copy SkipUnchangedFiles="true" SourceFiles="@(IncludeFilesLibxml)" DestinationFolder="include\libxml"/> + <Copy SkipUnchangedFiles="true" SourceFiles="@(IncludeFilesLibxslt)" DestinationFolder="include\libxslt"/> + <Copy SkipUnchangedFiles="true" SourceFiles="@(IncludeFilesLibexslt)" DestinationFolder="include\libexslt"/> + </Target> + + <Target Name="Clean"> + <RemoveDir Directories="download;bin;include;lib;Debug;Release"/> + </Target> +</Project> Modified: trunk/platform/Win32/xmlwrapp.bkl =================================================================== --- trunk/platform/Win32/xmlwrapp.bkl 2010-04-10 08:39:59 UTC (rev 181) +++ trunk/platform/Win32/xmlwrapp.bkl 2010-04-19 12:42:00 UTC (rev 182) @@ -7,6 +7,7 @@ <template id="xmlwrapp_lib" template="simple"> <include>../../include</include> + <include>include</include> </template> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <vac...@us...> - 2010-04-10 08:40:05
|
Revision: 181 http://xmlwrapp.svn.sourceforge.net/xmlwrapp/?rev=181&view=rev Author: vaclavslavik Date: 2010-04-10 08:39:59 +0000 (Sat, 10 Apr 2010) Log Message: ----------- Better error reporting when input file doesn't exist. Previously, tree_parser would return a generic "unknown XML parsing error" message if it failed because the specific XML file didn't exist or otherwise couldn't be read. We now treat this all too common special case specially and emit clear diagnostics. Modified Paths: -------------- trunk/NEWS trunk/src/libxml/tree_parser.cxx trunk/tests/tree/test_tree.cxx Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2010-04-10 08:39:38 UTC (rev 180) +++ trunk/NEWS 2010-04-10 08:39:59 UTC (rev 181) @@ -10,6 +10,8 @@ Added xml::node::clear() method. + Better error reporting when xml::tree_parser input file doesn't exist. + Version 0.6.2 Fixed xml::tree_parser to fail on non-fatal parser errors. Modified: trunk/src/libxml/tree_parser.cxx =================================================================== --- trunk/src/libxml/tree_parser.cxx 2010-04-10 08:39:38 UTC (rev 180) +++ trunk/src/libxml/tree_parser.cxx 2010-04-10 08:39:59 UTC (rev 181) @@ -45,6 +45,7 @@ // standard includes #include <stdexcept> #include <cstring> +#include <cstdio> #include <string> #include <memory> @@ -156,6 +157,25 @@ } else { + if ( pimpl_->last_error_ == DEFAULT_ERROR ) + { + // Try to describe the problem better. A common issue is that + // a file couldn't be found, in which case "unknown XML parsing + // error" is more than unhelpful. + FILE *test = fopen(name, "r"); + if ( !test ) + { + pimpl_->last_error_ = "failed to open file \""; + pimpl_->last_error_ += name; + pimpl_->last_error_ += "\""; + } + else + { + // no such luck, the error is something else + fclose(test); + } + } + // a problem appeared if (tmpdoc) xmlFreeDoc(tmpdoc); Modified: trunk/tests/tree/test_tree.cxx =================================================================== --- trunk/tests/tree/test_tree.cxx 2010-04-10 08:39:38 UTC (rev 180) +++ trunk/tests/tree/test_tree.cxx 2010-04-10 08:39:59 UTC (rev 181) @@ -144,6 +144,8 @@ BOOST_AUTO_TEST_CASE( nonexistent_file ) { xml::tree_parser parser("doesnt_exist.xml", false); + BOOST_CHECK_EQUAL( parser.get_error_message(), + "failed to open file \"doesnt_exist.xml\"" ); BOOST_CHECK( !parser ); // failed } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <vac...@us...> - 2010-04-10 08:39:45
|
Revision: 180 http://xmlwrapp.svn.sourceforge.net/xmlwrapp/?rev=180&view=rev Author: vaclavslavik Date: 2010-04-10 08:39:38 +0000 (Sat, 10 Apr 2010) Log Message: ----------- Fix error handling in tree_parser without exceptions. If libxml2 returned NULL document without errors (e.g. because a missing file is just a warning in it), pimpl_->okay_ was left as true. This was not only clearly wrong, but also inconsistent with exceptions handling: if exceptions were allowed, an exception _would_ be thrown in this situation. Modified Paths: -------------- trunk/src/libxml/tree_parser.cxx trunk/tests/tree/test_tree.cxx Modified: trunk/src/libxml/tree_parser.cxx =================================================================== --- trunk/src/libxml/tree_parser.cxx 2010-04-10 08:39:16 UTC (rev 179) +++ trunk/src/libxml/tree_parser.cxx 2010-04-10 08:39:38 UTC (rev 180) @@ -160,6 +160,8 @@ if (tmpdoc) xmlFreeDoc(tmpdoc); + pimpl_->okay_ = false; + if (allow_exceptions) throw xml::exception(pimpl_->last_error_); } @@ -192,6 +194,7 @@ ctxt->myDoc = 0; ctxt->sax = 0; xmlFreeParserCtxt(ctxt); + pimpl_->okay_ = false; if (allow_exceptions) Modified: trunk/tests/tree/test_tree.cxx =================================================================== --- trunk/tests/tree/test_tree.cxx 2010-04-10 08:39:16 UTC (rev 179) +++ trunk/tests/tree/test_tree.cxx 2010-04-10 08:39:38 UTC (rev 180) @@ -140,6 +140,23 @@ } +// test reporting of nonexistent files +BOOST_AUTO_TEST_CASE( nonexistent_file ) +{ + xml::tree_parser parser("doesnt_exist.xml", false); + BOOST_CHECK( !parser ); // failed +} + +BOOST_AUTO_TEST_CASE( nonexistent_file_throw ) +{ + BOOST_CHECK_THROW + ( + xml::tree_parser parser("doesnt_exist.xml"), + xml::exception + ); +} + + /* * this test should print out an outline of the input xml doc */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <vac...@us...> - 2010-04-10 08:39:22
|
Revision: 179 http://xmlwrapp.svn.sourceforge.net/xmlwrapp/?rev=179&view=rev Author: vaclavslavik Date: 2010-04-10 08:39:16 +0000 (Sat, 10 Apr 2010) Log Message: ----------- Test that xml::exception is thrown, not just any std::exception. Modified Paths: -------------- trunk/tests/document/test_document.cxx trunk/tests/tree/test_tree.cxx trunk/tests/xslt/test_xslt.cxx Modified: trunk/tests/document/test_document.cxx =================================================================== --- trunk/tests/document/test_document.cxx 2010-03-17 12:26:33 UTC (rev 178) +++ trunk/tests/document/test_document.cxx 2010-04-10 08:39:16 UTC (rev 179) @@ -305,19 +305,19 @@ BOOST_CHECK_THROW ( doc.push_back(xml::node("noway")), - std::exception + xml::exception ); BOOST_CHECK_THROW ( doc.insert(xml::node("noway")), - std::exception + xml::exception ); BOOST_CHECK_THROW ( doc.insert(doc.end(), xml::node("noway")), - std::exception + xml::exception ); } @@ -349,13 +349,13 @@ BOOST_CHECK_THROW ( doc.replace(n, xml::node("noway")), - std::exception + xml::exception ); BOOST_CHECK_THROW ( doc.replace(doc.begin(), xml::node(xml::node::comment(" no way "))), - std::exception + xml::exception ); } @@ -388,7 +388,7 @@ BOOST_CHECK_THROW ( doc.erase(doc.begin(), doc.end()), - std::exception + xml::exception ); } Modified: trunk/tests/tree/test_tree.cxx =================================================================== --- trunk/tests/tree/test_tree.cxx 2010-03-17 12:26:33 UTC (rev 178) +++ trunk/tests/tree/test_tree.cxx 2010-04-10 08:39:16 UTC (rev 179) @@ -108,7 +108,7 @@ BOOST_CHECK_THROW ( xml::tree_parser parser(test_file_path("tree/data/bad.xml").c_str()), - std::exception + xml::exception ); } @@ -135,7 +135,7 @@ BOOST_CHECK_THROW ( xml::tree_parser parser(XMLDATA_BAD.c_str(), XMLDATA_BAD.size()), - std::exception + xml::exception ); } @@ -203,7 +203,7 @@ BOOST_CHECK_THROW ( xml::tree_parser parser( XMLDATA_BAD_NS.c_str(), XMLDATA_BAD_NS.size()), - std::exception + xml::exception ); } Modified: trunk/tests/xslt/test_xslt.cxx =================================================================== --- trunk/tests/xslt/test_xslt.cxx 2010-03-17 12:26:33 UTC (rev 178) +++ trunk/tests/xslt/test_xslt.cxx 2010-04-10 08:39:16 UTC (rev 179) @@ -47,7 +47,7 @@ BOOST_CHECK_THROW ( xslt::stylesheet style1(test_file_path("xslt/data/01a.xsl").c_str()), - std::exception + xml::exception ); } @@ -61,7 +61,7 @@ BOOST_CHECK_THROW ( xslt::stylesheet style1(test_file_path("xslt/data/01c.xsl").c_str()), - std::exception + xml::exception ); } @@ -152,7 +152,7 @@ BOOST_CHECK_THROW ( style.apply(parser.get_document()), - std::exception + xml::exception ); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <vac...@us...> - 2010-03-17 12:26:48
|
Revision: 178 http://xmlwrapp.svn.sourceforge.net/xmlwrapp/?rev=178&view=rev Author: vaclavslavik Date: 2010-03-17 12:26:33 +0000 (Wed, 17 Mar 2010) Log Message: ----------- Add xml::node::clear(). Modified Paths: -------------- trunk/NEWS trunk/include/xmlwrapp/node.h trunk/src/libxml/node.cxx trunk/tests/node/test_node.cxx Added Paths: ----------- trunk/tests/node/data/04c.out Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2010-03-11 15:30:57 UTC (rev 177) +++ trunk/NEWS 2010-03-17 12:26:33 UTC (rev 178) @@ -8,6 +8,8 @@ Fixed compilation with Sun Studio compiler. + Added xml::node::clear() method. + Version 0.6.2 Fixed xml::tree_parser to fail on non-fatal parser errors. Modified: trunk/include/xmlwrapp/node.h =================================================================== --- trunk/include/xmlwrapp/node.h 2010-03-11 15:30:57 UTC (rev 177) +++ trunk/include/xmlwrapp/node.h 2010-03-17 12:26:33 UTC (rev 178) @@ -778,6 +778,13 @@ size_type erase(const char *name); /** + Erases all children nodes. + + @since 0.7.0 + */ + void clear(); + + /** Sort all the children nodes of this node using one of thier attributes. Only nodes that are of xml::node::type_element will be sorted, and they must have the given node_name. Modified: trunk/src/libxml/node.cxx =================================================================== --- trunk/src/libxml/node.cxx 2010-03-11 15:30:57 UTC (rev 177) +++ trunk/src/libxml/node.cxx 2010-03-17 12:26:33 UTC (rev 178) @@ -700,6 +700,19 @@ } +void node::clear() +{ + xmlNodePtr n = pimpl_->xmlnode_; + + if ( !n->children ) + return; + + xmlFreeNodeList(n->children); + n->children = + n->last = NULL; +} + + void node::sort(const char *node_name, const char *attr_name) { xmlNodePtr i(pimpl_->xmlnode_->children), next(0); Added: trunk/tests/node/data/04c.out =================================================================== --- trunk/tests/node/data/04c.out (rev 0) +++ trunk/tests/node/data/04c.out 2010-03-17 12:26:33 UTC (rev 178) @@ -0,0 +1,2 @@ +<?xml version="1.0"?> +<root/> Modified: trunk/tests/node/test_node.cxx =================================================================== --- trunk/tests/node/test_node.cxx 2010-03-11 15:30:57 UTC (rev 177) +++ trunk/tests/node/test_node.cxx 2010-03-17 12:26:33 UTC (rev 178) @@ -329,6 +329,21 @@ } +BOOST_AUTO_TEST_CASE( clear ) +{ + xml::tree_parser parser(test_file_path("node/data/04.xml").c_str()); + + xml::node &root = parser.get_document().get_root_node(); + + BOOST_REQUIRE( root.size() > 0 ); + + root.clear(); + + BOOST_CHECK( root.empty() ); + BOOST_CHECK( is_same_as_file(root, "node/data/04c.out") ); +} + + /* * These tests check xml::node::insert() */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <vac...@us...> - 2010-03-11 15:31:05
|
Revision: 177 http://xmlwrapp.svn.sourceforge.net/xmlwrapp/?rev=177&view=rev Author: vaclavslavik Date: 2010-03-11 15:30:57 +0000 (Thu, 11 Mar 2010) Log Message: ----------- Add test for xml::node::set_text_content(). Modified Paths: -------------- trunk/tests/node/test_node.cxx Modified: trunk/tests/node/test_node.cxx =================================================================== --- trunk/tests/node/test_node.cxx 2010-03-11 15:30:14 UTC (rev 176) +++ trunk/tests/node/test_node.cxx 2010-03-11 15:30:57 UTC (rev 177) @@ -612,4 +612,14 @@ } +BOOST_AUTO_TEST_CASE( escape_set_text_content ) +{ + xml::node n("root"); + n.set_text_content("Marlow & Sons"); + + BOOST_CHECK_EQUAL( n.get_content(), "Marlow & Sons" ); + BOOST_CHECK( is_same_as_file(n, "node/data/special_chars.xml") ); +} + + BOOST_AUTO_TEST_SUITE_END() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <vac...@us...> - 2010-03-11 15:30:20
|
Revision: 176 http://xmlwrapp.svn.sourceforge.net/xmlwrapp/?rev=176&view=rev Author: vaclavslavik Date: 2010-03-11 15:30:14 +0000 (Thu, 11 Mar 2010) Log Message: ----------- Add xml::node::set_text_content(). Unlike set_content(), this method expects unescaped text and escapes it properly itself. Modified Paths: -------------- trunk/NEWS trunk/include/xmlwrapp/node.h trunk/src/libxml/node.cxx Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2010-03-11 15:29:43 UTC (rev 175) +++ trunk/NEWS 2010-03-11 15:30:14 UTC (rev 176) @@ -1,4 +1,7 @@ + Added xml::node::set_text_content() for setting unescaped textual + content. + Added xml::exception class, derived from std::runtime_error. Xmlwrapp will throw only this or derived exception, with the exception of std::bad_alloc(), which is still thrown when appropriate. Modified: trunk/include/xmlwrapp/node.h =================================================================== --- trunk/include/xmlwrapp/node.h 2010-03-11 15:29:43 UTC (rev 175) +++ trunk/include/xmlwrapp/node.h 2010-03-11 15:30:14 UTC (rev 176) @@ -287,11 +287,32 @@ entity references, but XML special chars need to be escaped first. In particular, the '&' character @em must be escaped as "&" unless it's part of entity reference. Not escaping - @a content may result in truncation of data. + @a content may result in truncation of data. Use + set_text_content() if @a content may contain special characters. + + @see set_text_content() */ void set_content(const char *content); /** + Set the content of a node to given text. + + In contrast to set_content(), @a content is raw text, so unescaped XML + special chars are allowed and entity references are not supported. + + If this node is an element node, this function will remove all of its + children nodes and replace them with one text node set to the given + string. + + @param content The content text. + + @see set_content() + + @since 0.7.0 + */ + void set_text_content(const char *content); + + /** Get the content for this text node. If this node is not a text node but it has children nodes that are text nodes, the contents of those child nodes will be returned. If there is no content or these Modified: trunk/src/libxml/node.cxx =================================================================== --- trunk/src/libxml/node.cxx 2010-03-11 15:29:43 UTC (rev 175) +++ trunk/src/libxml/node.cxx 2010-03-11 15:30:14 UTC (rev 176) @@ -436,6 +436,16 @@ } +void node::set_text_content(const char *content) +{ + xmlChar *escaped = xmlEncodeSpecialChars(pimpl_->xmlnode_->doc, + reinterpret_cast<const xmlChar*>(content)); + xmlNodeSetContent(pimpl_->xmlnode_, escaped); + if ( escaped ) + xmlFree(escaped); +} + + const char* node::get_content() const { xmlchar_helper content(xmlNodeGetContent(pimpl_->xmlnode_)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |