activemq-cpp-3.4.0

src/main/decaf/util/Properties.h

Go to the documentation of this file.
00001 /*
00002  * Licensed to the Apache Software Foundation (ASF) under one or more
00003  * contributor license agreements.  See the NOTICE file distributed with
00004  * this work for additional information regarding copyright ownership.
00005  * The ASF licenses this file to You under the Apache License, Version 2.0
00006  * (the "License"); you may not use this file except in compliance with
00007  * the License.  You may obtain a copy of the License at
00008  *
00009  *     http://www.apache.org/licenses/LICENSE-2.0
00010  *
00011  * Unless required by applicable law or agreed to in writing, software
00012  * distributed under the License is distributed on an "AS IS" BASIS,
00013  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  * See the License for the specific language governing permissions and
00015  * limitations under the License.
00016  */
00017 
00018 #ifndef _DECAF_UTIL_PROPERTIES_H_
00019 #define _DECAF_UTIL_PROPERTIES_H_
00020 
00021 #include <vector>
00022 #include <string>
00023 #include <decaf/util/Config.h>
00024 #include <decaf/util/StlMap.h>
00025 #include <decaf/io/InputStream.h>
00026 #include <decaf/io/OutputStream.h>
00027 #include <decaf/lang/Pointer.h>
00028 #include <decaf/lang/exceptions/IllegalArgumentException.h>
00029 #include <decaf/lang/exceptions/NullPointerException.h>
00030 #include <decaf/io/IOException.h>
00031 
00032 namespace decaf{
00033 namespace io{
00034     class Reader;
00035     class Writer;
00036 }
00037 namespace util{
00038 
00039     class PropertiesInternal;
00040 
00053     class DECAF_API Properties{
00054     private:
00055 
00056         PropertiesInternal* internal;
00057 
00058     protected:
00059 
00064         decaf::lang::Pointer<Properties> defaults;
00065 
00066     public:
00067 
00068         Properties();
00069 
00070         Properties( const Properties& src );
00071 
00072         virtual ~Properties();
00073 
00082         Properties& operator= ( const Properties& src );
00083 
00089         bool isEmpty() const;
00090 
00094         int size() const;
00095 
00105         const char* getProperty( const std::string& name ) const;
00106 
00118         std::string getProperty( const std::string& name, const std::string& defaultValue ) const;
00119 
00131         std::string setProperty( const std::string& name, const std::string& value );
00132 
00141         bool hasProperty( const std::string& name ) const;
00142 
00151         std::string remove( const std::string& name );
00152 
00161         std::vector<std::string> propertyNames() const;
00162 
00169         std::vector< std::pair< std::string, std::string > > toArray() const;
00170 
00178         void copy( const Properties& source );
00179 
00185         Properties* clone() const;
00186 
00190         void clear();
00191 
00204         bool equals( const Properties& source ) const;
00205 
00211         std::string toString() const;
00212 
00227         void load( decaf::io::InputStream* stream );
00228 
00328         void load( decaf::io::Reader* reader );
00329 
00358         void store( decaf::io::OutputStream* out, const std::string& comment );
00359 
00396         void store( decaf::io::Writer* writer, const std::string& comments );
00397 
00398     private:
00399 
00400         void selectProperties( decaf::util::StlMap<std::string, std::string>& selectProperties ) const;
00401 
00402     };
00403 
00404 }}
00405 
00406 #endif /*_DECAF_UTIL_PROPERTIES_H_*/