You can subscribe to this list here.
2004 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(622) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2005 |
Jan
(303) |
Feb
(64) |
Mar
(5) |
Apr
(63) |
May
(82) |
Jun
(53) |
Jul
(50) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Christian P. <cp...@us...> - 2005-04-28 10:34:15
|
Update of /cvsroot/pclasses/pclasses2/include/pclasses/App In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2766/include/pclasses/App Modified Files: LogChannel.h Log Message: - Some small fixes for the logging framework Index: LogChannel.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/App/LogChannel.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- LogChannel.h 24 Apr 2005 11:36:31 -0000 1.2 +++ LogChannel.h 28 Apr 2005 10:34:06 -0000 1.3 @@ -40,9 +40,11 @@ public: typedef std::map<std::string, LogTarget*> TargetMap; - LogChannel(); + LogChannel(const std::string& name); ~LogChannel() throw(); + const std::string& name() const; + //! Add a logging target bool addTarget(const std::string& name, LogTarget* target); @@ -69,6 +71,7 @@ LogChannel& operator()(LogMessage::Level) throw(); private: + std::string _name; TargetMap _targets; LogMessage::Level _logLevel; }; |
From: Christian P. <cp...@us...> - 2005-04-28 10:24:08
|
Update of /cvsroot/pclasses/pclasses2/src/System In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30213/src/System Modified Files: SignalListener.h SignalListener.posix.cpp Log Message: - Restore previous signal handlers Index: SignalListener.posix.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/System/SignalListener.posix.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- SignalListener.posix.cpp 25 Apr 2005 10:57:31 -0000 1.5 +++ SignalListener.posix.cpp 28 Apr 2005 10:23:57 -0000 1.6 @@ -18,6 +18,7 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ +#include "pclasses/Trace.h" #include "pclasses/System/EventQueue.h" #include "pclasses/CircularQueue.h" #include "SignalListener.h" @@ -138,6 +139,8 @@ qs = _signals.front(); _signals.pop(); + P_TRACE(SignalFdListener) << "Dispatching signal sig=" << qs.sig; + if(_listeners[qs.sig]) _listeners[qs.sig]->onSignal(qs.val); } @@ -179,29 +182,29 @@ } SignalListener::SignalListener(int sig) +: _sig(sig) { - setup(sig); -} + P_TRACE(SignalListener) << "Installing signal handler for sig=" << sig; + + struct sigaction sa; + sa.sa_sigaction = &signal_handler; + sigfillset(&sa.sa_mask); // block all signals during signal handler's execution + sa.sa_flags = SA_RESTART|SA_SIGINFO; // restart system calls, use 3 param sighandler -SignalListener::~SignalListener() -{ SignalFdListener& l = SignalFdListener::instance(); - l.removeListener(*this); + l.addListener(_sig, *this); - //TODO: restore previous signal handler ... + sigaction(_sig, &sa, &savedSigActions[_sig]); } -void SignalListener::setup(int sig) +SignalListener::~SignalListener() { - struct sigaction sa; - sa.sa_sigaction = &signal_handler; - sigfillset(&sa.sa_mask); // block all signals during signal handler's execution - sa.sa_flags = SA_RESTART|SA_SIGINFO; // restart system calls, use 3 param sighandler + P_TRACE(SignalListener) << "Destroying signal handler for sig=" << _sig; SignalFdListener& l = SignalFdListener::instance(); - l.addListener(sig, *this); + l.removeListener(*this); - sigaction(sig, &sa, &savedSigActions[sig]); + sigaction(_sig, &savedSigActions[_sig], 0); } } //! namespace System Index: SignalListener.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/System/SignalListener.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- SignalListener.h 23 Apr 2005 17:48:03 -0000 1.2 +++ SignalListener.h 28 Apr 2005 10:23:57 -0000 1.3 @@ -37,7 +37,7 @@ virtual void onSignal(const sigval& sv) = 0; private: - void setup(int sig); + int _sig; }; } // !namespace System |
From: Christian P. <cp...@us...> - 2005-04-28 10:21:53
|
Update of /cvsroot/pclasses/pclasses2/include/pclasses/System In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29121/include/pclasses/System Modified Files: PathFinder.h Log Message: - Use StringList implementation Index: PathFinder.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/System/PathFinder.h,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- PathFinder.h 23 Apr 2005 15:19:31 -0000 1.6 +++ PathFinder.h 28 Apr 2005 10:21:43 -0000 1.7 @@ -9,9 +9,8 @@ // implementation as it may be useful for other too. -- cproch #include <pclasses/Export.h> - -#include <string> -#include <list> +#include <pclasses/StringList.h> +#include <pclasses/Unicode/String.h> #include <map> namespace P { @@ -49,13 +48,15 @@ /** A list type returned by some functions. */ - typedef std::list<std::string> string_list; + typedef StringList<Unicode::String> string_list; + + PathFinder(); /** Creates object with the given path/extension list. */ - PathFinder(const std::string & path = std::string(), - const std::string & ext = std::string()); + PathFinder(const Unicode::String& path, + const Unicode::String& ext); virtual ~PathFinder(); @@ -63,24 +64,24 @@ Returns a pathSeparator()-delimited string of all paths added via add/path(). */ - std::string pathString() const; + Unicode::String pathString() const; /** Sets the path to p, which should be a pathSeparator()-delimited string. Returns the number of path elements parsed from p. */ - virtual size_t path( const std::string & p ); + virtual size_t path(const Unicode::String& p); /** Sets the path to the given list of directories. Returns the number of elements in the list. */ - virtual size_t path( const string_list & p ); + virtual size_t path(const string_list& p); /** Adds p to the path. May be path_separtor()-delimited. */ - virtual void addPath( const std::string & p ); + virtual void addPath(const Unicode::String& p); /** Adds a "search extension." Sample: @@ -92,25 +93,25 @@ and those with non-traditional extensions, like "foo_EXT". */ - virtual void addExtension( const std::string & ext = std::string() ); + virtual void addExtension(const Unicode::String& ext); /** like addExtension(), but overwrites extension list. Returns the number of entries parsed from the string. */ - virtual size_t extensions( const std::string & ext ); + virtual size_t extensions(const Unicode::String& ext); /** Sets the extensions list to the given list. Returns the number of entries in p. */ - virtual size_t extensions( const string_list & p ); + virtual size_t extensions(const string_list& p); /** Returns the pathSeparator()-delimited listed of file suffixes to use when searching for a path. */ - std::string extensionsString() const; + Unicode::String extensionsString() const; /** Returns this object's extensions list. @@ -120,25 +121,25 @@ /** Returns true if path is readable. */ - static bool isAccessible( const std::string & path ); + static bool isAccessible(const Unicode::String& path); /** Returns the "base name" of the given string: any part following the final directory separator character. */ - static std::string basename( const std::string & ); + static Unicode::String basename(const Unicode::String &); /** Returns a platform-dependent directory separator. This is set when the class is compiled. */ - static std::string dirSeparator(); + static Unicode::String dirSeparator(); /** Returns a platform-dependent path-list separator string. This is set when the class is compiled. */ - static std::string pathSeparator(); + static Unicode::String pathSeparator(); /** Returns the full path of the given resource, provided it could be found @@ -153,7 +154,8 @@ uses a cache. When caching it will always return the same result for any given resourcename. */ - std::string find( const std::string & resourcename, bool check_cache = true ) const; + const Unicode::String& find(const Unicode::String& resourcename, + bool check_cache = true) const; /** Empties the hit-cache used by find(). @@ -169,11 +171,11 @@ const string_list & path() const; private: - string_list paths; - string_list exts; - typedef std::map < std::string, std::string > StringStringMap; - typedef StringStringMap::iterator StringStringIterator; - mutable StringStringMap hitcache; + string_list _paths; + string_list _exts; + + typedef std::map<Unicode::String, Unicode::String> StringStringMap; + mutable StringStringMap _hitcache; }; } // !namespace System |
From: Christian P. <cp...@us...> - 2005-04-28 10:21:53
|
Update of /cvsroot/pclasses/pclasses2/src/System In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29121/src/System Modified Files: PathFinder.cpp Log Message: - Use StringList implementation Index: PathFinder.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/System/PathFinder.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- PathFinder.cpp 25 Apr 2005 10:57:31 -0000 1.5 +++ PathFinder.cpp 28 Apr 2005 10:21:44 -0000 1.6 @@ -14,136 +14,85 @@ # include <unistd.h> #endif +#include "pclasses/Trace.h" #include "pclasses/System/PathFinder.h" -// CERR is a drop-in replacement for std::cerr, but slightly more -// decorative. - -#ifndef CERR -#define CERR std::cerr << __FILE__ << ":" << std::dec << __LINE__ << " : " -#endif - -using std::string; -using std::ostream; - namespace P { namespace System { - -PathFinder::~PathFinder() +PathFinder::PathFinder() { } -PathFinder::PathFinder(const string & p, const string & e) +PathFinder::PathFinder(const Unicode::String& p, const Unicode::String& e) { - this->path( p ); - this->extensions( e ); + path(p); + extensions(e); } -/** - Internal helper function to collapse a list into a string. - cproch: Modified code to use a ostringstream. Appending to strings is really slow. -*/ -template <typename StringList> -std::string joinList( const StringList & list, const std::string & separator ) +PathFinder::~PathFinder() { - std::ostringstream ret; - - typename StringList::const_iterator it = list.begin(); - while(it != list.end()) - { - ret << (*it); - ++it; - if(it != list.end()) - ret << separator; - } - - return ret.str(); } -string PathFinder::pathString() const +Unicode::String PathFinder::pathString() const { - return joinList( this->paths, pathSeparator() ); + return _paths.join(pathSeparator()); } -const PathFinder::string_list & PathFinder::path() const +const PathFinder::string_list& PathFinder::path() const { - return this->paths; + return _paths; } -string PathFinder::extensionsString() const +Unicode::String PathFinder::extensionsString() const { - return joinList( this->exts, pathSeparator()); + return _exts.join(pathSeparator()); } -const PathFinder::string_list & PathFinder::extensions() const +const PathFinder::string_list& PathFinder::extensions() const { - return this->exts; -} - -size_t tokenize_to_list( const std::string & str, std::list<std::string> & li, const std::string & sep ) -{ // internal helper function - if( str.empty() ) return 0; - - size_t c = 0; - - std::string token; - std::string::size_type sz = str.size(); - - for( std::string::size_type i = 0; i < sz; i++ ) - { - if( sz-1 == i ) token += str[i]; - if( str.find( sep, i ) == i || (sz-1 == i) ) - { - //CERR << "token="<<token<<std::endl; - li.push_back( token ); - token = ""; - i += sep.size() - 1; - continue; - } - token += str[i]; - } - - return c; + return _exts; } -size_t PathFinder::path( const string & p ) +size_t PathFinder::path(const Unicode::String& p) { - this->paths.erase( this->paths.begin(), this->paths.end() ); - return tokenize_to_list( p, this->paths, pathSeparator() ); + _paths = string_list(p, pathSeparator()); + return _paths.size(); } -size_t PathFinder::path( const PathFinder::string_list & p ) +size_t PathFinder::path(const PathFinder::string_list& p) { - this->paths = p; - return this->paths.size(); + _paths = p; + return _paths.size(); } -void PathFinder::addPath( const string & p ) +void PathFinder::addPath(const Unicode::String& p) { - tokenize_to_list( p, this->paths, pathSeparator() ); + string_list np = string_list(p, pathSeparator()); + _paths.insert(_paths.end(), np.begin(), np.end()); } -size_t PathFinder::extensions( const string & p ) +size_t PathFinder::extensions(const Unicode::String& p) { - this->exts.erase( this->exts.begin(), this->exts.end() ); - return tokenize_to_list( p, this->exts, pathSeparator() ); + _exts = string_list(p, pathSeparator()); + return _exts.size(); } -size_t PathFinder::extensions( const PathFinder::string_list & e ) +size_t PathFinder::extensions(const PathFinder::string_list& e) { - this->exts = e; - return this->exts.size(); + _exts = e; + return _exts.size(); } -void PathFinder::addExtension( const string & p ) +void PathFinder::addExtension(const Unicode::String& e) { - tokenize_to_list( p, this->exts, pathSeparator() ); + string_list ne = string_list(e, pathSeparator()); + _exts.insert(_exts.end(), ne.begin(), ne.end()); } // static -bool PathFinder::isAccessible( const string & path ) +bool PathFinder::isAccessible(const Unicode::String & path) { #if WIN32 # define CHECKACCESS _access @@ -153,73 +102,88 @@ # define CHECKRIGHTS F_OK #endif - return 0 == CHECKACCESS( path.c_str(), CHECKRIGHTS ); + return 0 == CHECKACCESS(path.utf8().c_str(), CHECKRIGHTS); #undef CHECKACCESS #undef CHECKRIGHTS } -string PathFinder::basename( const std::string & name ) +Unicode::String PathFinder::basename(const Unicode::String& name) { - string::size_type slashat = name.find_last_of( PathFinder::dirSeparator() ); - if ( slashat == string::npos ) + Unicode::String::size_type slashat = + name.find_last_of(PathFinder::dirSeparator()); + + if(slashat == Unicode::String::npos) return name; - return name.substr( slashat + 1 ); + + return name.substr(slashat + 1); } -std::string PathFinder::dirSeparator() +Unicode::String PathFinder::dirSeparator() { #ifdef WIN32 - return std::string( "\\" ); + return Unicode::String( "\\" ); #else - return std::string( "/" ); + return Unicode::String( "/" ); #endif } -std::string PathFinder::pathSeparator() +Unicode::String PathFinder::pathSeparator() { #ifdef WIN32 - return std::string( ";" ); + return Unicode::String( ";" ); #else - return std::string( ":" ); + return Unicode::String( ":" ); #endif } - -string PathFinder::find( const string & resource, bool check_cache ) const +const Unicode::String& PathFinder::find(const Unicode::String& resource, + bool check_cache) const { - //static const std::string NOT_FOUND = "PathFinder::find() : no findie"; - if( resource.empty() ) return resource; + static Unicode::String emptyStr; + + P_TRACE(PathFinder) << "find(" << resource << ")"; + + if(resource.empty()) + return emptyStr; #define CHECKPATH(CHECKAT) \ + P_TRACE(PathFinder) << "testing '" << CHECKAT << "'"; \ if( ! CHECKAT.empty() && PathFinder::isAccessible( CHECKAT ) ) \ - { this->hitcache[resource] = CHECKAT; return CHECKAT; } + { \ + P_TRACE(PathFinder) << "found '" << CHECKAT << "'"; \ + return _hitcache.insert(std::make_pair(resource, CHECKAT)).first->second; \ + } - //CERR << "find( " << resource << " )" << std::endl; if(check_cache) { - std::map <std::string,std::string>::iterator mapiter; - mapiter = this->hitcache.find( resource ); - if( this->hitcache.end() != mapiter ) return (*mapiter).second; + P_TRACE(PathFinder) << "lookup in cache '" << resource << "'"; + StringStringMap::iterator mi = _hitcache.find(resource); + if(mi != _hitcache.end()) + { + P_TRACE(PathFinder) << "found (cached) '" << (*mi).first + << "' -> '" << (*mi).second << "'"; + return (*mi).second; + } } - CHECKPATH( resource ); - - string_list::const_iterator piter = this->paths.begin(); - string_list::const_iterator eiter = this->exts.begin(); + CHECKPATH(resource); - string path; - string ext; + string_list::const_iterator piter = _paths.begin(); + string_list::const_iterator eiter = _exts.begin(); - if ( PathFinder::isAccessible( resource ) ) + if(PathFinder::isAccessible(resource)) + { + P_TRACE(PathFinder) << "found '" << resource << "'"; return resource; + } - piter = this->paths.begin(); - string checkhere; + Unicode::String path, ext; + Unicode::String checkhere; - while ( piter != this->paths.end() ) + while(piter != _paths.end()) { - path = ( *piter ); - if ( !path.empty() ) + path = (*piter); + if(!path.empty()) { path += PathFinder::dirSeparator(); } @@ -227,29 +191,23 @@ ++piter; checkhere = path + resource; - //CERR << "find( " << resource << " ) checking " << checkhere << std::endl; - CHECKPATH( checkhere ); + CHECKPATH(checkhere); - eiter = this->exts.begin(); - while ( eiter != this->exts.end() ) + eiter = _exts.begin(); + while(eiter != _exts.end()) { - ext = ( *eiter ); - ++eiter; + ext = (*eiter++); checkhere = path + resource + ext; - //CERR << "find( " << resource << " ) checking " << checkhere << std::endl; - CHECKPATH( checkhere ); + CHECKPATH(checkhere); } } - //CERR << "find( "<<resource<<" ): not found :(" << std::endl; - // so arguable: - // this->hitcache[resource] = ""; - return string(); + return emptyStr; } void PathFinder::clearCache() { - this->hitcache.clear(); + _hitcache.clear(); } // /** |
From: Christian P. <cp...@us...> - 2005-04-28 10:21:23
|
Update of /cvsroot/pclasses/pclasses2/src/Unicode In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28735/src/Unicode Modified Files: Char.cpp Log Message: - Added conversion operator to uchar_t Index: Char.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/Unicode/Char.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- Char.cpp 26 Apr 2005 12:16:02 -0000 1.4 +++ Char.cpp 28 Apr 2005 10:21:14 -0000 1.5 @@ -179,6 +179,11 @@ return (Char::CombiningClass)data->combining; } +Char::operator const uchar_t& () const throw() +{ + return _char; +} + Char& Char::operator=(uchar_t ch) { _char = ch; |
From: Christian P. <cp...@us...> - 2005-04-28 10:21:23
|
Update of /cvsroot/pclasses/pclasses2/include/pclasses/Unicode In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28735/include/pclasses/Unicode Modified Files: Char.h Log Message: - Added conversion operator to uchar_t Index: Char.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/Unicode/Char.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- Char.h 26 Apr 2005 12:16:02 -0000 1.3 +++ Char.h 28 Apr 2005 10:21:13 -0000 1.4 @@ -172,6 +172,8 @@ Decomposition decompTag() const; CombiningClass combiningClass() const; + operator const uchar_t& () const throw(); + Char& operator=(uchar_t ch); Char& operator=(const Char& ch); |
From: Christian P. <cp...@us...> - 2005-04-28 10:15:11
|
Update of /cvsroot/pclasses/pclasses2/src/Unicode In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25449/src/Unicode Modified Files: String.cpp Log Message: - Added generic StringList implementation - Added more operations to Unicode::String Index: String.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/Unicode/String.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- String.cpp 26 Apr 2005 12:16:02 -0000 1.4 +++ String.cpp 28 Apr 2005 10:15:02 -0000 1.5 @@ -64,26 +64,27 @@ std::swap(b._str, _str); } +bool String::empty() const throw() +{ + return _str.empty(); +} + size_t String::size() const throw() { return _str.size(); } String String::substr(size_t offset, size_t length) const - throw(OutOfBounds) { - if(offset + length > _str.size()) - throw OutOfBounds("Offset and/or length is out of bounds", P_SOURCEINFO); - return _str.substr(offset, length); } -String String::left(size_t length) const throw(OutOfBounds) +String String::left(size_t length) const { return substr(0, length); } -String String::right(size_t length) const throw(OutOfBounds) +String String::right(size_t length) const { return substr(_str.size() - length, length); } @@ -94,14 +95,80 @@ return *this; } -const Char& String::at(size_t pos) const throw(OutOfBounds) +String& String::append(const Char& ch) { - return operator[](pos); + _str.append(1, ch); + return *this; } -Char& String::at(size_t pos) throw(OutOfBounds) +size_t String::find(const String& str, size_t pos) const { - return operator[](pos); + return _str.find(str._str, pos); +} + +size_t String::find(const Char& ch, size_t pos) const +{ + return _str.find(ch, pos); +} + +size_t String::rfind(const String& str, size_t pos) const +{ + return _str.rfind(str._str, pos); +} + +size_t String::rfind(const Char& ch, size_t pos) const +{ + return _str.rfind(ch, pos); +} + +size_t String::find_first_of(const String& str, size_t pos) const +{ + return _str.find_first_of(str._str, pos); +} + +size_t String::find_first_of(const Char& ch, size_t pos) const +{ + return _str.find_first_of(ch, pos); +} + +size_t String::find_first_not_of(const String& str, size_t pos) const +{ + return _str.find_first_not_of(str._str, pos); +} + +size_t String::find_first_not_of(const Char& ch, size_t pos) const +{ + return _str.find_first_not_of(ch, pos); +} + +size_t String::find_last_of(const String& str, size_t pos) const +{ + return _str.find_last_of(str._str, pos); +} + +size_t String::find_last_of(const Char& ch, size_t pos) const +{ + return _str.find_last_of(ch, pos); +} + +size_t String::find_last_not_of(const String& str, size_t pos) const +{ + return _str.find_last_not_of(str._str, pos); +} + +size_t String::find_last_not_of(const Char& ch, size_t pos) const +{ + return _str.find_last_not_of(ch, pos); +} + +const Char& String::at(size_t pos) const +{ + return at(pos); +} + +Char& String::at(size_t pos) +{ + return at(pos); } std::string String::local() const @@ -119,19 +186,13 @@ return toCharset("UTF8"); } -const Char& String::operator[](size_t pos) const throw(OutOfBounds) +const Char& String::operator[](size_t pos) const { - if(pos >= _str.size()) - throw OutOfBounds("Index is out of bounds", P_SOURCEINFO); - return (Char&)_str.operator[](pos); } -Char& String::operator[](size_t pos) throw(OutOfBounds) +Char& String::operator[](size_t pos) { - if(pos >= _str.size()) - throw OutOfBounds("Index is out of bounds", P_SOURCEINFO); - return (Char&)_str.operator[](pos); } @@ -165,6 +226,12 @@ return *this; } +String& String::operator+=(const Char& ch) +{ + append(ch); + return *this; +} + bool String::operator==(const String& str) const throw() { return _str == str._str; @@ -310,6 +377,22 @@ return outstr; } +String operator+(const String& lhs, const String& rhs) +{ + return String(lhs).append(rhs); +} + +String operator+(const String& lhs, const Char& rhs) +{ + return String(lhs).append(rhs); +} + +std::ostream& operator<<(std::ostream& os, const String& str) +{ + os << str.utf8(); + return os; +} + } // !namespace Unicode |
From: Christian P. <cp...@us...> - 2005-04-28 10:15:11
|
Update of /cvsroot/pclasses/pclasses2/include/pclasses In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25449/include/pclasses Added Files: StringList.h Log Message: - Added generic StringList implementation - Added more operations to Unicode::String --- NEW FILE: StringList.h --- /*************************************************************************** * Copyright (C) 2005 by Christian Prochnow, SecuLogiX GmbH * * cp...@se... * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU Library 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 Library 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. * ***************************************************************************/ #ifndef P_StringList_h #define P_StringList_h #include <list> namespace P { //! String list template <class StringType> class StringList: public std::list<StringType> { public: typedef std::list<StringType> string_list; StringList() : string_list() { } StringList(const string_list& lst) : string_list(lst) { } StringList(const StringType& str, const StringType& separator) { *this = fromString(str, separator); } //! Join all strings into a single string StringType join(const StringType& separator) const { StringType ret; typename string_list::const_iterator i = begin(); while(i != end()) { ret += *i; ++i; if(i != end()) ret += separator; } return ret; } //! Tokenize string into list of strings static string_list fromString(const StringType& str, const StringType& separator) { if(str.empty()) return string_list(); typename StringType::size_type tokenBegin = 0; typename StringType::size_type tokenEnd; StringType token; string_list lst; while(tokenEnd != StringType::npos) { tokenEnd = str.find(separator, tokenBegin); token = str.substr(tokenBegin, tokenEnd - tokenBegin); lst.push_back(token); tokenBegin = tokenEnd + separator.size(); } return lst; } }; } // !namespace P #endif |
From: Christian P. <cp...@us...> - 2005-04-28 10:15:10
|
Update of /cvsroot/pclasses/pclasses2/include/pclasses/Unicode In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25449/include/pclasses/Unicode Modified Files: String.h Log Message: - Added generic StringList implementation - Added more operations to Unicode::String Index: String.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/Unicode/String.h,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- String.h 26 Apr 2005 12:16:02 -0000 1.4 +++ String.h 28 Apr 2005 10:15:01 -0000 1.5 @@ -40,6 +40,10 @@ npos = (size_t)-1 }; + typedef ustring::size_type size_type; + typedef ustring::const_iterator const_iterator; + typedef ustring::iterator iterator; + String(); String(const String& str); String(const ustring& str); @@ -51,21 +55,40 @@ void swap(String& b); + bool empty() const throw(); size_t size() const throw(); - const Char& at(size_t index) const throw(OutOfBounds); - Char& at(size_t index) throw(OutOfBounds); + const Char& at(size_t index) const; + Char& at(size_t index); - String substr(size_t offset = 0, size_t length = npos) const - throw(OutOfBounds); + String substr(size_t offset = 0, size_t length = npos) const; - String left(size_t length) const throw(OutOfBounds); - String right(size_t length) const throw(OutOfBounds); + String left(size_t length) const; + String right(size_t length) const; String& append(const String& str); + String& append(const Char& ch); - Char& operator[](size_t pos) throw(OutOfBounds); - const Char& operator[](size_t pos) const throw(OutOfBounds); + size_t find(const String& str, size_t pos = 0) const; + size_t find(const Char& ch, size_t pos = 0) const; + + size_t rfind(const String& str, size_t pos = npos) const; + size_t rfind(const Char& ch, size_t pos = npos) const; + + size_t find_first_of(const String& str, size_t pos = 0) const; + size_t find_first_of(const Char& ch, size_t pos = 0) const; + + size_t find_first_not_of(const String& str, size_t pos = 0) const; + size_t find_first_not_of(const Char& ch, size_t pos = 0) const; + + size_t find_last_of(const String& str, size_t pos = npos) const; + size_t find_last_of(const Char& ch, size_t pos = npos) const; + + size_t find_last_not_of(const String& str, size_t pos = npos) const; + size_t find_last_not_of(const Char& ch, size_t pos = npos) const; + + Char& operator[](size_t pos); + const Char& operator[](size_t pos) const; String& operator=(const String& str); String& operator=(const ustring& str); @@ -74,6 +97,7 @@ String& operator=(const std::string& str); String& operator+=(const String& str); + String& operator+=(const Char& ch); bool operator==(const String& str) const throw(); bool operator!=(const String& str) const throw(); @@ -110,6 +134,11 @@ ustring _str; }; +PUNICODE_EXPORT String operator+(const String& lhs, const String& rhs); +PUNICODE_EXPORT String operator+(const String& lhs, const Char& rhs); + +PUNICODE_EXPORT std::ostream& operator<<(std::ostream& os, const String& str); + } // !namespace Unicode } // !namespace P |
From: Christian P. <cp...@us...> - 2005-04-28 10:12:02
|
Update of /cvsroot/pclasses/pclasses2/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23571/src Modified Files: Trace.cpp Log Message: - Added tracing support Index: Trace.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/Trace.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- Trace.cpp 10 Jan 2005 02:48:38 -0000 1.1 +++ Trace.cpp 28 Apr 2005 10:11:36 -0000 1.2 @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2004 by Christian Prochnow * + * Copyright (C) 2005 by Christian Prochnow, SecuLogiX GmbH * * cp...@se... * * * * This program is free software; you can redistribute it and/or modify * @@ -17,3 +17,62 @@ * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ + +#include "pclasses/Trace.h" +#include <stdio.h> +#include <sstream> + +namespace P { + +TraceStream::TraceStream(TraceLog& log, const SourceInfo& si, const char* cl) +: std::ostream(new std::stringbuf()), _log(log), _src(si), _class(cl) +{ +} + +TraceStream::TraceStream(const TraceStream& strm) +: std::ostream(new std::stringbuf()), _log(strm._log), _src(strm._src), + _class(strm._class) +{ +} + +TraceStream::~TraceStream() +{ + std::stringbuf* sb = static_cast<std::stringbuf*>(rdbuf()); + _log.output(_src, _class, sb->str()); + delete sb; +} + +std::ostream& TraceStream::operator()() +{ + return *this; +} + + +TraceLog TraceLog::_trace; + +TraceLog::TraceLog() +{ +} + +TraceLog::~TraceLog() +{ +} + +TraceStream TraceLog::stream(const SourceInfo& si, const char* cl) +{ + return TraceStream(*this, si, cl); +} + +void TraceLog::output(const SourceInfo& si, const std::string& cl, + const std::string& msg) +{ + //std::cout << si.file() << ":" << si.line() << std::endl; + std::cout << cl << ": " << msg << std::endl; +} + +TraceLog& TraceLog::instance() +{ + return _trace; +} + +} |
From: Christian P. <cp...@us...> - 2005-04-28 10:12:00
|
Update of /cvsroot/pclasses/pclasses2/include/pclasses In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23571/include/pclasses Modified Files: Trace.h Log Message: - Added tracing support Index: Trace.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/Trace.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- Trace.h 10 Jan 2005 02:48:38 -0000 1.1 +++ Trace.h 28 Apr 2005 10:11:36 -0000 1.2 @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2004 by Christian Prochnow * + * Copyright (C) 2005 by Christian Prochnow, SecuLogiX GmbH * * cp...@se... * * * * This program is free software; you can redistribute it and/or modify * @@ -21,8 +21,94 @@ #ifndef P_Trace_h #define P_Trace_h +#include <pclasses/pclasses-config.h> +#include <pclasses/Export.h> +#include <pclasses/SourceInfo.h> +#include <pclasses/IntTypes.h> + +#include <string> +#include <iostream> + namespace P { +class TraceLog; + +class PCORE_EXPORT TraceStream: + private std::ostream +{ + public: + TraceStream(TraceLog& log, const SourceInfo& si, const char* cl); + TraceStream(const TraceStream&); + ~TraceStream(); + + std::ostream& operator()(); + + private: + TraceLog& _log; + SourceInfo _src; + std::string _class; +}; + +class PCORE_EXPORT TraceLog { + public: + TraceStream stream(const SourceInfo& si, const char* cl); + + void output(const SourceInfo& si, const std::string& cl, + const std::string& msg); + + static TraceLog& instance(); + + private: + TraceLog(); + ~TraceLog(); + + static TraceLog _trace; +}; + +class NullTraceStream { + public: + inline NullTraceStream& operator()(const SourceInfo& si) + { return *this; } + + inline NullTraceStream& operator<<(char ch) + { return *this; } + + inline NullTraceStream& operator<<(const char* str) + { return *this; } + + inline NullTraceStream& operator<<(int16_t val) + { return *this; } + + inline NullTraceStream& operator<<(uint16_t val) + { return *this; } + + inline NullTraceStream& operator<<(int32_t val) + { return *this; } + + inline NullTraceStream& operator<<(uint32_t val) + { return *this; } + + #ifdef PCLASSES_HAVE_64BIT_INT + inline NullTraceStream& operator<<(int64_t val) + { return *this; } + + inline NullTraceStream& operator<<(uint64_t val) + { return *this; } + #endif + + inline NullTraceStream& operator<<(const void* ptr) + { return *this; } + + inline NullTraceStream& operator<<(const std::string& str) + { return *this; } + +}; + +#if defined(_DEBUG) && !defined(NO_DEBUG) +# define P_TRACE(c) NullTraceStream() +#else +# define P_TRACE(c) P::TraceLog::instance().stream(P_SOURCEINFO,#c)() +#endif } // !namespace P |
From: Christian P. <cp...@us...> - 2005-04-26 12:21:01
|
Update of /cvsroot/pclasses/pclasses2/src/XML In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28701/src/XML Modified Files: Makefile.am Log Message: - Added $EXPAT_LIBS to Makefile.am Index: Makefile.am =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/XML/Makefile.am,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- Makefile.am 17 Jan 2005 22:50:41 -0000 1.4 +++ Makefile.am 26 Apr 2005 12:20:46 -0000 1.5 @@ -5,6 +5,7 @@ CPPFLAGS = -DPXML_BUILD +libpclasses_xml_la_CFLAGS = $(EXPAT_CFLAGS) libpclasses_xml_la_SOURCES = XMLParseError.cpp XMLPushParser.expat.cpp # Christian: please commit this file and re-add to Makefile.am: @@ -13,4 +14,4 @@ libpclasses_xml_la_LDFLAGS = -no-undefined libpclasses_xml_la_LIBADD = $(top_builddir)/src/libpclasses.la \ - $(top_builddir)/src/System/libpclasses_system.la -lexpat + $(top_builddir)/src/System/libpclasses_system.la $(EXPAT_LIBS) |
From: Christian P. <cp...@us...> - 2005-04-26 12:20:32
|
Update of /cvsroot/pclasses/pclasses2/include/pclasses/Util In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28319/include/pclasses/Util Modified Files: StringTool.h Log Message: - Fixed export macros - Fixed StringDevice Index: StringTool.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/Util/StringTool.h,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- StringTool.h 10 Jan 2005 12:58:05 -0000 1.7 +++ StringTool.h 26 Apr 2005 12:19:56 -0000 1.8 @@ -3,6 +3,8 @@ #include <string> #include <map> + +#include <pclasses/Export.h> #include <pclasses/Phoenix.h> #include <pclasses/Util/LexT.h> @@ -354,31 +356,31 @@ //! Strip leading white-speaces -void trimLeft(std::string& str); +PUTIL_EXPORT void trimLeft(std::string& str); //! Strip trailing white-spaces -void trimRight(std::string& str); +PUTIL_EXPORT void trimRight(std::string& str); //! Strip leading and trailing white-spaces -void trim(std::string& str); +PUTIL_EXPORT void trim(std::string& str); //! Returns the string converted to uppercase letters -std::string upperCase(const std::string& str); +PUTIL_EXPORT std::string upperCase(const std::string& str); //! Returns the string converted to uppercase letters /*! Uses the given locale to do the conversion. */ -std::string upperCase(const std::string& str, const std::locale& loc); +PUTIL_EXPORT std::string upperCase(const std::string& str, const std::locale& loc); //! Returns the string converted to lowercase letters -std::string lowerCase(const std::string& str); +PUTIL_EXPORT std::string lowerCase(const std::string& str); //! Returns the string converted to lowercase letters /*! Uses the given locale to do the conversion. */ -std::string lowerCase(const std::string& str, const std::locale& loc); +PUTIL_EXPORT std::string lowerCase(const std::string& str, const std::locale& loc); }} // namespace P::StringTool |
From: Christian P. <cp...@us...> - 2005-04-26 12:20:28
|
Update of /cvsroot/pclasses/pclasses2/src/IO In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28319/src/IO Modified Files: StringDevice.cpp Log Message: - Fixed export macros - Fixed StringDevice Index: StringDevice.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/IO/StringDevice.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- StringDevice.cpp 1 Jan 2005 19:24:27 -0000 1.1 +++ StringDevice.cpp 26 Apr 2005 12:19:55 -0000 1.2 @@ -8,13 +8,14 @@ StringDevice::peek(char *buffer, size_t count) throw (IOError) { size_t at = this->getPos(); - size_t to = ( (count + at) > this->size() ) + size_t to = ((count + at) > (size_t)this->size() ) ? this->size() : at + count; size_t ret = 0; for( ; at < to; at++ ) { - buffer[ret++] = this->m_buf.at(at).latin1(); + memcpy(buffer + ret, &this->m_buf.at(at), sizeof(Unicode::Char)); + ret += sizeof(Unicode::Char); } return ret; } |
From: Christian P. <cp...@us...> - 2005-04-26 12:16:21
|
Update of /cvsroot/pclasses/pclasses2/src/Unicode In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26729/src/Unicode Modified Files: Char.cpp Makefile.am String.cpp uctype.cpp ustring.cpp Log Message: - More work on unicode support Index: String.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/Unicode/String.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- String.cpp 27 Dec 2004 07:00:31 -0000 1.3 +++ String.cpp 26 Apr 2005 12:16:02 -0000 1.4 @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2004 by Christian Prochnow * + * Copyright (C) 2004,2005 by Christian Prochnow, SecuLogiX GmbH * * cp...@se... * * * * This program is free software; you can redistribute it and/or modify * @@ -19,50 +19,40 @@ ***************************************************************************/ #include "pclasses/Unicode/String.h" -#include "pclasses/ScopedPtr.h" -#include "pclasses/ScopedArrayPtr.h" -#include "pclasses/Algorithm.h" #include <cstring> #include <sstream> +#include <iconv.h> +#include <errno.h> +#include <langinfo.h> + namespace P { namespace Unicode { -String::String(size_t reserve) throw(OutOfMemory) -: _offset(0), _length(0) -{ - ScopedPtr<Data> d(new Data); - d->str = (Char*)new char[sizeof(Char) * reserve]; - d->size = reserve; - _data = d.release(); -} - -String::String(const String& str) throw(OutOfMemory) -: _offset(str._offset), _length(str._length), _data(str._data) +String::String() { } -String::String(const char* str, size_t count) throw(OutOfMemory) +String::String(const String& str) +: _str(str._str) { - *this = fromLatin1(str, count); } -String::String(const wchar_t* str, size_t count) throw(OutOfMemory) +String::String(const ustring& str) +: _str(str) { - *this = fromUcs2(str, count); } -String::String(const String& str, size_t offset, size_t length) - throw(OutOfMemory) -: _offset(str._offset + offset), _length(length), _data(str._data) +String::String(const std::string& str) { + *this = fromLatin1(str.c_str(), str.size()); } -String::String(const std::string& str) +String::String(const char* str, size_t count) { - *this = fromLatin1(str.c_str()); + *this = fromLatin1(str, count); } String::~String() throw() @@ -71,150 +61,89 @@ void String::swap(String& b) { - SharedPtr<Data> tmp = _data; - _data = b._data; - b._data = tmp; + std::swap(b._str, _str); } size_t String::size() const throw() { - return _data->size; -} - -void String::resize(size_t sz) throw(OutOfMemory) -{ - resize(sz, 0, 0); + return _str.size(); } -void String::resize(size_t sz, size_t holeOffset, size_t holeLen) throw(OutOfMemory) +String String::substr(size_t offset, size_t length) const + throw(OutOfBounds) { - SharedPtr<Data> newData(new Data); - char* newStr = 0; - size_t newLength = 0; - - size_t length = sz >= _length ? _length : sz; - - if(holeLen == 0 || holeOffset >= length) - { - size_t reserve = sz - length; - - newStr = new char[sizeof(Char) * sz]; - copy_construct((Char*)newStr, data(), length); - construct((Char*)newStr + length, reserve); - - newLength = length; - } - else - { - size_t len1 = holeOffset - length; - size_t off2 = holeOffset; - size_t len2 = length - off2; - - newStr = new char[sizeof(Char) * sz]; - copy_construct((Char*)newStr, data(), len1); - construct((Char*)newStr + holeOffset, holeLen); - copy_construct((Char*)newStr + off2, data(), len2); - - newLength = length + holeLen; - } + if(offset + length > _str.size()) + throw OutOfBounds("Offset and/or length is out of bounds", P_SOURCEINFO); - newData->str = (Char*)newStr; - newData->size = sz; - _data = newData; - _offset = 0; - _length = newLength; + return _str.substr(offset, length); } -size_t String::length() const throw() +String String::left(size_t length) const throw(OutOfBounds) { - return _length; + return substr(0, length); } -std::string String::utf8() const +String String::right(size_t length) const throw(OutOfBounds) { - std::ostringstream os; - ConstIterator i = begin(); - while(i != end()) - { - os << (*i).latin1(); - ++i; - } - - return os.str(); + return substr(_str.size() - length, length); } -String String::part(size_t offset, size_t length) const - throw(OutOfMemory, OutOfBounds) +String& String::append(const String& str) { - if(offset + length > _length) - throw OutOfBounds("Offset and/or length is out of bounds", P_SOURCEINFO); - - return String(*this, offset, length); + _str.append(str._str); + return *this; } -String String::left(size_t length) const throw(OutOfMemory, OutOfBounds) +const Char& String::at(size_t pos) const throw(OutOfBounds) { - return part(0, length); + return operator[](pos); } -String String::right(size_t length) const throw(OutOfMemory, OutOfBounds) +Char& String::at(size_t pos) throw(OutOfBounds) { - return part(_length - length, length); + return operator[](pos); } -String String::deepCopy() const +std::string String::local() const { - String str(_length + 8); - copy_construct(str.data(), data(), _length); - return str; + return toCharset(nl_langinfo(CODESET)); } -const Char& String::at(size_t pos) const throw(OutOfBounds) +std::string String::latin1() const { - if(_offset + pos >= _length) - throw OutOfBounds("Index is out of bounds", P_SOURCEINFO); - - return *(data() + pos); + return toCharset("LATIN1"); } -Char& String::at(size_t pos) throw(OutOfMemory, OutOfBounds) +std::string String::utf8() const { - return operator[](pos); + return toCharset("UTF8"); } -Char& String::operator[](ptrdiff_t pos) throw(OutOfMemory, OutOfBounds) +const Char& String::operator[](size_t pos) const throw(OutOfBounds) { - if( static_cast<size_t>( pos ) - /** ACHTUNG ^^^^ cast added by stephan to avoid warning. - @Christian: how do you want to handle this case? - */ - >= _length) + if(pos >= _str.size()) throw OutOfBounds("Index is out of bounds", P_SOURCEINFO); - if(_data.useCount() > 1) - *this = deepCopy(); + return (Char&)_str.operator[](pos); +} - // construct Char's that were not yet constructed, but allocated - /*if(pos >= _length) - size_t ccount = pos - _length; - construct(_data->str + _length, ccount); - _length += pos + 1; - }*/ +Char& String::operator[](size_t pos) throw(OutOfBounds) +{ + if(pos >= _str.size()) + throw OutOfBounds("Index is out of bounds", P_SOURCEINFO); - return *(_data->str + _offset + pos); + return (Char&)_str.operator[](pos); } String& String::operator=(const String& str) { - if(this != &str) - { - if(_data != str._data) - _data = str._data; - - _offset = str._offset; - _length = str._length; - } + _str = str._str; + return *this; +} +String& String::operator=(const ustring& str) +{ + _str = str; return *this; } @@ -224,59 +153,39 @@ return *this; } -String& String::operator=(const wchar_t* str) +String& String::operator=(const std::string& str) { - *this = fromUcs2(str); + *this = fromLatin1(str.c_str(), str.size()); return *this; } -String& String::operator=(const std::string& str) +String& String::operator+=(const String& str) { - *this = fromLatin1(str.c_str()); + append(str); return *this; } bool String::operator==(const String& str) const throw() { - if(&str == this || (str.data() == data() && str._length == _length)) - return true; - - if(str._length == _length) - { - Char* lhsBegin = data(); - Char* lhsEnd = data() + _length; - Char* rhsBegin = str.data(); - - while(lhsBegin != lhsEnd) - { - if(*lhsBegin != *rhsBegin) - return false; - - ++lhsBegin, ++rhsBegin; - } - - return true; - } - - return false; + return _str == str._str; } bool String::operator!=(const String& str) const throw() { return !operator==(str); - return false; + return false; } bool String::operator<(const String& str) const throw() { //@todo String::operator< - return false; + return false; } bool String::operator>(const String& str) const throw() { //@todo String::operator> - return false; + return false; } bool String::operator<=(const String& str) const throw() @@ -289,256 +198,118 @@ return (operator>(str) || operator==(str)); } -Char* String::data() const throw() -{ - return _data->str + _offset; -} - -String String::fromLatin1(const char* str, size_t count) throw(OutOfMemory) +String String::fromLocal(const char* str, size_t count) { if(count == npos) count = strlen(str); - Char ch; - String str2(count + 8); - - const char* end = str + count; - Char* mystr = str2.data(); - - while(str != end) - { - ch = *(str++); - copy_construct(mystr++, &ch, 1); - } - - str2._length = count; - return str2; + return fromCharset(nl_langinfo(CODESET), str, count); } -String String::fromUcs2(const wchar_t* str, size_t count) throw(OutOfMemory) +String String::fromLatin1(const char* str, size_t count) { if(count == npos) - count = wcslen(str); - - Char ch; - String str2(count + 8); - - const wchar_t* end = str + count; - Char* mystr = str2.data(); - - while(str != end) - { - ch = *(str++); - copy_construct(mystr++, &ch, 1); - } - - str2._length = count; - return str2; -} - -String::Iterator String::begin() -{ - if(_data.useCount() > 1) - *this = deepCopy(); - - return Iterator(data()); -} - -String::Iterator String::end() -{ - if(_data.useCount() > 1) - *this = deepCopy(); - - return Iterator(data() + _length); -} - -String::ConstIterator String::begin() const -{ - return ConstIterator(data()); -} - -String::ConstIterator String::end() const -{ - return ConstIterator(data() + _length); -} - -void String::insert(const Iterator& pos, const Char& ch) -{ - if(_data.useCount() > 1 || _length + 1 > _data->size) - resize(size() + 1, &(*pos) - data(), 1); - else - { /* @todo */ } - - *pos = ch; -} - -void String::insert(const Iterator& pos, const String& str) -{ - -} - -void String::insert(size_t pos, const Char& ch) -{ - insert(Iterator(data() + pos), ch); -} - -void String::insert(size_t pos, const String& str) -{ - insert(Iterator(data() + pos), str); -} - -void String::append(const Char& ch) -{ - insert(end(), ch); -} - -void String::append(const String& str) -{ - insert(end(), str); -} - -void String::prepend(const Char& ch) -{ - insert(begin(), ch); -} - -void String::prepend(const String& str) -{ - insert(begin(), str); -} - -void String::erase(const Iterator& pos) -{ -} - -void String::erase(size_t pos) -{ - erase(Iterator(data() + pos)); -} - + count = strlen(str); -String::Iterator::Iterator(const String::Iterator& iter) -: _current(iter._current) -{ + return fromCharset("LATIN1", str, count); } -String::Iterator::Iterator(Char* current) -: _current(current) +String String::fromUtf8(const char* str, size_t count) { -} + if(count == npos) + count = strlen(str); -String::Iterator::~Iterator() -{ + return fromCharset("UTF8", str, count); } -Char& String::Iterator::operator*() const +String String::fromUcs2(const char* str, size_t count) { - return *_current; + return fromCharset("UCS2", (const char*)str, count); } -String::Iterator& String::Iterator::operator++() +String String::fromCharset(const char* charset, const char* str, size_t count) { - ++_current; - return *this; -} + ustring outstr; + char outstrbuf[1024]; -String::Iterator String::Iterator::operator++(int) -{ - Iterator tmp = *this; - ++_current; - return tmp; -} + iconv_t icd = iconv_open("UCS4", charset); -String::Iterator& String::Iterator::operator--() -{ - --_current; - return *this; -} + char* inbuf = (char*)str; + size_t inbytesleft = count; -String::Iterator String::Iterator::operator--(int) -{ - Iterator tmp = *this; - --_current; - return tmp; -} + char* outbuf = (char*)outstrbuf; + size_t outbytesleft = sizeof(outstrbuf); -String::Iterator& String::Iterator::operator=(const String::Iterator& iter) -{ - _current = iter._current; - return *this; -} +_do_iconv: + size_t ret = iconv(icd, &inbuf, &inbytesleft, &outbuf, &outbytesleft); -bool String::Iterator::operator==(const String::Iterator& iter) const -{ - return (_current == iter._current); -} + // get number of chars converted ... + unsigned int numchars = sizeof(outstrbuf) - outbytesleft; + unsigned int numuchars = numchars / sizeof(uchar_t); -bool String::Iterator::operator!=(const String::Iterator& iter) const -{ - return (_current != iter._current); -} + // append already converted chars to our string ... + outstr.append((uchar_t*)outstrbuf, numuchars); + if(ret == (size_t)-1) + { + if(errno == E2BIG) + { + outbytesleft = sizeof(outstrbuf); + outbuf = outstrbuf; + goto _do_iconv; + } + else + { + //TODO: throw InvalidString + throw; + } + } -String::ConstIterator::ConstIterator(const String::ConstIterator& iter) -: _current(iter._current) -{ + iconv_close(icd); + return outstr; } -String::ConstIterator::ConstIterator(const Char* current) -: _current(current) +std::string String::toCharset(const char* charset) const { -} + std::string outstr; + char outstrbuf[1024]; -String::ConstIterator::~ConstIterator() -{ -} + iconv_t icd = iconv_open(charset, "UCS4"); -const Char& String::ConstIterator::operator*() const -{ - return *_current; -} + char* inbuf = (char*)_str.c_str(); + size_t inbytesleft = _str.size() * sizeof(uchar_t); -String::ConstIterator& String::ConstIterator::operator++() -{ - ++_current; - return *this; -} + char* outbuf = (char*)outstrbuf; + size_t outbytesleft = sizeof(outstrbuf); -String::ConstIterator String::ConstIterator::operator++(int) -{ - ConstIterator tmp = *this; - ++_current; - return tmp; -} +_do_iconv: + size_t ret = iconv(icd, &inbuf, &inbytesleft, &outbuf, &outbytesleft); -String::ConstIterator& String::ConstIterator::operator--() -{ - --_current; - return *this; -} + // get number of chars converted ... + unsigned int numchars = sizeof(outstrbuf) - outbytesleft; -String::ConstIterator String::ConstIterator::operator--(int) -{ - ConstIterator tmp = *this; - --_current; - return tmp; -} + // append already converted chars to our string ... + outstr.append(outstrbuf, numchars); -String::ConstIterator& String::ConstIterator::operator=(const String::ConstIterator& iter) -{ - _current = iter._current; - return *this; -} + if(ret == (size_t)-1) + { + if(errno == E2BIG) + { + outbytesleft = sizeof(outstrbuf); + outbuf = outstrbuf; + goto _do_iconv; + } + else + { + //TODO: throw InvalidString + throw; + } + } -bool String::ConstIterator::operator==(const String::ConstIterator& iter) const -{ - return (_current == iter._current); + iconv_close(icd); + return outstr; } -bool String::ConstIterator::operator!=(const String::ConstIterator& iter) const -{ - return (_current != iter._current); -} } // !namespace Unicode Index: Makefile.am =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/Unicode/Makefile.am,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- Makefile.am 17 Jan 2005 22:50:41 -0000 1.7 +++ Makefile.am 26 Apr 2005 12:16:02 -0000 1.8 @@ -22,7 +22,7 @@ libpclasses_unicode_la_LDFLAGS = -no-undefined -libpclasses_unicode_la_LIBADD = $(top_builddir)/src/libpclasses.la +libpclasses_unicode_la_LIBADD = $(top_builddir)/src/libpclasses.la $(LIBICONV) all: unicodedata_db Index: ustring.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/Unicode/ustring.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- ustring.cpp 14 Jan 2005 14:46:02 -0000 1.1 +++ ustring.cpp 26 Apr 2005 12:16:02 -0000 1.2 @@ -20,6 +20,8 @@ #include "pclasses/Unicode/ustring.h" #include <string.h> +#include <iconv.h> +#include <errno.h> namespace P { @@ -45,7 +47,7 @@ size_t ucslen(const uchar_t* s) { size_t n = 0; - while(*(s++) != 0) + while(*(s++) != UEOF) ++n; return n; @@ -80,19 +82,6 @@ return s; } -ustring str(const char* str) -{ - size_t len = strlen(str); - ustring ret; - ret.reserve(len); - - size_t i = 0; - while(len-- > 0) - ret[i++] = touchar(*(str++)); - - return ret; -} - } // !namespace Unicode } // !namespace P Index: Char.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/Unicode/Char.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- Char.cpp 14 Jan 2005 14:46:02 -0000 1.3 +++ Char.cpp 26 Apr 2005 12:16:02 -0000 1.4 @@ -25,55 +25,18 @@ namespace Unicode { -Char::Char(uint32_t ch) +Char::Char(uchar_t ch) : _char(ch) { } -Char::Char(char ch) -: _char(ch) -{ -} - -Char::Char(wchar_t ch) -: _char(ch) -{ -} - Char::Char(const Char& ch) : _char(ch._char) { } -char Char::latin1() const -{ - if(_char < 0x7f) - return _char; - - return '?'; -} - -wchar_t Char::ucs2() const -{ - //@todo - return '?'; -} - bool Char::isNumber() const { - bool ret = false; - - switch(category()) - { - case Number_DecimalDigit: - case Number_Letter: - case Number_Other: - ret = true; - break; - default: - break; - } - - return ret; + return isudigit(_char) == 1 ? true : false; } bool Char::isSymbol() const @@ -134,21 +97,7 @@ bool Char::isLetter() const { - bool ret = false; - - switch(category()) - { - case Letter_Uppercase: - case Letter_Lowercase: - case Letter_Titlecase: - case Letter_Modifier: - case Letter_Other: - ret = true; - default: - break; - } - - return ret; + return isualpha(_char) == 1 ? true : false; } int Char::toNumber() const @@ -182,36 +131,22 @@ bool Char::isLower() const { - return category() == Letter_Lowercase; + return isulower(_char) == 1 ? true : false; } Char Char::toLower() const { - const codePointData* data = lookupCodePoint(_char); - if(data && data->extra) - { - const letterExtraData* extraData = (const letterExtraData*)data->extra; - return Char(extraData->lower); - } - - return *this; + return toulower(_char); } bool Char::isUpper() const { - return category() == Letter_Uppercase; + return isuupper(_char) == 1 ? true : false; } Char Char::toUpper() const { - const codePointData* data = lookupCodePoint(_char); - if(data && data->extra) - { - const letterExtraData* extraData = (const letterExtraData*)data->extra; - return Char(extraData->upper); - } - - return *this; + return touupper(_char); } bool Char::isMirrored() const @@ -244,19 +179,7 @@ return (Char::CombiningClass)data->combining; } -Char& Char::operator=(uint32_t ch) -{ - _char = ch; - return *this; -} - -Char& Char::operator=(char ch) -{ - _char = ch; - return *this; -} - -Char& Char::operator=(wchar_t ch) +Char& Char::operator=(uchar_t ch) { _char = ch; return *this; @@ -302,7 +225,7 @@ const Char& Char::eof() { - static Char _eof((char)0); + static Char _eof(UEOF); return _eof; } Index: uctype.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/Unicode/uctype.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- uctype.cpp 14 Jan 2005 14:46:02 -0000 1.1 +++ uctype.cpp 26 Apr 2005 12:16:02 -0000 1.2 @@ -174,14 +174,6 @@ return c; } -uchar_t touchar(char c) -{ - if(c < 0x7f) - return c; - - return '?'; -} - } // !namespace Unicode } // !namespace P |
From: Christian P. <cp...@us...> - 2005-04-26 12:16:15
|
Update of /cvsroot/pclasses/pclasses2/include/pclasses/Unicode In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26729/include/pclasses/Unicode Modified Files: Char.h String.h uctype.h ustring.h Log Message: - More work on unicode support Index: Char.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/Unicode/Char.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- Char.h 24 Jan 2005 01:19:26 -0000 1.2 +++ Char.h 26 Apr 2005 12:16:02 -0000 1.3 @@ -23,13 +23,14 @@ #include <pclasses/Export.h> #include <pclasses/BasicTypes.h> +#include <pclasses/Unicode/uctype.h> #include <cwchar> namespace P { namespace Unicode { -//! UNICODE 4.0 Compliant character class +//! UNICODE 4.0 compliant character class class PUNICODE_EXPORT Char { public: //! General category @@ -146,14 +147,9 @@ Combining_IotaSubscript = 240 }; - Char(uint32_t ch = 0); - Char(char ch); - Char(wchar_t ch); + Char(uchar_t ch = 0); Char(const Char& ch); - char latin1() const; - wchar_t ucs2() const; - bool isLetter() const; bool isSymbol() const; @@ -176,9 +172,7 @@ Decomposition decompTag() const; CombiningClass combiningClass() const; - Char& operator=(uint32_t ch); - Char& operator=(char ch); - Char& operator=(wchar_t ch); + Char& operator=(uchar_t ch); Char& operator=(const Char& ch); bool operator==(const Char& ch) const; @@ -195,7 +189,7 @@ static const Char& cr(); private: - uint32_t _char; + uchar_t _char; }; Index: ustring.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/Unicode/ustring.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- ustring.h 24 Jan 2005 01:20:09 -0000 1.2 +++ ustring.h 26 Apr 2005 12:16:02 -0000 1.3 @@ -20,7 +20,7 @@ #ifndef P_Unicode_ustring_h #define P_Unicode_ustring_h - + #include <pclasses/Export.h> #include <pclasses/Unicode/uctype.h> #include <string> @@ -100,16 +100,14 @@ } -namespace P { +namespace P { namespace Unicode { -typedef std::basic_string<uchar_t, - std::char_traits<uchar_t>, +typedef std::basic_string<uchar_t, + std::char_traits<uchar_t>, std::allocator<uchar_t> > ustring; -PUNICODE_EXPORT ustring str(const char* str); - } // !namespace Unicode } // !namespace P Index: uctype.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/Unicode/uctype.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- uctype.h 24 Jan 2005 01:19:26 -0000 1.2 +++ uctype.h 26 Apr 2005 12:16:02 -0000 1.3 @@ -42,7 +42,6 @@ PUNICODE_EXPORT int isuspace(uchar_t c); PUNICODE_EXPORT int isuupper(uchar_t c); -PUNICODE_EXPORT uchar_t touchar(char c); PUNICODE_EXPORT uchar_t toulower(uchar_t c); PUNICODE_EXPORT uchar_t touupper(uchar_t c); Index: String.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/Unicode/String.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- String.h 24 Jan 2005 01:19:26 -0000 1.3 +++ String.h 26 Apr 2005 12:16:02 -0000 1.4 @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2004 by Christian Prochnow * + * Copyright (C) 2004,2005 by Christian Prochnow, SecuLogiX GmbH * * cp...@se... * * * * This program is free software; you can redistribute it and/or modify * @@ -24,9 +24,8 @@ #include <pclasses/Export.h> #include <pclasses/BasicTypes.h> #include <pclasses/Alloc.h> -#include <pclasses/SharedPtr.h> -#include <pclasses/ScopedArrayPtr.h> #include <pclasses/Unicode/Char.h> +#include <pclasses/Unicode/ustring.h> #include <string> @@ -34,112 +33,47 @@ namespace Unicode { +//! UNICODE 4.0 compliant string class class PUNICODE_EXPORT String { public: enum { npos = (size_t)-1 }; - - String(size_t reserve = 8) throw(OutOfMemory); - String(const String& str) throw(OutOfMemory); - String(const char* str, size_t count = npos) throw(OutOfMemory); - String(const wchar_t* str, size_t count = npos) throw(OutOfMemory); + + String(); + String(const String& str); + String(const ustring& str); + String(const std::string& str); + String(const char* str, size_t count = npos); + ~String() throw(); void swap(String& b); size_t size() const throw(); - void resize(size_t sz) throw(OutOfMemory); - - size_t length() const throw(); const Char& at(size_t index) const throw(OutOfBounds); - Char& at(size_t index) throw(OutOfMemory, OutOfBounds); - - String part(size_t offset, size_t length) const - throw(OutOfMemory, OutOfBounds); - - String left(size_t length) const throw(OutOfMemory, OutOfBounds); - String right(size_t length) const throw(OutOfMemory, OutOfBounds); - - class PUNICODE_EXPORT Iterator { - public: - Iterator(Char* current); - Iterator(const Iterator& iter); - ~Iterator(); - - Char& operator*() const; - - Iterator& operator++(); - Iterator operator++(int); - - Iterator& operator--(); - Iterator operator--(int); - - Iterator& operator=(const Iterator& iter); - - bool operator==(const Iterator& iter) const; - bool operator!=(const Iterator& iter) const; - - private: - Char* _current; - }; - - class PUNICODE_EXPORT ConstIterator { - public: - ConstIterator(const Char* current); - ConstIterator(const ConstIterator& iter); - ~ConstIterator(); - - const Char& operator*() const; - - ConstIterator& operator++(); - ConstIterator operator++(int); - - ConstIterator& operator--(); - ConstIterator operator--(int); - - ConstIterator& operator=(const ConstIterator& iter); - - bool operator==(const ConstIterator& iter) const; - bool operator!=(const ConstIterator& iter) const; - - private: - const Char* _current; - }; - - Iterator begin(); - ConstIterator begin() const; - - Iterator end(); - ConstIterator end() const; - - void insert(const Iterator& pos, const Char& ch); - void insert(size_t pos, const Char& ch); - - void insert(const Iterator& pos, const String& str); - void insert(size_t pos, const String& str); - - void erase(const Iterator& pos); - void erase(size_t pos); + Char& at(size_t index) throw(OutOfBounds); - void append(const Char& ch); - void append(const String& str); + String substr(size_t offset = 0, size_t length = npos) const + throw(OutOfBounds); - void prepend(const Char& ch); - void prepend(const String& str); + String left(size_t length) const throw(OutOfBounds); + String right(size_t length) const throw(OutOfBounds); - std::string utf8() const; + String& append(const String& str); - String deepCopy() const; + Char& operator[](size_t pos) throw(OutOfBounds); + const Char& operator[](size_t pos) const throw(OutOfBounds); String& operator=(const String& str); + String& operator=(const ustring& str); + String& operator=(const char* str); - String& operator=(const wchar_t* str); String& operator=(const std::string& str); - Char& operator[](ptrdiff_t pos) throw(OutOfMemory, OutOfBounds); + String& operator+=(const String& str); bool operator==(const String& str) const throw(); bool operator!=(const String& str) const throw(); @@ -150,29 +84,30 @@ bool operator<=(const String& str) const throw(); bool operator>=(const String& str) const throw(); - static String fromLatin1(const char* str, size_t count = npos) - throw(OutOfMemory); + //! Returns the string in local encoding + std::string local() const; - static String fromUcs2(const wchar_t* str, size_t count = npos) - throw(OutOfMemory); + //! Returns the string in latin1 encoding + std::string latin1() const; - private: + //! Returns the string in utf8 encoding + std::string utf8() const; - //! Private string-data structure - struct Data { - Char* str; - size_t size; - }; + std::string toCharset(const char* charset) const; - String(const String& str, size_t offset, size_t length) throw(OutOfMemory); + static String fromLocal(const char* str, size_t count = npos); - Char* data() const throw(); + static String fromLatin1(const char* str, size_t count = npos); - void resize(size_t sz, size_t holeOffset, size_t holeLen) throw(OutOfMemory); + static String fromUtf8(const char* str, size_t count = npos); - mutable size_t _offset; - mutable size_t _length; - mutable SharedPtr<Data> _data; + static String fromUcs2(const char* str, size_t count); + + static String fromCharset(const char* charset, const char* str, + size_t count); + + private: + ustring _str; }; } // !namespace Unicode |
From: Christian P. <cp...@us...> - 2005-04-26 12:11:07
|
Update of /cvsroot/pclasses/pclasses2/m4 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24474/m4 Added Files: iconv.m4 expat.m4 Log Message: - Added configure checks for expat and iconv --- NEW FILE: iconv.m4 --- # iconv.m4 serial AM4 (gettext-0.11.3) dnl Copyright (C) 2000-2002 Free Software Foundation, Inc. dnl This file is free software, distributed under the terms of the GNU dnl General Public License. As a special exception to the GNU General dnl Public License, this file may be distributed as part of a program dnl that contains a configuration script generated by Autoconf, under dnl the same distribution terms as the rest of that program. dnl From Bruno Haible. AC_DEFUN([AM_ICONV_LINKFLAGS_BODY], [ dnl Prerequisites of AC_LIB_LINKFLAGS_BODY. AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) AC_REQUIRE([AC_LIB_RPATH]) dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV dnl accordingly. AC_LIB_LINKFLAGS_BODY([iconv]) ]) AC_DEFUN([AM_ICONV_LINK], [ dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and dnl those with the standalone portable GNU libiconv installed). dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV dnl accordingly. AC_REQUIRE([AM_ICONV_LINKFLAGS_BODY]) dnl Add $INCICONV to CPPFLAGS before performing the following checks, dnl because if the user has installed libiconv and not disabled its use dnl via --without-libiconv-prefix, he wants to use it. The first dnl AC_TRY_LINK will then fail, the second AC_TRY_LINK will succeed. am_save_CPPFLAGS="$CPPFLAGS" AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCICONV]) AC_CACHE_CHECK(for iconv, am_cv_func_iconv, [ am_cv_func_iconv="no, consider installing GNU libiconv" am_cv_lib_iconv=no AC_TRY_LINK([#include <stdlib.h> #include <iconv.h>], [iconv_t cd = iconv_open("",""); iconv(cd,NULL,NULL,NULL,NULL); iconv_close(cd);], am_cv_func_iconv=yes) if test "$am_cv_func_iconv" != yes; then am_save_LIBS="$LIBS" LIBS="$LIBS $LIBICONV" AC_TRY_LINK([#include <stdlib.h> #include <iconv.h>], [iconv_t cd = iconv_open("",""); iconv(cd,NULL,NULL,NULL,NULL); iconv_close(cd);], am_cv_lib_iconv=yes am_cv_func_iconv=yes) LIBS="$am_save_LIBS" fi ]) if test "$am_cv_func_iconv" = yes; then AC_DEFINE(HAVE_ICONV, 1, [Define if you have the iconv() function.]) fi if test "$am_cv_lib_iconv" = yes; then AC_MSG_CHECKING([how to link with libiconv]) AC_MSG_RESULT([$LIBICONV]) else dnl If $LIBICONV didn't lead to a usable library, we don't need $INCICONV dnl either. CPPFLAGS="$am_save_CPPFLAGS" LIBICONV= LTLIBICONV= fi AC_SUBST(LIBICONV) AC_SUBST(LTLIBICONV) ]) AC_DEFUN([AM_ICONV], [ AM_ICONV_LINK if test "$am_cv_func_iconv" = yes; then AC_MSG_CHECKING([for iconv declaration]) AC_CACHE_VAL(am_cv_proto_iconv, [ AC_TRY_COMPILE([ #include <stdlib.h> #include <iconv.h> extern #ifdef __cplusplus "C" #endif #if defined(__STDC__) || defined(__cplusplus) size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft); #else size_t iconv(); #endif ], [], am_cv_proto_iconv_arg1="", am_cv_proto_iconv_arg1="const") am_cv_proto_iconv="extern size_t iconv (iconv_t cd, $am_cv_proto_iconv_arg1 char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);"]) am_cv_proto_iconv=`echo "[$]am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'` AC_MSG_RESULT([$]{ac_t:- }[$]am_cv_proto_iconv) AC_DEFINE_UNQUOTED(ICONV_CONST, $am_cv_proto_iconv_arg1, [Define as const if the declaration of iconv() needs const.]) fi ]) --- NEW FILE: expat.m4 --- dnl Check if --with-expat[=PREFIX] is specified and dnl Expat >= 1.95.0 is installed in the system. dnl If yes, substitute EXPAT_CFLAGS, EXPAT_LIBS with regard to dnl the specified PREFIX and set with_expat to PREFIX, or 'yes' if PREFIX dnl has not been specified. Also HAVE_LIBEXPAT, HAVE_EXPAT_H are defined. dnl If --with-expat has not been specified, set with_expat to 'no'. dnl In addition, an Automake conditional EXPAT_INSTALLED is set accordingly. dnl This is necessary to adapt a whole lot of packages that have expat dnl bundled as a static library. AC_DEFUN(AM_WITH_EXPAT, [ AC_ARG_WITH(expat, [ --with-expat=PREFIX Use system Expat library], , with_expat=yes) AM_CONDITIONAL(EXPAT_INSTALLED, test $with_expat != no) EXPAT_CFLAGS= EXPAT_LIBS= if test $with_expat != no; then if test $with_expat != yes; then EXPAT_CFLAGS="-I$with_expat/include" EXPAT_LIBS="-L$with_expat/lib" fi AC_CHECK_LIB(expat, XML_ParserCreate, [ EXPAT_LIBS="$EXPAT_LIBS -lexpat" expat_found=yes ], [ expat_found=no ], "$EXPAT_LIBS") if test $expat_found = no; then AC_MSG_ERROR([Could not find the Expat library]) fi expat_save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS $EXPAT_CFLAGS" AC_CHECK_HEADERS(expat.h, , expat_found=no) if test $expat_found = no; then AC_MSG_ERROR([Could not find expat.h]) fi CFLAGS="$expat_save_CFLAGS" fi AC_SUBST(EXPAT_CFLAGS) AC_SUBST(EXPAT_LIBS) ]) |
From: Christian P. <cp...@us...> - 2005-04-26 12:11:06
|
Update of /cvsroot/pclasses/pclasses2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24474 Modified Files: configure.in Log Message: - Added configure checks for expat and iconv Index: configure.in =================================================================== RCS file: /cvsroot/pclasses/pclasses2/configure.in,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- configure.in 23 Apr 2005 12:00:06 -0000 1.9 +++ configure.in 26 Apr 2005 12:10:46 -0000 1.10 @@ -219,11 +219,12 @@ AM_CONDITIONAL(WITH_WIN32_TIME, false) dnl -dnl build with stl support? +dnl check for libiconv .. needed by Unicode support dnl -AC_ARG_WITH(stl,[ --with-stl Enable code for STL support], - [ AC_DEFINE_UNQUOTED([WITH_STL],1,[Defines if STL support is wanted]) ]) +AM_ICONV + +AM_WITH_EXPAT dnl dnl check socket stuff |
From: Christian P. <cp...@us...> - 2005-04-25 11:03:47
|
Update of /cvsroot/pclasses/pclasses2/include/pclasses In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20587/include/pclasses Modified Files: IntrusivePtr.h ScopedPtr.h SharedPtr.h Log Message: - Removed #ifdef PCLASSES_WITH_STL, the stl is required Index: IntrusivePtr.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/IntrusivePtr.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- IntrusivePtr.h 22 Dec 2004 17:54:38 -0000 1.1.1.1 +++ IntrusivePtr.h 25 Apr 2005 11:03:19 -0000 1.2 @@ -18,14 +18,11 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ -#ifndef _P_IntrusivePtr_h_ -#define _P_IntrusivePtr_h_ +#ifndef P_IntrusivePtr_h +#define P_IntrusivePtr_h #include <pclasses/Alloc.h> - -#ifdef PCLASSES_WITH_STL #include <memory> -#endif namespace P { @@ -43,11 +40,9 @@ : _ptr(ptr.release()) { } -#ifdef PCLASSES_WITH_STL explicit IntrusivePtr(std::auto_ptr<Type>& ptr) throw() : _ptr(ptr.release()) { } -#endif ~IntrusivePtr() throw() { checked_delete(_ptr); } @@ -93,18 +88,20 @@ return *this; } -#ifdef PCLASSES_WITH_STL IntrusivePtr& operator=(std::auto_ptr<Type>& ptr) throw() { IntrusivePtr(ptr).swap(*this); return *this; } -#endif - + private: Type* _ptr; }; +template <class Type> +inline void swap(IntrusivePtr<Type>& a, IntrusivePtr<Type>& b) throw() +{ a.swap(b); } + } // !namespace P #endif Index: SharedPtr.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/SharedPtr.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- SharedPtr.h 22 Dec 2004 17:54:39 -0000 1.1.1.1 +++ SharedPtr.h 25 Apr 2005 11:03:19 -0000 1.2 @@ -18,15 +18,12 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ -#ifndef _P_Core_SharedPtr_h_ -#define _P_Core_SharedPtr_h_ +#ifndef P_SharedPtr_h +#define P_SharedPtr_h #include <pclasses/Exception.h> #include <pclasses/Atomic.h> - -#ifdef PCLASSES_WITH_STL - #include <memory> -#endif +#include <memory> namespace P { @@ -43,11 +40,9 @@ : _ptr(ptr._ptr) { _ptr->getRef(); } -#ifdef PCLASSES_WITH_STL explicit SharedPtr(std::auto_ptr<Type> ptr) throw(OutOfMemory) : _ptr(alloc(ptr.release())) { } -#endif ~SharedPtr() throw() { _ptr->putRef(); } @@ -83,13 +78,11 @@ return *this; } -#ifdef PCLASSES_WITH_STL SharedPtr& operator=(std::auto_ptr<Type>& ptr) throw(OutOfMemory) { SharedPtr(ptr).swap(*this); return *this; } -#endif SharedPtr& operator=(const SharedPtr& ptr) throw() { Index: ScopedPtr.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/ScopedPtr.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- ScopedPtr.h 22 Dec 2004 17:54:40 -0000 1.1.1.1 +++ ScopedPtr.h 25 Apr 2005 11:03:19 -0000 1.2 @@ -18,14 +18,11 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ -#ifndef _P_ScopedPtr_h_ -#define _P_ScopedPtr_h_ +#ifndef P_ScopedPtr_h +#define P_ScopedPtr_h #include <pclasses/Alloc.h> - -#ifdef PCLASSES_WITH_STL #include <memory> -#endif namespace P { @@ -39,11 +36,9 @@ : _ptr(ptr) { } -#ifdef PCLASSES_WITH_STL explicit ScopedPtr(std::auto_ptr<Type> ptr) throw() : _ptr(ptr.release()) { } -#endif ~ScopedPtr() throw() { checked_delete(_ptr); } @@ -83,14 +78,12 @@ return *this; } -#ifdef PCLASSES_WITH_STL ScopedPtr& operator=(std::auto_ptr<Type>& ptr) throw() { ScopedPtr(ptr).swap(*this); return *this; } -#endif - + private: ScopedPtr(const ScopedPtr&); ScopedPtr& operator=(const ScopedPtr&); |
From: Christian P. <cp...@us...> - 2005-04-25 10:57:47
|
Update of /cvsroot/pclasses/pclasses2/src/System In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17555/src/System Modified Files: PathFinder.cpp SignalListener.posix.cpp Log Message: - Fixed compile-error with -Werror Index: SignalListener.posix.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/System/SignalListener.posix.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- SignalListener.posix.cpp 23 Apr 2005 17:48:03 -0000 1.4 +++ SignalListener.posix.cpp 25 Apr 2005 10:57:31 -0000 1.5 @@ -144,7 +144,7 @@ // clear the signal pipe ... we don't want to get signaled forever char tmp[64]; - int ret = ::read(fd(), tmp, 64); + ::read(fd(), tmp, 64); // restore blocked signal state ... sigprocmask(SIG_SETMASK, &oldSet, 0); Index: PathFinder.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/System/PathFinder.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- PathFinder.cpp 23 Apr 2005 15:19:32 -0000 1.4 +++ PathFinder.cpp 25 Apr 2005 10:57:31 -0000 1.5 @@ -49,8 +49,6 @@ std::string joinList( const StringList & list, const std::string & separator ) { std::ostringstream ret; - unsigned long count = list.size(); - unsigned long at = 0; typename StringList::const_iterator it = list.begin(); while(it != list.end()) |
From: Christian P. <cp...@us...> - 2005-04-25 10:56:40
|
Update of /cvsroot/pclasses/pclasses2/src/System In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17012/src/System Modified Files: timeout.h Log Message: - Added missing export macros Index: timeout.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/System/timeout.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- timeout.h 22 Dec 2004 17:54:35 -0000 1.1.1.1 +++ timeout.h 25 Apr 2005 10:56:30 -0000 1.2 @@ -18,8 +18,10 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ -#ifndef _P_timeout_h_ -#define _P_timeout_h_ +#ifndef P_timeout_h +#define P_timeout_h + +#include "pclasses/Export.h" struct timeval; @@ -37,12 +39,12 @@ }; #ifndef WIN32 -timespec* get_timeout(struct timespec *spec, unsigned int timer, +PSYSTEM_EXPORT timespec* get_timeout(struct timespec *spec, unsigned int timer, timeout_mode mode); #endif -timeval* get_timeout(struct timeval *val, unsigned int timer, timeout_mode mode); -bool timeout_elapsed(struct timeval* val); +PSYSTEM_EXPORT timeval* get_timeout(struct timeval *val, unsigned int timer, timeout_mode mode); +PSYSTEM_EXPORT bool timeout_elapsed(struct timeval* val); } // !namespace Private |
From: Christian P. <cp...@us...> - 2005-04-25 10:55:42
|
Update of /cvsroot/pclasses/pclasses2/src/System In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16052/src/System Modified Files: SharedMemory.sysv.cpp Log Message: - Fixed compile-error with -Werror Index: SharedMemory.sysv.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/System/SharedMemory.sysv.cpp,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- SharedMemory.sysv.cpp 22 Dec 2004 17:54:36 -0000 1.1.1.1 +++ SharedMemory.sysv.cpp 25 Apr 2005 10:55:04 -0000 1.2 @@ -83,7 +83,7 @@ flags |= SHM_RDONLY; void* mapaddr = shmat(_handle->shmid, addr, flags); - if((int)mapaddr == -1) + if((long)mapaddr == -1) throw SystemError(errno, "Could not map SYSV shared-memory segment", P_SOURCEINFO); |
From: Christian P. <cp...@us...> - 2005-04-25 10:54:31
|
Update of /cvsroot/pclasses/pclasses2/src/System In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15822/src/System Modified Files: Makefile.am Log Message: - Added Timer sources to Makefile.am Index: Makefile.am =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/System/Makefile.am,v retrieving revision 1.18 retrieving revision 1.19 diff -u -d -r1.18 -r1.19 --- Makefile.am 22 Feb 2005 13:23:02 -0000 1.18 +++ Makefile.am 25 Apr 2005 10:54:18 -0000 1.19 @@ -66,11 +66,11 @@ endif if WITH_POSIX_TIME -Time_Sources = SystemClock.posix.cpp +Time_Sources = SystemClock.posix.cpp Timer.posix.cpp endif if WITH_WIN32_TIME -Time_Sources = SystemClock.win32.cpp +Time_Sources = SystemClock.win32.cpp Timer.win32.cpp endif System_Sources = CdRomDevice.linux.cpp Ps2Device.linux.cpp \ |
From: Christian P. <cp...@us...> - 2005-04-25 10:51:24
|
Update of /cvsroot/pclasses/pclasses2/src/Util In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14574/src/Util Modified Files: ManagedThread.cpp WorkQueue.cpp Log Message: - Changed return type of Thread::main() to long Index: ManagedThread.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/Util/ManagedThread.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- ManagedThread.cpp 28 Jan 2005 11:39:37 -0000 1.2 +++ ManagedThread.cpp 25 Apr 2005 10:51:15 -0000 1.3 @@ -76,9 +76,9 @@ } } -int ManagedThread::join() throw(SystemError) +long ManagedThread::join() throw(SystemError) { - int ret = Thread::join(); + long ret = Thread::join(); _shouldSuspend = false; _shouldStop = false; changeState(Stopped); @@ -100,7 +100,7 @@ return true; } -int ManagedThread::init() +long ManagedThread::init() { return 0; } @@ -117,9 +117,9 @@ { } -int ManagedThread::main() +long ManagedThread::main() { - int ret = init(); + long ret = init(); if(ret != 0) { changeState(Failed); Index: WorkQueue.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/Util/WorkQueue.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- WorkQueue.cpp 28 Jan 2005 11:39:37 -0000 1.3 +++ WorkQueue.cpp 25 Apr 2005 10:51:15 -0000 1.4 @@ -39,7 +39,7 @@ return _state; } -int WorkItem::retVal() const throw() +long WorkItem::retVal() const throw() { return _retVal; } @@ -116,7 +116,7 @@ { } -int WorkerThread::mainLoop() +long WorkerThread::mainLoop() { WorkItem* item = 0; @@ -152,7 +152,7 @@ { while(_numThreads > numThreads) { - list<WorkerThread*>::iterator i = _threads.begin(); + std::list<WorkerThread*>::iterator i = _threads.begin(); WorkerThread* thread = *i; thread->stop(); thread->join(); |
From: Christian P. <cp...@us...> - 2005-04-25 10:51:24
|
Update of /cvsroot/pclasses/pclasses2/src/System In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14574/src/System Modified Files: Thread.common.cpp Thread.posix.cpp Log Message: - Changed return type of Thread::main() to long Index: Thread.common.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/System/Thread.common.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- Thread.common.cpp 1 Feb 2005 16:55:44 -0000 1.3 +++ Thread.common.cpp 25 Apr 2005 10:51:15 -0000 1.4 @@ -33,7 +33,7 @@ } protected: - int main() + long main() { Semaphore* sem = _sem; if(sem) Index: Thread.posix.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/System/Thread.posix.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- Thread.posix.cpp 28 Jan 2005 11:36:38 -0000 1.3 +++ Thread.posix.cpp 25 Apr 2005 10:51:15 -0000 1.4 @@ -86,7 +86,7 @@ _handle = handle.release(); } -int Thread::join() throw(LogicError, SystemError) +long Thread::join() throw(LogicError, SystemError) { if(!_handle) throw LogicError("Thread is not running", P_SOURCEINFO); @@ -99,7 +99,7 @@ delete _handle; _handle = 0; - return (int)threadRet; + return (long)threadRet; } void Thread::yield() throw() |