Update ooo320-m1
[ooovba.git] / writerfilter / qa / cppunittests / odiapi / FileLoggerImpl.cxx
blob33ee1787d493f638ee58cb24e2ad93d9adf2ec31
1 /* Copyright 2005 Sun Microsystems, Inc. */
3 #include "FileLoggerImpl.hxx"
4 #include <iostream>
6 using namespace std;
8 namespace util
11 FileLoggerImpl::FileLoggerImpl(const string& fileName) :
12 file_(fileName.c_str())
14 if (!file_)
15 throw "Cannot open file";
18 void FileLoggerImpl::beginTree()
20 file_ << "digraph {" << endl;
23 void FileLoggerImpl::endTree()
25 file_ << "}" << endl;
28 void FileLoggerImpl::beginNode(const std::string& nodeId, const std::string& value, const std::string& refersToNodeId, bool inUse)
30 if (!nodeStack_.empty())
32 if (inUse)
33 file_ << nodeId << " [ label=\"(" << value << ")\", shape=box, color=grey, style=filled ];"<< endl;
34 else
35 file_ << nodeId << " [ label=\"(" << value << ")\" ];"<< endl;
37 file_ << nodeStack_.top() << " -> " << nodeId << ";" << endl;
39 if (!refersToNodeId.empty())
40 file_ << nodeId << " -> " << refersToNodeId << " [ color=grey, weight=0 ];" << endl;
42 else
44 file_ << nodeId << " [ label=\"(" << value << ")\", shape=diamond ];"<< endl;
46 nodeStack_.push(nodeId);
49 void FileLoggerImpl::endNode(const std::string& nodeId)
51 nodeStack_.pop();
54 } // namespace util