Home C-Bits Package Documentation Project Page

Main Page   Namespace List   Compound List   File List   Compound Members  

PropertyList.h

Go to the documentation of this file.
00001 /* ====================================================================
00002  *              The CBITS Software License, Version 1.0
00003  *
00004  *               Copyright (c) 2002-2003 Bruce Lowery
00005  *                       All rights reserved
00006  *
00007  * Redistribution and use of this software, in source and binary forms, 
00008  * with or without modification, are permitted provided that the above 
00009  * copyright notice, this paragraph, and the following paragraph are 
00010  * retained in each source code file.
00011  *
00012  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
00013  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00014  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00015  * DISCLAIMED.  IN NO EVENT SHALL BRUCE LOWERY OR OTHER CONTRIBUTORS 
00016  * TO THE CBITS LIBRARY BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00017  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00018  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
00019  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
00020  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00021  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
00022  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00023  * SUCH DAMAGE.
00024  * ====================================================================
00025  */
00026 #ifndef __PROPERTYLIST_H__
00027 #define __PROPERTYLIST_H__
00028 
00029 #include <map>
00030 #include <string>
00031 #include <vector>
00032 
00054 namespace cbits
00055 {
00056 
00071 class PropertyList
00072 {
00073 
00074 public:
00075 
00082     static PropertyList& getPropertyList
00083     ( 
00084         const std::string& name 
00089     );
00090 
00091 
00096     static void removePropertyList
00097     ( 
00098         const std::string& name 
00103     );
00104 
00105 
00110     static void removeAll();
00111 
00112 
00117     static int getNumPropertyLists();
00118 
00119 
00127     static const bool exists
00128     ( 
00129         const std::string& name 
00133     );
00134 
00135 
00140     void setProperty
00141     ( 
00142         const std::string & property_name, 
00147         const std::string & property_value 
00151     );
00152 
00153 
00161     const char * getProperty
00162     ( 
00163         const std::string & property_name 
00167     );
00168 
00169 
00176     const bool isSet
00177     ( 
00178         const char* name 
00182     );
00183 
00184 
00191     const int getNumProperties() const;
00192 
00193 
00204     std::vector< std::string > & getValues( void );
00205 
00206 
00216     std::vector< std::string > & getKeys( void );
00217 
00218 
00223     void removeProperties();
00224 
00225 
00240     const bool readPropertyList
00241     ( 
00242         std::istream& prop_stream,
00247         const bool override  =  true,
00254         const char nv_delim  =  '=', 
00259         const char cmt_delim =  '#' 
00263     );
00264 
00265 
00281     const bool readFile
00282     ( 
00283         const char* const path, 
00288         const bool override  =  true,
00295         const char nv_delim  =  '=', 
00300         const char cmt_delim =  '#' 
00304     );
00305 
00306 
00314     const bool writePropertyList 
00315     (
00316         std::ostream& os,
00320         const char delim = '='
00324     ) const;
00325 
00326 
00333     const int readCommandLine
00334     (
00335         const int argc, 
00340         const char* const * argv,
00345         const bool override = true,
00351         const char delim = '='
00355     );
00356 
00357 
00364     static std::string trim
00365     ( 
00366         const std::string& line 
00370     );
00371 
00372 
00373 
00374 private:
00375 
00376     std::map< std::string, std::string > _properties;
00381     std::vector< std::string > _values;
00386     std::vector< std::string > _keys;
00393 protected: 
00394 
00398     PropertyList();
00399 
00403     static std::map< std::string, PropertyList* >& getSets();
00404 
00405 
00406 private:
00407 
00408     /* Holds property sets */
00409     static std::map< std::string, PropertyList* > _sets;
00410 
00411 
00412     /* This iterator is used internally */
00413     typedef std::map<std::string,std::string>::const_iterator PITERATOR;
00418     PropertyList( const PropertyList& );
00423     PropertyList& operator=( const PropertyList& );
00428 }; /* END OF CLASS PropertyList */
00429 
00430 
00431 }; /* END OF NAMESPACE cbits */
00432 
00433 #endif /* PropertyList_H */
00434 
00435 /*
00436  * $Id: PropertyList.h,v 1.5 2002/10/16 02:47:20 brulow Exp $
00437  *
00438  * History: (Add nothing manually below)
00439  * -----------------------------------------------------------------------
00440  *
00441  * $Log: PropertyList.h,v $
00442  * Revision 1.5  2002/10/16 02:47:20  brulow
00443  * build libs with compiler instead of raw 'ld'.
00444  *
00445  * Revision 1.4  2002/10/09 02:02:26  brulow
00446  * Improve package documentation
00447  *
00448  * Revision 1.3  2002/10/08 17:11:20  brulow
00449  * Improve documentation
00450  *
00451  * Revision 1.2  2002/10/04 20:04:20  brulow
00452  * Enhance interface
00453  *
00454  * Revision 1.1  2002/10/03 16:04:47  brulow
00455  * Add
00456  *
00457  *
00458  */

Generated by
doxygen
Hosted by
SourceForge