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-06-30 14:52:22
|
Update of /cvsroot/pclasses/pclasses2/include/pclasses In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31566/include/pclasses Added Files: LexT.h Log Message: - Moved LexT from P::Util to P namespace - Removed fromString()/toString() from Private namespace and put it in a separate Traits::LexT<> class. - Removed non-const accessors --- NEW FILE: LexT.h --- //////////////////////////////////////////////////////////////////////// // LexT.h: the P::LexT class, a simple class for lexically casting // i/ostreamable types. As of 30.06.2005 this class does not only // support i/ostreamable types, as you may provide a Traits // specialisation for a particular type. // // author: st...@s1... // License: Public Domain // // Modified by cp...@se... to use a Traits class for the // to/from string conversion. // //////////////////////////////////////////////////////////////////////// #ifndef P_LexT_h #define P_LexT_h #include <pclasses/Export.h> #include <pclasses/Exception.h> #include <string> #include <iostream> #include <sstream> namespace P { namespace Traits { //! Lexical type conversion traits /*! This traits class is used by P::LexT to convert a given type to/from a string. */ template <typename Type> struct LexT { /*! Returns a string representation of the given object, which must be ostreamble. */ static std::string toString(const Type& val) { std::ostringstream os; os << std::fixed; os << val; return os.str(); } /*! Lexically casts str to Type, returning errorVal if the conversion fails. */ static Type fromString(const std::string& str) throw(ConversionError) { std::istringstream is(str); Type val = Type(); if((is >> val) && is.eof()) return val; throw ConversionError("Could not convert to requested type", P_SOURCEINFO); } }; template < > struct LexT<std::string> { static std::string toString(const std::string& val) { return val; } static std::string fromString(const std::string& str) { return str; } }; template < > struct LexT<char*> { static std::string toString(const char* val) { return val; } static std::string fromString(const std::string& str) { return str; } }; } // !namespace Traits /*! LexT provides a really convenient way to lexically cast strings and other streamable types to/from each other. All parameterized types used by this type must be: - i/o streamable or provide a specialized Traits::LexT<> template. The operators must complement each other. - Assignable. - Default Constructable. This type is fairly light-weight, with only one std::string data member, so it should copy quickly and implicitely use std::string's CoW and reference counting features. Adding reference counting to this class would be of no benefit, and would probably hurt performance, considering that std::string's are optimized in these ways, and this type is simply a proxy for a std::string. For some uses the LexT type can replace the requirement for returning a proxy type from a type's operator[](), as discussed in Scott Meyers' <em>More Effective C++</em>, Item 30. This class originally was such a proxy, and then evolved into a generic solution for POD-based types, which inherently also covers most i/ostreamable types. It is less efficient than specialized proxies for, e.g. (char &), but it is also extremely easy to use, as shown here: <pre> LexT lex = 17; int bogo = lex; ulong bogol = bogo * static_cast<long>(lex); lex = "bogus string"; typedef std::map<LexT,LexT> LMap; LMap map; map[4] = "one"; map["one"] = 4; map[123] = "eat this"; map['x'] = "marks the spot"; map["fred"] = 94.3 * static_cast<double>( map["one"] ); map["fred"] = 10 * static_cast<double>( map["fred"] ); map["123"] = "this was re-set"; int myint = map["one"]; </pre> Finally, Perl-ish type flexibility in C++. :) It gets better: if we're using s11n, we can now save and load these objects at will: <pre> s11nlite::save( map, "somefile.s11n" ); ... LMap * map = s11nlite::load_serializable<LMap>( "somefile.s11n" ); </pre> If s11n is detected by this header it will automatically register a serialization proxy with s11n. See the end of this header file for the exact registration code. This software is released into the Public Domain by it's author, stephan beal (st...@s1...). If you want this class to work with the SIO framework you must include the following header: <pclasses/s11n/proxy/LexT_s11n.h> Change history: 30 Jun 2005 - Removed fromString()/toString() from Private namespace and put it in a separate Traits::LexT<> class. - Removed non-const accessors 28 Dec 2004: - Changed the impl of istream>>() to use getc() instead of getline(), so newlines are preserved. 25 Dec 2004: - Ported into the P::Classes tree. Renamed the class and some functions for P's naming conventions. 25 Nov 2004: - Minor doc updates. - Changed multiple-include guard to allow inclusion of this file twice for purposes of registering LexT with s11n. Before, this header must have been included AFTER including s11n to pick up the registration. Now including this header after including s11n is safe if it has previously been included (and thus didn't pick up s11n registration). 2 Oct 2004: - Accomodated recent changes in libs11n. 22 Aug 2004: - Added ambiguity-buster overloads for operator==() for (const char *) and std::string. 20 Aug 2004: - Added LexT::empty() - Moved LexT::operator==() to a free function. - Added LexT::operator=(const char *) (see API notes for why). 17 Aug 2004: - Initial release. - After-relase: - Added more docs. - Added std::string and (const char *) overloads, to avoid some ambiguities. 16 Aug 2004: - Zen Coding Session. */ class LexT { public: /*! Constructs an empty object. Calling <code>castTo<T>()</code> on an un-populated LexT object will return T(). */ LexT() throw() { } ~LexT() throw() { } /*! Copies rhs's data to this object. */ LexT(const LexT& rhs) : _data(rhs._data) { } /*! Lexically casts f to a string. */ template <typename FromT> LexT(const FromT& f) { _data = Traits::LexT<FromT>::toString(f); } /*! See operator=(const char *) for a note about why this exists. @fixme cproch: see operator=(const char*) */ LexT(const char * str) : _data(str ? str : "") { } /*! lexically casts the value to a ToType, throwing a ConversionError if the cast fails. When calling this function you may need to use the following syntax to avoid compile errors: Foo foo = lex.template castTo<Foo>(); (It's weird, i know, and the first time i saw it, finding the solution to took me days. (Thank you, Nicolai Josuttis!)) However, in normal usage you won't need to use this function, as the generic type conversion operator does the exact same thing: <pre> LexT lex = 17; int foo = lex; </pre> */ template <typename ToType> inline ToType castTo() const throw(ConversionError) { if(!_data.empty()) return Traits::LexT<ToType>::fromString(_data); return ToType(); } /*! Returns a const reference to this object's raw string data. */ inline const std::string& str() const throw() { return _data; } /*! Returns true if this object contains no data, else false. */ inline bool empty() const throw() { return _data.empty(); } /*! Copies rhs's data and returns this object. */ inline LexT& operator=(const LexT& rhs) { if(&rhs != this) _data = rhs._data; return *this; } /*! This overload exists to keep the compiler/linker from generating a new instantiation of this function for each differently-lengthed (const char *) which is assigned to a LexT. @fixme cproch: is this really the case ? i don't see why the compiler should generate a new instance of this method, cause LexT isnt a template class. */ inline LexT& operator=(const char* rhs) { _data = rhs ? rhs : ""; return *this; } /*! Sets this object's value and returns this object. */ template <typename ToType> inline LexT& operator=(const ToType& f) { _data = Traits::LexT<ToType>::toString(f); return *this; } /*! i used to LOVE C++... After writing this function i WORSHIP C++. The grace with which C++ handles this is pure magic, my friends. 16.8.2004 ----- stephan */ template <typename ToType> inline operator ToType() const throw(ConversionError) { return castTo<ToType>(); } /* Overload to avoid ambiguity in some cases. 30.6.2005 cproch: this operator actually produces an amgiguity */ //inline operator std::string () const throw() //{ return _data; } /* Returns the same as str(). 30.6.2005 cproch: this operator actually produces an amgiguity */ //operator const std::string& () const throw() //{ return _data; } /*! Overload to avoid ambiguity in some cases. Useful for mixing C and C++ APIs: <pre> LexT arg = "USER"; LexT user = ::getenv(arg); </pre> */ inline operator const char* () const throw() { return _data.c_str(); } /*! Returns (this-<str() < rhs.str()). */ inline bool operator<(const LexT& rhs) const throw() { return _data < rhs._data; } /*! Returns (this-<str() > rhs.str()). */ inline bool operator>(const LexT& rhs) const throw() { return _data > rhs._data; } /*! Returns lhs.str() == rhs.str() */ inline bool operator==(const LexT& rhs) const throw() { return _data == rhs._data; } /*! Casts lhs to a Type object and returns true only if that object compares as equal to rhs. */ template <typename Type> inline bool operator==(const Type& rhs) const throw(ConversionError) { return castTo<Type>() == rhs; } /*! Avoid an ambiguity... */ inline bool operator==(const std::string& rhs) const throw() { return _data == rhs; } /*! Avoid an ambiguity... If rhs == 0 then this function returns true if lhs.empty(). */ inline bool operator==(const char* rhs) const throw() { if(!rhs) return empty(); return _data == rhs; } /*! Copies a.str() to os. */ friend inline std::ostream& operator<<(std::ostream& os, const LexT& a) { return os << a._data; } /*! Reads from the input stream, appending to a.str() until the stream gives up. If the implementation of this function seems "wrong" to you, please read the justification in this paper: http://s11n.net/papers/lexically_casting.html */ friend inline std::istream& operator>>(std::istream& is, LexT& a) { return std::getline(is, a._data, static_cast<std::istream::char_type>( std::istream::traits_type::eof() )); } private: std::string _data; }; } // !namespace P #endif // !P_LexT_h |
From: Christian P. <cp...@us...> - 2005-06-29 20:52:38
|
Update of /cvsroot/pclasses/pclasses2/include/pclasses In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24487/include/pclasses Modified Files: CallbackN.sh Makefile.am Signal.h Added Files: SignalN.sh Log Message: - Added shell script for generating SignalN classes - Fixed Makefile.am --- NEW FILE: SignalN.sh --- #! /bin/bash #/*************************************************************************** # * Copyright (C) 2005 by Christian Prochnow * # * 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. * # ***************************************************************************/ # # this shell-script generates code for Signals with n arguments.... # generare_signalN() { templateargs="typename ArgType1" argtypescp="ArgType1" argtypes="ArgType1 arg1" args="arg1" num=1 while [ "$num" -lt "$1" ] do num=`expr $num + 1` templateargs="$templateargs, typename ArgType$num" argtypescp="$argtypescp, ArgType$num" argtypes="$argtypes, ArgType$num arg$num" args="$args, arg$num" done cat << EOF > "SignalN$1.h" namespace P { /* -------------------- Signal$num ---------------- */ //! Base class for Signal$num template <typename RetType, $templateargs> class SignalBase$num { public: typedef std::list< Callback$num<RetType, $argtypescp>* > CallbackList; SignalBase$num() { } virtual ~SignalBase$num() { unbind_slots(_slots); } template <class CallbackType> void bind(CallbackType slot) { bind_slot(_slots, slot); } template <class CallbackType> void unbind(CallbackType slot) { unbind_slot(_slots, slot); } virtual RetType fire($argtypes) const = 0; protected: CallbackList _slots; }; //! Signal with $num argument(s) template <typename RetType, $templateargs> class Signal$num: public SignalBase$num<RetType, $argtypescp> { typedef SignalBase$num<RetType, $argtypescp> BaseType; public: RetType fire($argtypes) const { RetType ret = RetType(); typename BaseType::CallbackList::const_iterator i = this->_slots.begin(); while(i != this->_slots.end()) { ret = (*i)->exec($args); if(ret) break; ++i; } return ret; } }; //! Signal with $num argument(s) (void specialisation) template <$templateargs> class Signal$num<void, $argtypescp>: public SignalBase$num<void, $argtypescp> { typedef SignalBase$num<void, $argtypescp> BaseType; public: void fire($argtypes) const { typename BaseType::CallbackList::const_iterator i = this->_slots.begin(); while(i != this->_slots.end()) { (*i)->exec($args); ++i; } } }; } // !namespace P EOF } generare_signalN 1 generare_signalN 2 generare_signalN 3 generare_signalN 4 Index: CallbackN.sh =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/CallbackN.sh,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- CallbackN.sh 2 Feb 2005 15:54:42 -0000 1.3 +++ CallbackN.sh 29 Jun 2005 20:52:29 -0000 1.4 @@ -51,7 +51,7 @@ cat << EOF > "CallbackN$1.h" namespace P { -/* ----------------- Callback1 ------------------ */ +/* ----------------- Callback$num ------------------ */ template <$templateargs> class CallbackArgs$num: public CallbackArgs { @@ -73,7 +73,7 @@ return args; } -//! Callback base class with $num argument +//! Callback base class with $num argument(s) template <typename _RetT, $templateargs> class Callback$num: public Callback { public: @@ -95,7 +95,7 @@ virtual _RetT exec($argtypes) const = 0; }; -//! Callback base class with $num argument (void specialisation) +//! Callback base class with $num argument(s) (void specialisation) template <$templateargs> class Callback$num<void $argtypescp>: public Callback { public: @@ -116,9 +116,9 @@ virtual void exec($argtypes) const = 0; }; -/* -------------- Function1 ------------- */ +/* -------------- Function$num ------------- */ -//! Function callback class with $num argument +//! Function callback class with $num argument(s) template <typename _RetT, $templateargs> class Function$num: public Callback$num<_RetT, $argtypes> { public: @@ -140,7 +140,7 @@ FuncPtr _funcPtr; }; -//! Function callback class with $num argument (void specialisation) +//! Function callback class with $num argument(s) (void specialisation) template <$templateargs> class Function$num<void, $argtypes>: public Callback$num<void, $argtypes> { public: @@ -167,9 +167,9 @@ Function$num<_RetT, $argtypes> make_function(_RetT (*ptr)($argtypes)) throw() { return Function$num<_RetT, $argtypes>(ptr); } -/* ---------- Method1 ------------ */ +/* ---------- Method$num ------------ */ -//! Method callback class with $num arguments +//! Method callback class with $num argument(s) template <typename _RetT, class _ObjT, $templateargs> class Method$num: public Callback$num<_RetT, $argtypes> { public: @@ -192,7 +192,7 @@ FuncPtr _funcPtr; }; -//! Method callback class with $num arguments (void specialisation) +//! Method callback class with $num argument(s) (void specialisation) template <class _ObjT, $templateargs> class Method$num<void, _ObjT, $argtypes>: public Callback$num<void, $argtypes> { public: Index: Makefile.am =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/Makefile.am,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- Makefile.am 22 Jun 2005 11:33:41 -0000 1.16 +++ Makefile.am 29 Jun 2005 20:52:29 -0000 1.17 @@ -4,12 +4,15 @@ INCLUDES = METASOURCES = AUTO +BUILT_SOURCES = all_callbacks all_signals + all_callbacks: if [ ! -e "$(top_builddir)/include/pclasses/CallbackN1.h" ]; then bash $(top_srcdir)/include/pclasses/CallbackN.sh; fi if [ "$(top_builddir)/include/pclasses/CallbackN.sh" -nt "$(top_builddir)/include/pclasses/CallbackN1.h" ]; then bash $(top_srcdir)/include/pclasses/CallbackN.sh; fi -all_callbacks_clean: - rm -f CallbackN1.h CallbackN2.h CallbackN3.h CallbackN4.h +all_signals: + if [ ! -e "$(top_builddir)/include/pclasses/SignalN1.h" ]; then bash $(top_srcdir)/include/pclasses/SignalN.sh; fi + if [ "$(top_builddir)/include/pclasses/SignalN.sh" -nt "$(top_builddir)/include/pclasses/SignalN1.h" ]; then bash $(top_srcdir)/include/pclasses/SignalN.sh; fi pkginclude_HEADERS = Exception.h IntTypes.h ScopedArrayPtr.h ScopedPtr.h \ SharedPtr.h Alloc.h SourceInfo.h Atomic.h AtomicTraits.h ValueType.h LockTraits.h \ @@ -17,10 +20,8 @@ Stack.h LinkedItem.h Pair.h IntTypeLimits.h Queue.h IntrusivePtr.h \ CircularQueue.h List.h NonCopyable.h Phoenix.h CoreMutex.h Factory.h \ SharingContext.h Time.h Date.h DateTime.h TimeSpan.h Callback.h Signal.h \ + SignalN1.h SignalN2.h SignalN3.h SignalN4.h \ CallbackN1.h CallbackN2.h CallbackN3.h CallbackN4.h StringList.h \ Trace.h PropertyMap.h Export.h Buffer.h pclasses-config.h -all: all_callbacks - -clean: all_callbacks_clean - +CLEANFILES = CallbackN1.h CallbackN2.h CallbackN3.h CallbackN4.h SignalN1.h SignalN2.h SignalN3.h SignalN4.h Index: Signal.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/Signal.h,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- Signal.h 21 Jan 2005 14:51:10 -0000 1.4 +++ Signal.h 29 Jun 2005 20:52:29 -0000 1.5 @@ -131,145 +131,11 @@ } }; -/* -------------------- Signal1 ---------------- */ - -//! Base class for Signal1 -template <typename RetType, typename ArgType1> -class SignalBase1 { - public: - typedef std::list< - Callback1<RetType, ArgType1>* - > CallbackList; - - SignalBase1() - { } - - virtual ~SignalBase1() - { unbind_slots(_slots); } - - template <class CallbackType> - void bind(CallbackType slot) - { bind_slot(_slots, slot); } - - template <class CallbackType> - void unbind(CallbackType slot) - { unbind_slot(_slots, slot); } - - virtual RetType fire(ArgType1) const = 0; - - protected: - CallbackList _slots; -}; - -//! Signal with one argument -template <typename RetType, typename ArgType1> -class Signal1: public SignalBase1<RetType, ArgType1> { - typedef SignalBase1<RetType, ArgType1> BaseType; - - public: - RetType fire(ArgType1 arg1) const - { - RetType ret = RetType(); - typename BaseType::CallbackList::const_iterator i = this->_slots.begin(); - while(i != this->_slots.end()) - { - ret = (*i)->exec(arg1); - if(ret) - break; - ++i; - } - - return ret; - } -}; - -//! Signal with one arguments (void specialisation) -template <typename ArgType1> -class Signal1<void, ArgType1>: public SignalBase1<void, ArgType1> { - typedef SignalBase1<void, ArgType1> BaseType; - - public: - void fire(ArgType1 arg1) const - { - typename BaseType::CallbackList::const_iterator i = this->_slots.begin(); - while(i != this->_slots.end()) - { - (*i)->exec(arg1); - ++i; - } - } -}; - - -/* -------------------- Signal2 ---------------- */ - -//! Base class for Signal2 -template <typename RetType, typename ArgType1, typename ArgType2> -class SignalBase2 { - public: - typedef std::list< - Callback2<RetType, ArgType1, ArgType2>* - > CallbackList; - - SignalBase2() - { } - - virtual ~SignalBase2() - { unbind_slots(_slots); } - - template <class CallbackType> - void bind(CallbackType slot) - { bind_slot(_slots, slot); } - - template <class CallbackType> - void unbind(CallbackType slot) - { unbind_slot(_slots, slot); } - - virtual RetType fire(ArgType1, ArgType2) const = 0; - - protected: - CallbackList _slots; -}; - -//! Signal with two arguments -template <typename RetType, typename ArgType1, typename ArgType2> -class Signal2: public SignalBase2<RetType, ArgType1, ArgType2> { - typedef SignalBase2<RetType, ArgType1, ArgType2> BaseType; - - public: - RetType fire(ArgType1 arg1, ArgType2 arg2) const - { - RetType ret = RetType(); - typename BaseType::CallbackList::const_iterator i = this->_slots.begin(); - while(i != this->_slots.end()) - { - ret = (*i)->exec(arg1, arg2); - if(ret) - break; - ++i; - } - - return ret; - } -}; - -//! Signal with two arguments (void specialisation) -template <typename ArgType1, typename ArgType2> -class Signal2<void, ArgType1, ArgType2>: public SignalBase2<void, ArgType1, ArgType2> { - typedef SignalBase2<void, ArgType1, ArgType2> BaseType; - public: - void fire(ArgType1 arg1, ArgType2 arg2) const - { - typename BaseType::CallbackList::const_iterator i = this->_slots.begin(); - while(i != this->_slots.end()) - { - (*i)->exec(arg1, arg2); - ++i; - } - } -}; - - } // !namespace P +#include <pclasses/SignalN1.h> +#include <pclasses/SignalN2.h> +#include <pclasses/SignalN3.h> +#include <pclasses/SignalN4.h> + #endif |
From: Christian P. <cp...@us...> - 2005-06-29 20:19:51
|
Update of /cvsroot/pclasses/pclasses2/include/pclasses In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5928/include/pclasses Modified Files: Algorithm.h Log Message: - Details::construct(..., Traits::FalseType) is now exception safe - Added min() and max() Index: Algorithm.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/Algorithm.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- Algorithm.h 24 Dec 2004 16:49:14 -0000 1.2 +++ Algorithm.h 29 Jun 2005 20:19:41 -0000 1.3 @@ -18,8 +18,8 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ -#ifndef _P_Algorithm_h_ -#define _P_Algorithm_h_ +#ifndef P_Algorithm_h +#define P_Algorithm_h #include <pclasses/BasicTypes.h> #include <pclasses/TypeTraits.h> @@ -32,25 +32,42 @@ //! POD-type construction template <typename Type> -void construct(Type* dest, size_t count, Traits::TrueType) throw() +inline void construct(Type* dest, size_t count, Traits::TrueType) throw() { std::memset(dest, 0, sizeof(Type) * count); } //! Object-type construction template <typename Type> void construct(Type* dest, size_t count, Traits::FalseType) { - while(count--) - new(dest++) Type(); + Type* ptr = dest; + size_t n = count; + + try + { + while(n > 0) + { + new(ptr) Type(); + --n; + ++ptr; + } + } + catch(...) + { + // we must destruct previously constructed objects after + // receiving an exception ... + destruct(dest, count - n, Traits::FalseType()); + throw; + } } //! POD-type destruction template <typename Type> -void destruct(Type* dest, size_t count, Traits::TrueType) throw() +inline void destruct(Type* dest, size_t count, Traits::TrueType) throw() { } //! Object-type destruction template <typename Type> -void destruct(Type* dest, size_t count, Traits::FalseType) throw() +inline void destruct(Type* dest, size_t count, Traits::FalseType) throw() { while(count--) (dest++)->~Type(); @@ -58,13 +75,13 @@ //! POD-type copy construction template <typename Type> -void copy_construct(Type* dest, const Type* src, size_t count, +inline void copy_construct(Type* dest, const Type* src, size_t count, Traits::TrueType) throw() { std::memcpy(dest, src, sizeof(Type) * count); } //! Object-type copy construction template <typename Type> -void copy_construct(Type* dest, const Type* src, size_t count, +inline void copy_construct(Type* dest, const Type* src, size_t count, Traits::FalseType) { while(count--) @@ -73,41 +90,43 @@ //! POD-type copy template <typename Type> -void copy(Type* dest, const Type* src, size_t count, +inline void copy(Type* dest, const Type* src, size_t count, Traits::TrueType) throw() { std::memcpy(dest, src, sizeof(Type) * count); } //! Object-type copy construction template <typename Type> -void copy(Type* dest, const Type* src, size_t count, Traits::FalseType) +inline void copy(Type* dest, const Type* src, size_t count, Traits::FalseType) { while(count--) *dest++ = *src++; } -//! POD-type destructive-copy -template <typename Type> -void destructive_copy(Type* dest, Type* src, size_t count, - Traits::TrueType) throw() -{ std::memcpy(dest, src, sizeof(Type) * count); } +} // !namespace Details + +#undef min -//! Object-type destructive-copy template <typename Type> -void destructive_copy(Type* dest, Type* src, size_t count, Traits::FalseType) +inline const Type& min(const Type& a, const Type& b) { - while(count--) - { - *dest++ = *src; - destruct(src++, 1, - typename Traits::TypeTraits<Type>::HasTrivialCtor()); - } + if(a < b) + return a; + return b; } -} // !namespace Details +#undef max + +template <typename Type> +inline const Type& max(const Type& a, const Type& b) +{ + if(a > b) + return a; + return b; +} //! Construction algorithm template <typename Type> -void construct(Type* dest, size_t count) +inline void construct(Type* dest, size_t count) { Details::construct(dest, count, typename Traits::TypeTraits<Type>::HasTrivialCtor()); @@ -115,7 +134,7 @@ //! Destruction algorithm template <typename Type> -void destruct(Type* dest, size_t count) throw() +inline void destruct(Type* dest, size_t count) throw() { Details::destruct(dest, count, typename Traits::TypeTraits<Type>::HasTrivialCtor()); @@ -123,7 +142,7 @@ //! Copy-construction algorithm template <typename Type> -void copy_construct(Type* dest, const Type* src, size_t count) +inline void copy_construct(Type* dest, const Type* src, size_t count) { Details::copy_construct(dest, src, count, typename Traits::TypeTraits<Type>::HasTrivialCtor()); @@ -131,22 +150,14 @@ //! Copy algorithm template <typename Type> -void copy(Type* dest, const Type* src, size_t count) +inline void copy(Type* dest, const Type* src, size_t count) { Details::copy(dest, src, count, typename Traits::TypeTraits<Type>::HasTrivialCopy()); } -//! Destructive copy-algorithm -template <typename Type> -void destructive_copy(Type* dest, Type* src, size_t count) -{ - Details::destructive_copy(dest, src, count, - typename Traits::TypeTraits<Type>::HasTrivialCopy()); -} - template <typename Iterator> -size_t distance(Iterator begin, Iterator end) +inline size_t distance(Iterator begin, Iterator end) { size_t count = 0; for(; begin != end; ++begin) @@ -156,4 +167,4 @@ } // !namespace P -#endif // ! _P_Algorithm_h_ +#endif // ! P_Algorithm_h |
From: Christian P. <cp...@us...> - 2005-06-29 00:11:19
|
Update of /cvsroot/pclasses/pclasses2/src/App In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1010/src/App Modified Files: Config.cpp Log Message: - Changed ConfigSection::value_map from std::map to std::list to preserve order of config values Index: Config.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/App/Config.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- Config.cpp 22 Jun 2005 11:35:19 -0000 1.1 +++ Config.cpp 29 Jun 2005 00:11:10 -0000 1.2 @@ -59,11 +59,15 @@ { } -const Unicode::String& ConfigValue::value() const throw() +const Unicode::String& ConfigValue::toString() const throw() { return _value; } +StringList<Unicode::String> ConfigValue::toStringList() const +{ + return StringList<Unicode::String>(_value, ","); +} ConfigSection::ConfigSection(Config* cfg, const std::string& name) : _cfg(cfg), _name(name) @@ -193,13 +197,31 @@ ConfigSection::value_iterator ConfigSection::findValue(const std::string& name) throw() { - return _values.find(name); + value_iterator i = _values.begin(); + while(i != _values.end()) + { + if((*i).first == name) + break; + + ++i; + } + + return i; } ConfigSection::value_const_iterator ConfigSection::findValue(const std::string& name) const throw() { - return _values.find(name); + value_const_iterator i = _values.begin(); + while(i != _values.end()) + { + if((*i).first == name) + break; + + ++i; + } + + return i; } const ConfigValue& ConfigSection::value(const std::string& name, @@ -207,14 +229,13 @@ { value_iterator i = findValue(name); if(i != _values.end()) - return i->second; + return (*i).second; if(!add) throw ConfigError("Value not found", P_SOURCEINFO); const ConfigValue& val = - _values.insert(_values.begin(), - std::make_pair(name,ConfigValue()))->second; + (*_values.insert(_values.begin(), std::make_pair(name, ConfigValue()))).second; _cfg->setModified(); @@ -231,8 +252,7 @@ const ConfigValue* v = &defaultVal; if(add) { - v = &_values.insert(_values.begin(), - std::make_pair(name,defaultVal))->second; + v = &(*_values.insert(_values.begin(), std::make_pair(name, ConfigValue()))).second; _cfg->setModified(); } @@ -249,7 +269,7 @@ } else { - _values.insert(std::make_pair(name, val)); + _values.push_back(std::make_pair(name, val)); } } |
From: Christian P. <cp...@us...> - 2005-06-29 00:11:18
|
Update of /cvsroot/pclasses/pclasses2/include/pclasses/App In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1010/include/pclasses/App Modified Files: Config.h Log Message: - Changed ConfigSection::value_map from std::map to std::list to preserve order of config values Index: Config.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/App/Config.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- Config.h 22 Jun 2005 11:35:18 -0000 1.1 +++ Config.h 29 Jun 2005 00:11:09 -0000 1.2 @@ -52,9 +52,20 @@ { } ConfigValue(double value); + ConfigValue(Int32 value); + ConfigValue(UInt32 value); + ~ConfigValue() throw(); - const Unicode::String& value() const throw(); + const Unicode::String& toString() const throw(); + + StringList<Unicode::String> toStringList() const; + + double toDouble() const; + + Int32 toInt() const; + + UInt32 toUInt() const; private: Unicode::String _value; @@ -66,7 +77,7 @@ typedef section_list::iterator section_iterator; typedef section_list::const_iterator section_const_iterator; - typedef std::map<std::string, ConfigValue> value_map; + typedef std::list<std::pair<std::string, ConfigValue> > value_map; typedef value_map::iterator value_iterator; typedef value_map::const_iterator value_const_iterator; |
From: Christian P. <cp...@us...> - 2005-06-29 00:08:56
|
Update of /cvsroot/pclasses/pclasses2/plugins/ConfigStore/ini In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32139/plugins/ConfigStore/ini Modified Files: ConfigStore_ini.cpp Makefile.am Log Message: - Implemented ConfigStore_ini::load() Index: Makefile.am =================================================================== RCS file: /cvsroot/pclasses/pclasses2/plugins/ConfigStore/ini/Makefile.am,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- Makefile.am 22 Jun 2005 11:37:58 -0000 1.1 +++ Makefile.am 29 Jun 2005 00:08:47 -0000 1.2 @@ -2,10 +2,15 @@ METASOURCES = AUTO pkglib_LTLIBRARIES = ConfigStore_ini.la +noinst_PROGRAMS = lextest ConfigStore_ini_la_SOURCES = ConfigStore_ini.cpp ConfigStore_ini_la_LDFLAGS = -module -avoid-version +AM_YFLAGS = -d + +lextest_SOURCES = ini_lex.l ini_yacc.y + ConfigStore_ini_la_LIBADD = $(top_builddir)/src/libpclasses.la \ $(top_builddir)/src/Unicode/libpclasses_unicode.la \ $(top_builddir)/src/IO/libpclasses_io.la \ Index: ConfigStore_ini.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses2/plugins/ConfigStore/ini/ConfigStore_ini.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- ConfigStore_ini.cpp 22 Jun 2005 11:37:58 -0000 1.1 +++ ConfigStore_ini.cpp 29 Jun 2005 00:08:47 -0000 1.2 @@ -18,12 +18,14 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ +#include "pclasses/StringList.h" #include "pclasses/IO/IOStream.h" #include "pclasses/IO/IORequest.h" #include "pclasses/IO/IOManager.h" #include "pclasses/System/Plugin.h" #include "pclasses/App/Config.h" #include "pclasses/App/ConfigStore.h" +#include "pclasses/Util/StringTool.h" #include <list> using namespace P; @@ -42,6 +44,16 @@ void load() throw(IO::IOError) { + IOManager& ioMgr = IOManager::instance(); + + IORequest_Get* getReq = ioMgr.get(url()); + getReq->connect(); + + IOStream strm(*getReq); + loadConfig(strm); + + getReq->close(); + ioMgr.finish(getReq); } void save() throw(IO::IOError) @@ -63,13 +75,91 @@ private: typedef std::list<const ConfigSection*> section_list; + void loadConfig(IOStream& strm) + { + ConfigSection* currentSection = &config()->root(); + std::string line; + + while(!strm.eof()) + { + getline(strm, line); + + std::cout << line << std::endl; + + StringTool::trim(line); + + size_t lineLen = line.size(); + + // win32 uses '\r\n' for newline ... + if(lineLen > 0 && line.at(lineLen - 1) == '\r') + { + line.erase(lineLen - 1); + --lineLen; + } + + if(!lineLen) + continue; + + // comments ... + if(lineLen >= 1 && (line.at(0) == '#' || line.at(0) == ';')) + continue; + + // a new section begins ... + if(lineLen >= 2 && line.at(0) == '[' && line.at(lineLen - 1) == ']') + { + StringList<std::string> sectionNameList(line.substr(1, lineLen - 2), "\\"); + StringList<std::string>::const_iterator sni = sectionNameList.begin(); + currentSection = &config()->root(); + + while(sni != sectionNameList.end()) + { + currentSection = ¤tSection->section(*sni, true); + ++sni; + } + + continue; + } + + size_t equalPos = line.find('='); + + // invalid line, skip it + if(equalPos == std::string::npos || equalPos == 0) + continue; + + std::string valueName = line.substr(0, equalPos - 1); + StringTool::trim(valueName); + + std::string valueStr = line.substr(equalPos + 1); + StringTool::trim(valueStr); + + // remove quotes ... + size_t valueStrLen = valueStr.size(); + if(valueStrLen >= 2 && valueStr.at(0) == '\"' && valueStr.at(valueStrLen - 1) == '\"') + valueStr = valueStr.substr(1, valueStrLen - 2); + + currentSection->setValue(valueName, valueStr); + } + } + void saveSection(IOStream& strm, section_list& sectionContext, const ConfigSection& section) { ConfigSection::value_const_iterator vi = section.valuesBegin(); while(vi != section.valuesEnd()) { - strm << vi->first << " = " << vi->second.value().utf8() << std::endl; + std::string valueStr = vi->second.toString().utf8(); + size_t valueStrLen = valueStr.size(); + + strm << vi->first << " = "; + + // quote values with spaces at front or back ... + if(valueStrLen >= 1 && (valueStr.at(0) == ' ' || valueStr.at(valueStrLen - 1) == ' ')) + strm << '\"' << valueStr << '\"'; + else + strm << valueStr; + + strm << std::endl; + ++vi; } @@ -87,6 +177,7 @@ void saveSectionName(IOStream& strm, section_list& sectionContext) { + strm << std::endl; strm << '['; section_list::const_iterator i = sectionContext.begin(); while(i != sectionContext.end()) |
From: Christian P. <cp...@us...> - 2005-06-29 00:07:53
|
Update of /cvsroot/pclasses/pclasses2/src/Unicode In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31455/src/Unicode Modified Files: String.cpp Log Message: - Fixed a small bug in substring ctor of String Index: String.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/Unicode/String.cpp,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- String.cpp 22 Jun 2005 11:33:18 -0000 1.11 +++ String.cpp 29 Jun 2005 00:07:44 -0000 1.12 @@ -74,7 +74,7 @@ if(str._data.null()) return; - if(count == npos) + if(count == npos || count > str.size() - offset) count = str.size() - offset; _data = alloc(count * 2); |
From: Christian P. <cp...@us...> - 2005-06-29 00:06:44
|
Update of /cvsroot/pclasses/pclasses2/plugins/IOHandler/file In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30238/plugins/IOHandler/file Modified Files: IOHandler_file.cpp Log Message: - Fixed a small bug in IORequest_file_Get::read() Index: IOHandler_file.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses2/plugins/IOHandler/file/IOHandler_file.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- IOHandler_file.cpp 22 Jun 2005 11:40:04 -0000 1.3 +++ IOHandler_file.cpp 29 Jun 2005 00:06:35 -0000 1.4 @@ -56,7 +56,7 @@ if(!ret) setEof(true); - return true; + return ret; } private: |
From: Christian P. <cp...@us...> - 2005-06-22 11:41:14
|
Update of /cvsroot/pclasses/pclasses2/plugins/IOHandler/file In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16487/plugins/IOHandler/file Modified Files: Makefile.am Log Message: - Some Makefile.am dependency fixes Index: Makefile.am =================================================================== RCS file: /cvsroot/pclasses/pclasses2/plugins/IOHandler/file/Makefile.am,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- Makefile.am 25 May 2005 08:06:10 -0000 1.1 +++ Makefile.am 22 Jun 2005 11:40:33 -0000 1.2 @@ -7,5 +7,6 @@ IOHandler_file_la_LDFLAGS = -module -avoid-version IOHandler_file_la_LIBADD = $(top_builddir)/src/libpclasses.la \ + $(top_builddir)/src/Unicode/libpclasses_unicode.la \ $(top_builddir)/src/IO/libpclasses_io.la \ $(top_builddir)/src/System/libpclasses_system.la |
From: Christian P. <cp...@us...> - 2005-06-22 11:40:53
|
Update of /cvsroot/pclasses/pclasses2/plugins/LogTarget/File In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16487/plugins/LogTarget/File Modified Files: Makefile.am Log Message: - Some Makefile.am dependency fixes Index: Makefile.am =================================================================== RCS file: /cvsroot/pclasses/pclasses2/plugins/LogTarget/File/Makefile.am,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- Makefile.am 28 Apr 2005 11:24:43 -0000 1.1 +++ Makefile.am 22 Jun 2005 11:40:43 -0000 1.2 @@ -7,4 +7,7 @@ FileLogTarget_la_LDFLAGS = -module -avoid-version FileLogTarget_la_LIBADD = $(top_builddir)/src/libpclasses.la \ + $(top_builddir)/src/Unicode/libpclasses_unicode.la \ + $(top_builddir)/src/IO/libpclasses_io.la \ + $(top_builddir)/src/System/libpclasses_system.la \ $(top_builddir)/src/App/libpclasses_app.la |
From: Christian P. <cp...@us...> - 2005-06-22 11:40:53
|
Update of /cvsroot/pclasses/pclasses2/plugins/LogTarget/Console In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16487/plugins/LogTarget/Console Modified Files: Makefile.am Log Message: - Some Makefile.am dependency fixes Index: Makefile.am =================================================================== RCS file: /cvsroot/pclasses/pclasses2/plugins/LogTarget/Console/Makefile.am,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- Makefile.am 28 Apr 2005 11:16:36 -0000 1.3 +++ Makefile.am 22 Jun 2005 11:40:34 -0000 1.4 @@ -7,4 +7,7 @@ ConsoleLogTarget_la_LDFLAGS = -module -avoid-version ConsoleLogTarget_la_LIBADD = $(top_builddir)/src/libpclasses.la \ + $(top_builddir)/src/Unicode/libpclasses_unicode.la \ + $(top_builddir)/src/IO/libpclasses_io.la \ + $(top_builddir)/src/System/libpclasses_system.la \ $(top_builddir)/src/App/libpclasses_app.la |
From: Christian P. <cp...@us...> - 2005-06-22 11:40:23
|
Update of /cvsroot/pclasses/pclasses2/plugins/IOHandler/file In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16139/plugins/IOHandler/file Modified Files: IOHandler_file.cpp Log Message: - File should be resized to zero size, it may already exist Index: IOHandler_file.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses2/plugins/IOHandler/file/IOHandler_file.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- IOHandler_file.cpp 25 May 2005 09:34:59 -0000 1.2 +++ IOHandler_file.cpp 22 Jun 2005 11:40:04 -0000 1.3 @@ -73,6 +73,7 @@ void connect() throw(IOError) { _file.open(url().path(), IODevice::Write, IODevice::OpenCreate, IODevice::AllowRead); + _file.resize(0); setValid(true); setEof(false); setAccess(IODevice::Write); |
From: Christian P. <cp...@us...> - 2005-06-22 11:38:07
|
Update of /cvsroot/pclasses/pclasses2/plugins/ConfigStore/ini In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15277/plugins/ConfigStore/ini Added Files: Makefile.am ConfigStore_ini.cpp Log Message: - Added INI-Style ConfigStore plugin --- NEW FILE: Makefile.am --- INCLUDES = -I$(top_srcdir)/include -I$(top_builddir)/include $(all_includes) METASOURCES = AUTO pkglib_LTLIBRARIES = ConfigStore_ini.la ConfigStore_ini_la_SOURCES = ConfigStore_ini.cpp ConfigStore_ini_la_LDFLAGS = -module -avoid-version ConfigStore_ini_la_LIBADD = $(top_builddir)/src/libpclasses.la \ $(top_builddir)/src/Unicode/libpclasses_unicode.la \ $(top_builddir)/src/IO/libpclasses_io.la \ $(top_builddir)/src/System/libpclasses_system.la \ $(top_builddir)/src/App/libpclasses_app.la --- NEW FILE: ConfigStore_ini.cpp --- /*************************************************************************** * 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. * ***************************************************************************/ #include "pclasses/IO/IOStream.h" #include "pclasses/IO/IORequest.h" #include "pclasses/IO/IOManager.h" #include "pclasses/System/Plugin.h" #include "pclasses/App/Config.h" #include "pclasses/App/ConfigStore.h" #include <list> using namespace P; using namespace P::IO; using namespace P::App; class ConfigStore_ini: public ConfigStore { public: ConfigStore_ini() throw() { } ~ConfigStore_ini() throw() { } void load() throw(IO::IOError) { } void save() throw(IO::IOError) { IOManager& ioMgr = IOManager::instance(); IORequest_Put* putReq = ioMgr.put(url()); putReq->connect(); IOStream strm(*putReq); section_list sectionContext; saveSection(strm, sectionContext, config()->root()); strm.flush(); putReq->close(); ioMgr.finish(putReq); } private: typedef std::list<const ConfigSection*> section_list; void saveSection(IOStream& strm, section_list& sectionContext, const ConfigSection& section) { ConfigSection::value_const_iterator vi = section.valuesBegin(); while(vi != section.valuesEnd()) { strm << vi->first << " = " << vi->second.value().utf8() << std::endl; ++vi; } ConfigSection::section_const_iterator si = section.sectionsBegin(); while(si != section.sectionsEnd()) { sectionContext.push_back(*si); saveSectionName(strm, sectionContext); saveSection(strm, sectionContext, **si); sectionContext.pop_back(); ++si; } } void saveSectionName(IOStream& strm, section_list& sectionContext) { strm << '['; section_list::const_iterator i = sectionContext.begin(); while(i != sectionContext.end()) { strm << (*i)->name(); ++i; if(i != sectionContext.end()) strm << '\\'; } strm << ']' << std::endl; } }; P_PLUGIN_REGISTER_TYPE(ConfigStore, ConfigStore_ini); P_PLUGIN_REGISTER_ALIAS(ConfigStore, ini, ConfigStore_ini); |
From: Christian P. <cp...@us...> - 2005-06-22 11:38:06
|
Update of /cvsroot/pclasses/pclasses2/plugins In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15277/plugins Modified Files: Makefile.am Log Message: - Added INI-Style ConfigStore plugin Index: Makefile.am =================================================================== RCS file: /cvsroot/pclasses/pclasses2/plugins/Makefile.am,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- Makefile.am 25 May 2005 08:06:09 -0000 1.2 +++ Makefile.am 22 Jun 2005 11:37:57 -0000 1.3 @@ -1,2 +1,2 @@ -SUBDIRS = IOHandler LogTarget +SUBDIRS = IOHandler LogTarget ConfigStore |
From: Christian P. <cp...@us...> - 2005-06-22 11:38:06
|
Update of /cvsroot/pclasses/pclasses2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15277 Modified Files: configure.in Log Message: - Added INI-Style ConfigStore plugin Index: configure.in =================================================================== RCS file: /cvsroot/pclasses/pclasses2/configure.in,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- configure.in 25 May 2005 08:06:08 -0000 1.13 +++ configure.in 22 Jun 2005 11:37:57 -0000 1.14 @@ -281,7 +281,11 @@ plugins/LogTarget/File/Makefile \ plugins/IOHandler/Makefile \ plugins/IOHandler/file/Makefile \ - test/Makefile) + plugins/ConfigStore/Makefile \ + plugins/ConfigStore/ini/Makefile \ + test/Makefile \ + doc/Makefile \ + doc/Doxyfile) AC_PREFIX_CONFIG_H("PCLASSES", include/pclasses/config.h, include/pclasses/pclasses-config.h) |
From: Christian P. <cp...@us...> - 2005-06-22 11:38:06
|
Update of /cvsroot/pclasses/pclasses2/plugins/ConfigStore In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15277/plugins/ConfigStore Added Files: Makefile.am Log Message: - Added INI-Style ConfigStore plugin --- NEW FILE: Makefile.am --- SUBDIRS = ini |
From: Christian P. <cp...@us...> - 2005-06-22 11:36:59
|
Update of /cvsroot/pclasses/pclasses2/plugins/ConfigStore/ini In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14882/plugins/ConfigStore/ini Log Message: Directory /cvsroot/pclasses/pclasses2/plugins/ConfigStore/ini added to the repository |
From: Christian P. <cp...@us...> - 2005-06-22 11:36:59
|
Update of /cvsroot/pclasses/pclasses2/plugins/ConfigStore In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14882/plugins/ConfigStore Log Message: Directory /cvsroot/pclasses/pclasses2/plugins/ConfigStore added to the repository |
From: Christian P. <cp...@us...> - 2005-06-22 11:35:35
|
Update of /cvsroot/pclasses/pclasses2/src/App In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13726/src/App Modified Files: Makefile.am Added Files: ConfigStore.cpp Config.cpp Log Message: - Added ConfigStore, ConfigValue, ConfigSection, Config --- NEW FILE: Config.cpp --- /*************************************************************************** * 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. * ***************************************************************************/ #include "pclasses/Factory.h" #include "pclasses/App/Config.h" #include "pclasses/App/ConfigStore.h" namespace P { namespace App { ConfigError::ConfigError(const char* what, const SourceInfo& si) throw() : RuntimeError(what, si) { } ConfigError::~ConfigError() throw() { } ConfigValue::ConfigValue() { } ConfigValue::ConfigValue(const std::string& value) : _value(value) { } ConfigValue::ConfigValue(const Unicode::String& value) : _value(value) { } ConfigValue::ConfigValue(double value) { //@todo } ConfigValue::~ConfigValue() throw() { } const Unicode::String& ConfigValue::value() const throw() { return _value; } ConfigSection::ConfigSection(Config* cfg, const std::string& name) : _cfg(cfg), _name(name) { } ConfigSection::~ConfigSection() throw() { section_list::iterator i = _sections.begin(); while(i != _sections.end()) { delete *i; i = _sections.erase(i); } } const std::string& ConfigSection::name() const throw() { return _name; } ConfigSection::section_iterator ConfigSection::sectionsBegin() throw() { return _sections.begin(); } ConfigSection::section_const_iterator ConfigSection::sectionsBegin() const throw() { return _sections.begin(); } ConfigSection::section_iterator ConfigSection::sectionsEnd() throw() { return _sections.end(); } ConfigSection::section_const_iterator ConfigSection::sectionsEnd() const throw() { return _sections.end(); } ConfigSection::section_iterator ConfigSection::findSection(const std::string& name) throw() { section_iterator i = _sections.begin(); while(i != _sections.end()) { if((*i)->name() == name) break; ++i; } return i; } ConfigSection::section_const_iterator ConfigSection::findSection(const std::string& name) const throw() { section_const_iterator i = _sections.begin(); while(i != _sections.end()) { if((*i)->name() == name) break; ++i; } return i; } ConfigSection& ConfigSection::section(const std::string& name, bool add) throw(ConfigError) { section_iterator i = findSection(name); if(i != _sections.end()) return *(*i); if(!add) throw ConfigError("Section not found", P_SOURCEINFO); ConfigSection& sec = *(*_sections.insert(_sections.begin(), new ConfigSection(_cfg, name))); _cfg->setModified(); return sec; } bool ConfigSection::removeSection(const std::string& name) throw() { section_iterator i = findSection(name); if(i != _sections.end()) { delete *i; _sections.erase(i); _cfg->setModified(); return true; } return false; } ConfigSection::value_iterator ConfigSection::valuesBegin() throw() { return _values.begin(); } ConfigSection::value_const_iterator ConfigSection::valuesBegin() const throw() { return _values.begin(); } ConfigSection::value_iterator ConfigSection::valuesEnd() throw() { return _values.end(); } ConfigSection::value_const_iterator ConfigSection::valuesEnd() const throw() { return _values.end(); } ConfigSection::value_iterator ConfigSection::findValue(const std::string& name) throw() { return _values.find(name); } ConfigSection::value_const_iterator ConfigSection::findValue(const std::string& name) const throw() { return _values.find(name); } const ConfigValue& ConfigSection::value(const std::string& name, bool add) throw(ConfigError) { value_iterator i = findValue(name); if(i != _values.end()) return i->second; if(!add) throw ConfigError("Value not found", P_SOURCEINFO); const ConfigValue& val = _values.insert(_values.begin(), std::make_pair(name,ConfigValue()))->second; _cfg->setModified(); return val; } const ConfigValue& ConfigSection::value(const std::string& name, const ConfigValue& defaultVal, bool add) { value_iterator i = findValue(name); if(i != _values.end()) return i->second; const ConfigValue* v = &defaultVal; if(add) { v = &_values.insert(_values.begin(), std::make_pair(name,defaultVal))->second; _cfg->setModified(); } return *v; } void ConfigSection::setValue(const std::string& name, const ConfigValue& val) { value_iterator i = findValue(name); if(i != _values.end()) { i->second = val; _cfg->setModified(); } else { _values.insert(std::make_pair(name, val)); } } bool ConfigSection::removeValue(const std::string& name) throw() { value_iterator i = findValue(name); if(i != _values.end()) { _values.erase(i); _cfg->setModified(); return true; } return false; } bool ConfigSection::hasValue(const std::string& name) const throw() { value_const_iterator i = findValue(name); return i != _values.end() ? true : false; } Config::Config(const IO::URL& url, const std::string& cfgStoreType) throw(ConfigError, IO::IOError) : _store(0), _modified(false), _root(this, "") { ConfigStore* store = createConfigStore(cfgStoreType); store->init(this, url); _store = store; reload(); } Config::~Config() throw() { try { save(); } catch(...) { } delete _store; } void Config::reload() throw(IO::IOError) { _store->load(); _modified = false; } void Config::save() throw(IO::IOError) { if(_modified) { _store->save(); _modified = false; } } void Config::saveAs(const IO::URL& url, const std::string& cfgStoreType, bool clearModified) throw(ConfigError, IO::IOError) { ConfigStore* store = createConfigStore(cfgStoreType); try { store->init(this, url); store->save(); } catch(...) { delete store; throw; } if(clearModified) _modified = false; } ConfigSection& Config::root() throw() { return _root; } void Config::setModified() throw() { if(!_modified) _modified = true; } ConfigStore* Config::createConfigStore(const std::string& cfgStoreType) throw(ConfigError) { ConfigStore* store = Factory<ConfigStore>::instance().create("ConfigStore_" + cfgStoreType); if(!store) throw ConfigError("Unknown config storage type", P_SOURCEINFO); return store; } } // !namespace App } // !namespace P Index: Makefile.am =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/App/Makefile.am,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- Makefile.am 20 Jan 2005 11:05:57 -0000 1.6 +++ Makefile.am 22 Jun 2005 11:35:19 -0000 1.7 @@ -5,7 +5,8 @@ CPPFLAGS = -DPAPP_BUILD libpclasses_app_la_SOURCES = AppDetails.cpp LogMessage.cpp LogTarget.cpp \ - LogChannel.cpp LogManager.cpp SimpleApp.cpp BackgroundApp.cpp CmdLine.cpp + LogChannel.cpp LogManager.cpp SimpleApp.cpp BackgroundApp.cpp CmdLine.cpp \ + ConfigStore.cpp Config.cpp libpclasses_app_la_LDFLAGS = -no-undefined --- NEW FILE: ConfigStore.cpp --- /*************************************************************************** * 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. * ***************************************************************************/ #include "pclasses/App/ConfigStore.h" namespace P { namespace App { ConfigStore::ConfigStore() throw() : _config(0) { } ConfigStore::~ConfigStore() throw() { } void ConfigStore::init(Config* cfg, const IO::URL& url) throw() { _config = cfg; _url = url; } Config* ConfigStore::config() const throw() { return _config; } const IO::URL& ConfigStore::url() const throw() { return _url; } } // !namespace App } // !namespace P |
From: Christian P. <cp...@us...> - 2005-06-22 11:35:35
|
Update of /cvsroot/pclasses/pclasses2/include/pclasses/App In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13726/include/pclasses/App Modified Files: Makefile.am Added Files: ConfigStore.h Config.h Log Message: - Added ConfigStore, ConfigValue, ConfigSection, Config --- NEW FILE: Config.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_App_Config_h #define P_App_Config_h #include <pclasses/Export.h> #include <pclasses/Exception.h> #include <pclasses/StringList.h> #include <pclasses/Unicode/String.h> #include <pclasses/IO/IOError.h> #include <pclasses/IO/URL.h> #include <pclasses/App/ConfigStore.h> #include <string> namespace P { namespace App { class PAPP_EXPORT ConfigError: public RuntimeError { public: ConfigError(const char* what, const SourceInfo& si) throw(); ~ConfigError() throw(); }; class PAPP_EXPORT ConfigValue { public: ConfigValue(); ConfigValue(const std::string& value); ConfigValue(const Unicode::String& value); template <class StringType> ConfigValue(const StringList<StringType>& value) : _value(value.join(",")) { } ConfigValue(double value); ~ConfigValue() throw(); const Unicode::String& value() const throw(); private: Unicode::String _value; }; class PAPP_EXPORT ConfigSection { public: typedef std::list<ConfigSection*> section_list; typedef section_list::iterator section_iterator; typedef section_list::const_iterator section_const_iterator; typedef std::map<std::string, ConfigValue> value_map; typedef value_map::iterator value_iterator; typedef value_map::const_iterator value_const_iterator; const std::string& name() const throw(); section_iterator sectionsBegin() throw(); section_const_iterator sectionsBegin() const throw(); section_iterator sectionsEnd() throw(); section_const_iterator sectionsEnd() const throw(); section_iterator findSection(const std::string& name) throw(); section_const_iterator findSection(const std::string& name) const throw(); ConfigSection& section(const std::string& name, bool add = false) throw(ConfigError); bool removeSection(const std::string& name) throw(); value_iterator valuesBegin() throw(); value_const_iterator valuesBegin() const throw(); value_iterator valuesEnd() throw(); value_const_iterator valuesEnd() const throw(); value_iterator findValue(const std::string& name) throw(); value_const_iterator findValue(const std::string& name) const throw(); const ConfigValue& value(const std::string& name, bool add = false) throw(ConfigError); const ConfigValue& value(const std::string& name, const ConfigValue& defaultVal, bool add = false); void setValue(const std::string& name, const ConfigValue& val); bool removeValue(const std::string& name) throw(); bool hasValue(const std::string& name) const throw(); protected: friend class Config; ConfigSection(Config* cfg, const std::string& name); ~ConfigSection() throw(); private: Config* _cfg; std::string _name; section_list _sections; value_map _values; }; class PAPP_EXPORT Config { public: Config(const IO::URL& url, const std::string& cfgStoreType) throw(ConfigError, IO::IOError); ~Config() throw(); void reload() throw(IO::IOError); void save() throw(IO::IOError); void saveAs(const IO::URL& url, const std::string& cfgStoreType, bool clearModified = false) throw(ConfigError, IO::IOError); ConfigSection& root() throw(); protected: friend class ConfigSection; void setModified() throw(); private: static ConfigStore* createConfigStore(const std::string& cfgStoreType) throw(ConfigError); ConfigStore* _store; bool _modified; ConfigSection _root; }; } // !namespace App } // !namespace P #endif // !P_App_Config_h Index: Makefile.am =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/App/Makefile.am,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- Makefile.am 20 Jan 2005 11:05:56 -0000 1.4 +++ Makefile.am 22 Jun 2005 11:35:18 -0000 1.5 @@ -3,4 +3,5 @@ INCLUDES = METASOURCES = AUTO pclasses_app_include_HEADERS = AppDetails.h LogMessage.h LogTarget.h \ - LogChannel.h LogManager.h SimpleApp.h BackgroundApp.h CmdLine.h + LogChannel.h LogManager.h SimpleApp.h BackgroundApp.h CmdLine.h \ + ConfigStore.h Config.h --- NEW FILE: ConfigStore.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_App_ConfigStore_h #define P_App_ConfigStore_h #include <pclasses/Export.h> #include <pclasses/IO/IOError.h> #include <pclasses/IO/URL.h> namespace P { namespace App { class Config; class PAPP_EXPORT ConfigStore { public: ConfigStore() throw(); virtual ~ConfigStore() throw(); void init(Config* cfg, const IO::URL& url) throw(); virtual void load() throw(IO::IOError) = 0; virtual void save() throw(IO::IOError) = 0; protected: Config* config() const throw(); const IO::URL& url() const throw(); private: Config* _config; IO::URL _url; }; } // !namespace App } // !namespace P #endif // !P_App_ConfigStore_h |
From: Christian P. <cp...@us...> - 2005-06-22 11:33:52
|
Update of /cvsroot/pclasses/pclasses2/include/pclasses In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13069/include/pclasses Modified Files: Makefile.am Log Message: - Added StringList.h to Makefile.am Index: Makefile.am =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/Makefile.am,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- Makefile.am 3 Jun 2005 09:47:42 -0000 1.15 +++ Makefile.am 22 Jun 2005 11:33:41 -0000 1.16 @@ -17,7 +17,7 @@ Stack.h LinkedItem.h Pair.h IntTypeLimits.h Queue.h IntrusivePtr.h \ CircularQueue.h List.h NonCopyable.h Phoenix.h CoreMutex.h Factory.h \ SharingContext.h Time.h Date.h DateTime.h TimeSpan.h Callback.h Signal.h \ - CallbackN1.h CallbackN2.h CallbackN3.h CallbackN4.h \ + CallbackN1.h CallbackN2.h CallbackN3.h CallbackN4.h StringList.h \ Trace.h PropertyMap.h Export.h Buffer.h pclasses-config.h all: all_callbacks |
From: Christian P. <cp...@us...> - 2005-06-22 11:33:30
|
Update of /cvsroot/pclasses/pclasses2/include/pclasses/Unicode In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12693/include/pclasses/Unicode Modified Files: String.h Log Message: - Added String::insert(size_t pos, size_t n, const Char& ch) - Added String::insert(size_t pos, const String& str) Index: String.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/Unicode/String.h,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- String.h 24 May 2005 02:32:59 -0000 1.7 +++ String.h 22 Jun 2005 11:33:17 -0000 1.8 @@ -104,6 +104,9 @@ String& append(const String& str); String& append(const Char& ch); + String& insert(size_t pos, size_t n, const Char& ch); + String& insert(size_t pos, const String& str); + size_t find(const String& str, size_t pos = 0) const; size_t find(const Char& ch, size_t pos = 0) const; |
From: Christian P. <cp...@us...> - 2005-06-22 11:33:30
|
Update of /cvsroot/pclasses/pclasses2/src/Unicode In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12693/src/Unicode Modified Files: String.cpp Log Message: - Added String::insert(size_t pos, size_t n, const Char& ch) - Added String::insert(size_t pos, const String& str) Index: String.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/Unicode/String.cpp,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- String.cpp 24 May 2005 04:41:21 -0000 1.10 +++ String.cpp 22 Jun 2005 11:33:18 -0000 1.11 @@ -301,6 +301,59 @@ #define getUCharOffset(data, pos, offset) U16_FWD_N(data->str, offset, data->length, pos) +String& String::insert(size_t pos, size_t n, const Char& ch) +{ + if(_data.null()) + { + _data = alloc(pos + n); + //@todo .. zero all chars + } + else if(_data->size <= _data->length + pos + n) + resize(_data->length + pos + n); + else + deepCopy(); + + // get the initial uchar16 offset specified by codepoint pos + size_t offset = 0; + getUCharOffset(_data, pos, offset); + + u_strncpy(_data->str + offset + n, + _data->str + n, + _data->length - offset); + + for(size_t i = 0; i < n; ++i) + *(_data->str + offset + i) = ch; + + _data->length += n; + return *this; +} + +String& String::insert(size_t pos, const String& str) +{ + if(_data.null()) + { + _data = alloc(pos + str._data->length); + //@todo .. zero all chars + } + else if(_data->size <= _data->length + pos + str._data->length) + resize(_data->length + pos + str._data->length); + else + deepCopy(); + + // get the initial uchar16 offset specified by codepoint pos + size_t offset = 0; + getUCharOffset(_data, pos, offset); + + u_strncpy(_data->str + offset + str._data->length, + _data->str + str._data->length, + _data->length - offset); + + u_strncpy(_data->str + offset, str._data->str, str._data->length); + + _data->length += str._data->length; + return *this; +} + size_t String::find(const String& str, size_t pos/*=0*/) const { if(str._data.null() || !str._data->length) |
From: Christian P. <cp...@us...> - 2005-06-16 13:11:59
|
Update of /cvsroot/pclasses/pclasses2/include/pclasses In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29160/include/pclasses Modified Files: Phoenix.h Log Message: - Replaced old tracing messaging with P_TRACE ones Index: Phoenix.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/Phoenix.h,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- Phoenix.h 24 Dec 2004 23:04:29 -0000 1.4 +++ Phoenix.h 16 Jun 2005 13:11:49 -0000 1.5 @@ -10,22 +10,9 @@ //////////////////////////////////////////////////////////////////////////////// #include <stdlib.h> // atexit() -#include <iostream> // cout/cerr, only for debuggering - - -#ifndef phoenix_DEBUG -// enable debuggering to see when phoenixes are (re)created. -# define phoenix_DEBUG 0 -#endif +#include <typeinfo> -#if phoenix_DEBUG -# include <typeinfo> -# define phoenix_CERR std::cerr << __FILE__ << ":" << std::dec << __LINE__ << " : " \ - << "Phoenix<"<<typeid((base_type *)NULL).name()<<" , " \ - << typeid((context_type *)NULL).name()<<"> " -#else -# define phoenix_CERR if(0) std::cerr -#endif // phoenix_DEBUG +#include <pclasses/Trace.h> /** The Phoenix class acts as a wrapper for adding "phoenixing" behaviour to @@ -162,18 +149,26 @@ static bool donethat = false; if( this_type::m_destroyed ) { - phoenix_CERR << "Phoenixing!" << std::endl; + P_TRACE_GLOBAL() << "Phoenix<" << typeid(BaseType).name() + << "," << typeid(ContextType).name() << "> Phoenixing!"; + donethat = false; new( &meyers ) this_type; atexit( this_type::do_atexit ); } if( !donethat ) { - phoenix_CERR << "initializing instance" << std::endl; + P_TRACE_GLOBAL() << "Phoenix<" << typeid(BaseType).name() + << "," << typeid(ContextType).name() << "> init instance"; + donethat = true; initializer_type()( meyers ); } - phoenix_CERR << "instance() == " <<std::hex<<&meyers<<std::endl; + + P_TRACE_GLOBAL() << "Phoenix<" << typeid(BaseType).name() + << "," << typeid(ContextType).name() << ">::instance() == " + << std::hex << &meyers; + return meyers; } @@ -186,13 +181,13 @@ Phoenix() { - phoenix_CERR << "Phoenix() @" << std::hex<< this << std::endl; + P_TRACE(Phoenix) << "Phoenix()"; m_destroyed = false; } virtual ~Phoenix() throw() { - phoenix_CERR << "~Phoenix() @" << std::hex<< this << std::endl; + P_TRACE(Phoenix) << "~Phoenix()"; m_destroyed = true; } /** @@ -201,7 +196,7 @@ static void do_atexit() { if( m_destroyed ) return; - phoenix_CERR << "::do_atexit() @ " << std::hex << &instance() << std::endl; + P_TRACE_GLOBAL() << "Phoenix::do_atexit() @ " << std::hex << & instance(); static_cast<this_type &>(instance()).~Phoenix(); // will eventually trigger the BaseType dtor } @@ -210,6 +205,4 @@ } // namespace -#undef phoenix_DEBUG -#undef phoenix_CERR #endif // p_PHOENIX_HPP_INCLUDED |
From: Christian P. <cp...@us...> - 2005-06-16 13:10:56
|
Update of /cvsroot/pclasses/pclasses2/src/System In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28447/src/System Modified Files: PathFinder.cpp Log Message: - Small cleanup, doesnt use Path::absPath() twice now Index: PathFinder.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/System/PathFinder.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- PathFinder.cpp 24 May 2005 04:19:49 -0000 1.8 +++ PathFinder.cpp 16 Jun 2005 13:10:44 -0000 1.9 @@ -112,12 +112,15 @@ return emptyStr; #define CHECKPATH(CHECKAT) \ - P_TRACE(PathFinder) << "testing '" << CHECKAT << "'"; \ - if( ! CHECKAT.empty() && Path(CHECKAT).isAccessible() ) \ { \ - P_TRACE(PathFinder) << "found '" << CHECKAT << "'"; \ - return _hitcache.insert(std::make_pair(resource, CHECKAT)).first->second; \ - } + Path tmpPath(CHECKAT); \ + P_TRACE(PathFinder) << "testing '" << CHECKAT << "'"; \ + if( ! CHECKAT.empty() && tmpPath.isAccessible() ) \ + { \ + P_TRACE(PathFinder) << "found '" << CHECKAT << "'"; \ + return _hitcache.insert(std::make_pair(resource, tmpPath.absPath())).first->second; \ + } \ + } \ if(check_cache) { @@ -143,11 +146,9 @@ while(piter != _paths.end()) { path = (*piter); + if(!path.empty()) - { - path = Path(path).absPath(); path += Unicode::String::fromAscii(Path::separator()); - } ++piter; |