1 // Writer.h
2 //
3 // Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 Matthew Flood
4 // See file AUTHORS for contact information
5 //
6 // This file is part of RudeConfig.
7 //
8 // RudeConfig is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 2, or (at your option)
11 // any later version.
12 //
13 // RudeConfig is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 // GNU General Public License for more details.
17 //
18 // You should have received a copy of the GNU General Public License
19 // along with RudeConfig; (see COPYING) if not, write to the Free Software
20 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
21 // 02111-1307, USA.
22 //------------------------------------------------------------------------
23 
24 
25 #ifndef INCLUDED_Writer_H
26 #define INCLUDED_Writer_H
27 
28 #include "AbstractWriter.h"
29 #include <iostream>
30 
31 namespace rude{
32 namespace config{
33 
34 class File;
35 class Section;
36 class KeyValue;
37 class Comment;
38 class WhiteSpace;
39 
40 
41 class Writer: public AbstractWriter{
42 
43 public:
44 
45 	Writer();
46 
47 	virtual void visitFile(const File& configfile) const;
48 	virtual void visitSection(const Section& configsection) const;
49 	virtual void visitKeyValue(const KeyValue& keyvalue) const;
50 	virtual void visitComment(const Comment& comment) const;
51 	virtual void visitWhiteSpace(const WhiteSpace& whitespace) const;
52 
53 	virtual ~Writer();
54 
55 	//=
56 	// Writes the data member to an output stream
57 	//
58 	// For the following specification examples, assume an object with the following properties:
59 	//
60 	// <b>name</b> = "color"
61 	// <b>value</b>="blue"
62 	// <b>comment</b>="Color of the background"
63 	//
64 	// <ul>
65 	// <li>If comment char is null, comments/deleted items will not be written
66 	//
67 	// <b>Example:</b> object->write(stdout, 0, "=")
68 	// <b>Results:</b>
69 	// <font color=red><code>color = blue</code></font>
70 	//
71 	// <li>If delimiter is null, name / value will be separated by whitespace
72 	//
73 	// <b>Example:</b> object->write(stdout, "#", 0)
74 	// <b>Results:</b>
75 	// <font color=red><code>color  blue  # Color of the background</code></font>
76 	//
77 	// <li>Undefined results if outputstream is null
78 	//
79 	// <b>Example:</b> object->write(0, "#", "=")
80 	// <b>Results:</b>
81 	// <font color=red><code>??????????</code></font>
82 	//
83 	// <li>If the data member is a comment, then only the comment data is written - any values
84 	// for the name / value are discarded.
85 	//
86 	// <b>Example:</b> object->write(stdout, "#", "=")
87 	// <b>Results:</b>
88 	// <font color=red><code># Color of the background</code></font>
89 	//
90 	// <li>If the data member has been (flagged as) deleted, then the name, value and original comment are preserved,
91 	// preceded by a comment character.
92 	//
93 	// <b>Example:</b> object->write(stdout, "#", "=")
94 	// <b>Results:</b>
95 	// <font color=red><code># color = blue  # Color of the background</code></font>
96 	//
97 	// </ul>
98 	//=
99 
100 
101 };
102 
103 }} // end namespaces
104 
105 #endif
106 
107