cisst-saw
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
svlWebXMLObject.h
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* ex: set filetype=cpp softtabstop=4 shiftwidth=4 tabstop=4 cindent expandtab: */
3 
4 /*
5 
6  Author(s): Balazs Vagvolgyi
7  Created on: 2009-11-04
8 
9  (C) Copyright 2005-2009 Johns Hopkins University (JHU), All Rights
10  Reserved.
11 
12  --- begin cisst license - do not edit ---
13 
14  This software is provided "as is" under an open source license, with
15  no warranty. The complete license can be found in license.txt and
16  http://www.cisst.org/cisst/license.txt.
17 
18  --- end cisst license ---
19 
20 */
21 
22 
23 #ifndef _svlWebXMLObject_h
24 #define _svlWebXMLObject_h
25 
26 #include <cisstCommon.h>
29 
30 #include <map>
31 #include <string>
32 
33 // Always the last cisst include
34 #include <cisstCommon/cmnExport.h>
35 
36 
38 {
39  typedef struct __NodeData {
40  int modified;
41  std::string value;
42  } _NodeData;
43  typedef std::pair<std::string, _NodeData> _NodePair;
44  typedef std::map<std::string, _NodeData> _NodeMap;
45 
46 public:
47  svlWebXMLObject(const std::string & name, bool readable, bool writable);
48  virtual ~svlWebXMLObject();
49  virtual svlWebXMLObject* clone() const;
50 
51  virtual void Read(char*& data, int& datasize);
52  virtual void Write(char* data, int datasize);
53 
54  virtual int AddNode(const std::string & name, const std::string & value);
55  virtual int RemoveNode(const std::string & name);
56  virtual int SetNode(const std::string & name, const std::string & value);
57  virtual int GetNode(const std::string & name, std::string & value);
58  virtual const std::string & GetNode(const std::string & name);
59 
60 private:
62 
63  void Serialize();
64  void Deserialize();
65  int parseDocTree(void *node, unsigned int depth = -1);
66  void CheckCacheSize(int size);
67 
68  _NodeMap Nodes;
69  std::string XML;
70  std::string InvalidNode;
71  char* Cache;
72  int CacheSize;
73 };
74 
75 #endif // _svlWebXMLObject_h
76 
virtual svlWebObjectBase * clone() const =0
#define CISST_EXPORT
Definition: cmnExportMacros.h:50
Definition: svlWebObjectBase.h:36
Definition: svlWebXMLObject.h:37
virtual void Write(char *data, int datasize)
Macros to export the symbols of cisstCommon (in a Dll).
virtual void Read(char *&data, int &datasize)