MWAWPropertyHandler.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; c-default-style: "k&r"; indent-tabs-mode: nil; tab-width: 2; c-basic-offset: 2 -*- */
2 
3 /* libmwaw
4 * Version: MPL 2.0 / LGPLv2+
5 *
6 * The contents of this file are subject to the Mozilla Public License Version
7 * 2.0 (the "License"); you may not use this file except in compliance with
8 * the License or as specified alternatively below. You may obtain a copy of
9 * the License at http://www.mozilla.org/MPL/
10 *
11 * Software distributed under the License is distributed on an "AS IS" basis,
12 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 * for the specific language governing rights and limitations under the
14 * License.
15 *
16 * Major Contributor(s):
17 * Copyright (C) 2002 William Lachance (wrlach@gmail.com)
18 * Copyright (C) 2002,2004 Marc Maurer (uwog@uwog.net)
19 * Copyright (C) 2004-2006 Fridrich Strba (fridrich.strba@bluewin.ch)
20 * Copyright (C) 2006, 2007 Andrew Ziem
21 * Copyright (C) 2011, 2012 Alonso Laurent (alonso@loria.fr)
22 *
23 *
24 * All Rights Reserved.
25 *
26 * For minor contributions see the git repository.
27 *
28 * Alternatively, the contents of this file may be used under the terms of
29 * the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
30 * in which case the provisions of the LGPLv2+ are applicable
31 * instead of those above.
32 */
33 
34 #ifndef MWAW_PROPERTY_HANDLER
35 # define MWAW_PROPERTY_HANDLER
36 
37 # include <assert.h>
38 # include <ostream>
39 # include <sstream>
40 # include <string>
41 
42 class WPXBinaryData;
43 class WPXProperty;
44 class WPXPropertyList;
45 class WPXPropertyListVector;
46 class WPXString;
47 
50 {
51 public:
55  virtual ~MWAWPropertyHandler() {}
56 
58  virtual void startElement(const char *psName, const WPXPropertyList &xPropList) = 0;
60  virtual void startElement(const char *psName, const WPXPropertyList &xPropList,
61  const WPXPropertyListVector &vect);
63  virtual void startElement(const char *psName, const WPXPropertyList &xPropList,
64  const WPXBinaryData &data);
66  virtual void endElement(const char *psName) = 0;
68  virtual void insertElement(const char *psName);
70  virtual void characters(WPXString const &sCharacters) = 0;
71 
73  bool checkData(WPXBinaryData const &encoded);
75  bool readData(WPXBinaryData const &encoded);
76 };
77 
100 {
101 public:
104 
106  void startElement(const char *psName, const WPXPropertyList &xPropList);
108  void startElement(const char *psName, const WPXPropertyList &xPropList,
109  const WPXPropertyListVector &vect);
111  void startElement(const char *psName, const WPXPropertyList &xPropList,
112  const WPXBinaryData &data);
114  void insertElement(const char *psName);
116  void endElement(const char *psName);
118  void characters(WPXString const &sCharacters);
120  bool getData(WPXBinaryData &data);
121 
122 protected:
124  void writeInteger(int val) {
125  writeLong(long(val));
126  }
128  void writeLong(long val);
130  void writeString(const char *name);
132  void writeProperty(const char *key, const WPXProperty &prop);
134  void writePropertyList(const WPXPropertyList &prop);
135 
137  std::stringstream m_f;
138 };
139 
140 #endif
141 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
void startElement(const char *psName, const WPXPropertyList &xPropList)
starts an element
Definition: MWAWPropertyHandler.cxx:61
virtual void startElement(const char *psName, const WPXPropertyList &xPropList)=0
starts an element
virtual ~MWAWPropertyHandler()
destructor
Definition: MWAWPropertyHandler.hxx:55
write in WPXBinaryData a list of tags/and properties
Definition: MWAWPropertyHandler.hxx:99
virtual void insertElement(const char *psName)
inserts a simple element ( note: maybe used one day to code insertEOL, insertTab...)
Definition: MWAWPropertyHandler.cxx:528
bool checkData(WPXBinaryData const &encoded)
checks a encoded WPXBinaryData created by MWAWPropertyHandlerEncoder
Definition: MWAWPropertyHandler.cxx:504
void writeInteger(int val)
adds an integer value in f
Definition: MWAWPropertyHandler.hxx:124
MWAWPropertyHandlerEncoder()
constructor
Definition: MWAWPropertyHandler.cxx:55
bool getData(WPXBinaryData &data)
retrieves the data
Definition: MWAWPropertyHandler.cxx:148
virtual void endElement(const char *psName)=0
ends an element
void writePropertyList(const WPXPropertyList &prop)
adds a property list: int #prop, #prop*WPXProperty
Definition: MWAWPropertyHandler.cxx:138
MWAWPropertyHandler()
constructor
Definition: MWAWPropertyHandler.hxx:53
virtual void characters(WPXString const &sCharacters)=0
writes a list of characters
void writeString(const char *name)
adds a string: size and string
Definition: MWAWPropertyHandler.cxx:114
std::stringstream m_f
the streamfile
Definition: MWAWPropertyHandler.hxx:137
bool readData(WPXBinaryData const &encoded)
reads a encoded WPXBinaryData created by MWAWPropertyHandlerEncoder
Definition: MWAWPropertyHandler.cxx:510
void characters(WPXString const &sCharacters)
writes a list of characters
Definition: MWAWPropertyHandler.cxx:107
void writeProperty(const char *key, const WPXProperty &prop)
adds a property: a string key, a string corresponding to value
Definition: MWAWPropertyHandler.cxx:128
void endElement(const char *psName)
ends an element
Definition: MWAWPropertyHandler.cxx:101
a generic property handler
Definition: MWAWPropertyHandler.hxx:49
void writeLong(long val)
adds a long value if f
Definition: MWAWPropertyHandler.cxx:121
void insertElement(const char *psName)
insert a simple element
Definition: MWAWPropertyHandler.cxx:95

Generated on Tue Mar 10 2015 17:32:09 for libmwaw by doxygen 1.8.5