summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/orbsvcs/Notify/XML_Saver.h
blob: e1956637a952982d08e54b252afba2a434ed8cf6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/* -*- C++ -*- */

//=============================================================================
/**
 *  @file    XML_Saver.h
 *
 *  $Id$
 *
 *  @author Jonathan Pollack <pollack_j@ociweb.com>
 */
//=============================================================================

#ifndef XML_SAVER_H
#define XML_SAVER_H
#include /**/ "ace/pre.h"

#include "Topology_Saver.h"

#include "tao/corba.h"
#include "ace/streams.h"

#if !defined (ACE_LACKS_PRAGMA_ONCE)
#pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */

namespace TAO_NOTIFY
{

/**
 * \brief Save Notification Service Topology to an XML file.
 */
class XML_Saver : public Topology_Saver
{
public:
  /// Construct an XML_Saver.
  /// Initialization is deferred to "open()"
  XML_Saver (bool timestamp = true);

  virtual ~XML_Saver ();

  /// Open the output file.
  /// \param file_name the fully qualified file name
  /// \return true if successful
  bool open (const ACE_CString & file_name, size_t backup_count);

  //////////////////////////////////
  // Override Topology_Saver methods
  // see Topology_Saver.h for doc
  virtual bool begin_object (CORBA::Long id,
    const ACE_CString& type,
    const NVPList& attrs,
    bool changed
    ACE_ENV_ARG_DECL);

  virtual void end_object (CORBA::Long id,
    const ACE_CString& type
    ACE_ENV_ARG_DECL);

  virtual void close (ACE_ENV_SINGLE_ARG_DECL);

private:
  void backup_file_name (char * file_path, int nfile);

  /// \return newstr to allow in-line use
  char* escape_string(char *& newstr, size_t & size, const ACE_CString & str);

private:
  /// A stream representing our current output.
  ostream * output_;
  bool close_out_;

  /// the name of the output file
  ACE_CString base_name_;
  size_t backup_count_;

  /// true to enable timestamping
  bool timestamp_;

  /// A string consisting of spaces that is our current indentation level.
  ACE_CString indent_;

};

} // namespace TAO_NOTIFY

#include /**/ "ace/post.h"
#endif /* XML_SAVER_H */