update dev300-m58
[ooovba.git] / writerfilter / qa / cppunittests / odiapi / ExternalViewLogger.hxx
bloba0c9721c83f0fba2bcb34444ffc166dcac33411a
1 /* Copyright 2005 Sun Microsystems, Inc. */
3 #ifndef INCLUDED_EXTERNALVIEWLOGGER_HXX
4 #define INCLUDED_EXTERNALVIEWLOGGER_HXX
6 #ifndef INCLUDED_LOGGER_HXX
7 #include <odiapi/props/Logger.hxx>
8 #endif
10 #include <fstream>
11 #include <stack>
12 #include <map>
13 #include <utility>
14 #include <boost/shared_ptr.hpp>
16 namespace util {
18 struct NodeDescription
20 typedef boost::shared_ptr<NodeDescription> Pointer_t;
22 NodeDescription(const std::string& parent, const std::string& refersTo, const std::string& value, bool inUse);
24 std::string mParentNodeId;
25 std::string mRefersToNodeId;
26 std::string mNodeValue;
27 bool mInUse;
30 /** A file logger
32 class ExternalViewLoggerImpl : public Logger
34 public:
35 ExternalViewLoggerImpl(const std::string& fileName);
37 virtual void beginTree();
38 virtual void endTree();
40 virtual void beginNode(const std::string& nodeId, const std::string& value, const std::string& refersToNodeId, bool inUse);
41 virtual void endNode(const std::string& nodeId);
43 private:
44 bool isLeaf(const std::string& nodeId);
45 bool isUnreferencedLeaf(const std::string& nodeId);
46 bool isReferenced(const std::string& nodeId);
47 bool isReferingToOtherNode(const std::string& nodeId);
48 bool hasParent(const std::string& nodeId);
49 void dumpTree(const std::string& nodeId);
50 std::string getValue(const std::string& nodeId);
51 std::string getNewStyleName();
52 void dumpNodeContainer(const std::string& fileName);
54 private:
55 typedef std::map<std::string, NodeDescription::Pointer_t> NodeContainer_t;
57 std::string mFileName;
58 NodeContainer_t mNodeContainer;
59 std::ofstream mFile;
60 std::stack<std::string> mParentNodeStack;
63 } // namespace util
65 #endif // INCLUDED_LOGGER_HXX