Main Page   Class Hierarchy   Compound List   File List   Compound Members  

resConfigRegistry.imp.h

00001 //////////////////////////////////////////////////////////////////////
00002 // Copyright (c) 2001-2003 David Pritchard <drpritch@alumni.uwaterloo.ca>
00003 // 
00004 // This program is free software; you can redistribute it and/or
00005 // modify it under the terms of the GNU Lesser General Public License
00006 // as published by the Free Software Foundation; either
00007 // version 2 of the License, or (at your option) any later
00008 // version.
00009 // 
00010 // This program is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU Lesser General Public License for more details.
00014 // 
00015 // You should have received a copy of the GNU Lesser General Public License
00016 // along with this program; if not, write to the Free Software
00017 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00018 
00019 #ifndef freecloth_resmgt_resConfigRegistry_imp_h
00020 #define freecloth_resmgt_resConfigRegistry_imp_h
00021 
00022 #include <freecloth/resmgt/resConfigRegistry.h>
00023 #include <freecloth/base/baStringUtil.h>
00024 
00025 FREECLOTH_NAMESPACE_START
00026 
00027 ////////////////////////////////////////////////////////////////////////////////
00028 // CLASS ResConfigRegistryW
00029 
00030 //------------------------------------------------------------------------------
00031 
00032 template <class T>
00033 void ResConfigRegistryW::writeFloats(
00034     const String& key,
00035     const T& values
00036 ) {
00037     typename T::const_iterator i = values.begin();
00038     String string;
00039     if ( i != values.end() ) {
00040         string = BaStringUtil::fromFloat( *i );
00041         for ( ++i; i != values.end(); ++i ) {
00042             string += " " + BaStringUtil::fromFloat( *i );
00043         }
00044     }
00045     writeString( key, string );
00046 }
00047 
00048 //------------------------------------------------------------------------------
00049 
00050 #if HAVE_MEMBER_TEMPLATES
00051 template <class T>
00052 void ResConfigRegistryR::readFloats(
00053     const String& key,
00054     T& result,
00055     const T& def
00056 ) {
00057     if ( hasKey( key ) ) {
00058         result.clear();
00059         String s = readString( key );
00060         String::size_type startPos = 0;
00061         String::size_type spacePos = s.find_first_of( ' ', startPos );
00062         while ( spacePos != String::npos ) {
00063             result.push_back(
00064                 BaStringUtil::toFloat( s.substr( startPos, spacePos ) )
00065             );
00066             startPos = spacePos + 1;
00067             spacePos = s.find_first_of( ' ', startPos );
00068         }
00069         result.push_back(
00070             BaStringUtil::toFloat( s.substr( startPos ) )
00071         );
00072     }
00073     else {
00074         result = def;
00075     }
00076 }
00077 #endif
00078 
00079 FREECLOTH_NAMESPACE_END
00080 
00081 #endif

Generated on Wed Apr 23 15:58:46 2003 for Freecloth by doxygen1.3-rc3