source: XMLIO_V2/external/include/Poco/Util/PropertyFileConfiguration.h @ 80

Last change on this file since 80 was 80, checked in by ymipsl, 14 years ago

ajout lib externe

  • Property svn:eol-style set to native
File size: 4.4 KB
Line 
1//
2// PropertyFileConfiguration.h
3//
4// $Id: //poco/1.3/Util/include/Poco/Util/PropertyFileConfiguration.h#1 $
5//
6// Library: Util
7// Package: Configuration
8// Module:  PropertyFileConfiguration
9//
10// Definition of the PropertyFileConfiguration class.
11//
12// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
13// and Contributors.
14//
15// Permission is hereby granted, free of charge, to any person or organization
16// obtaining a copy of the software and accompanying documentation covered by
17// this license (the "Software") to use, reproduce, display, distribute,
18// execute, and transmit the Software, and to prepare derivative works of the
19// Software, and to permit third-parties to whom the Software is furnished to
20// do so, all subject to the following:
21//
22// The copyright notices in the Software and this entire statement, including
23// the above license grant, this restriction and the following disclaimer,
24// must be included in all copies of the Software, in whole or in part, and
25// all derivative works of the Software, unless such copies or derivative
26// works are solely in the form of machine-executable object code generated by
27// a source language processor.
28//
29// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
30// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
31// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
32// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
33// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
34// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
35// DEALINGS IN THE SOFTWARE.
36//
37
38
39#ifndef Util_PropertyFileConfiguration_INCLUDED
40#define Util_PropertyFileConfiguration_INCLUDED
41
42
43#include "Poco/Util/Util.h"
44#include "Poco/Util/MapConfiguration.h"
45#include <istream>
46#include <ostream>
47
48
49namespace Poco {
50namespace Util {
51
52
53class Util_API PropertyFileConfiguration: public MapConfiguration
54        /// This implementation of a Configuration reads properties
55        /// from a Java-style properties file.
56        ///
57        /// The file syntax is implemented as follows.
58        ///   - a line starting with a hash '#' or exclamation mark '!' is treated as a comment and ignored
59        ///   - every other line denotes a property assignment in the form
60        ///     <key> = <value> or
61        ///     <key> : <value>
62        ///
63        /// Keys and values may contain special characters represented by the following escape sequences:
64        ///   - \t: tab (0x09)
65        ///   - \n: line feed (0x0a)
66        ///   - \r: carriage return (0x0d)
67        ///   - \f: form feed (0x0c)
68        ///
69        /// For every other sequence that starts with a backslash, the backslash is removed.
70        /// Therefore, the sequence \a would just yield an 'a'.
71        ///
72        /// A value can spread across multiple lines if the last character in a line (the character
73        /// immediately before the carriage return or line feed character) is a single backslash.
74        ///
75        /// Property names are case sensitive. Leading and trailing whitespace is
76        /// removed from both keys and values. A property name can neither contain
77        /// a colon ':' nor an equal sign '=' character.
78{
79public:
80        PropertyFileConfiguration();
81                /// Creates an empty PropertyFileConfiguration.
82
83        PropertyFileConfiguration(std::istream& istr);
84                /// Creates an PropertyFileConfiguration and loads the configuration data
85                /// from the given stream, which must be in properties file format.
86               
87        PropertyFileConfiguration(const std::string& path);
88                /// Creates an PropertyFileConfiguration and loads the configuration data
89                /// from the given file, which must be in properties file format.
90               
91        void load(std::istream& istr);
92                /// Loads the configuration data from the given stream, which
93                /// must be in properties file format.
94               
95        void load(const std::string& path);
96                /// Loads the configuration data from the given file, which
97                /// must be in properties file format.
98               
99        void save(std::ostream& ostr) const;
100                /// Writes the configuration data to the given stream.
101                ///
102                /// The data is written as a sequence of statements in the form
103                /// <key>: <value>
104                /// separated by a newline character.
105
106        void save(const std::string& path) const;
107                /// Writes the configuration data to the given file.
108
109protected:
110        ~PropertyFileConfiguration();
111       
112private:
113        void parseLine(std::istream& istr);
114        static int readChar(std::istream& istr);
115};
116
117
118} } // namespace Poco::Util
119
120
121#endif // Util_PropertyFileConfiguration_INCLUDED
Note: See TracBrowser for help on using the repository browser.