00001
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef _WRITER_H
00030 #define _WRITER_H
00031
00032 #include "gexf.h"
00033 #include <libxml/xmlwriter.h>
00034 #include <string>
00035
00036 namespace libgexf {
00037
00041 class FileWriter {
00042 public:
00046 enum ElemType { NODE, EDGE };
00047 public:
00048 FileWriter();
00049
00056 FileWriter(const std::string& filepath, GEXF* gexf);
00057
00061 FileWriter(const FileWriter& orig);
00062
00063 virtual ~FileWriter();
00064
00065
00071 libgexf::GEXF getGEXFCopy();
00072
00079 void init(const std::string& filepath, libgexf::GEXF* gexf);
00080
00085 void write();
00086 private:
00087 void writeGexfNode(xmlTextWriterPtr writer);
00088 void writeMetaNode(xmlTextWriterPtr writer);
00089
00090 void writeGraphNode(xmlTextWriterPtr writer);
00091 void writeNodesNode(xmlTextWriterPtr writer);
00092 void writeNodeNode(xmlTextWriterPtr writer, const std::string& node_id, const std::string& label="");
00093 void writeEdgesNode(xmlTextWriterPtr writer);
00094 void writeEdgeNode(xmlTextWriterPtr writer, const std::string& edge_id, const std::string& source_id, const std::string& target_id, const std::string& cardinal="1", const std::string& type="undirected");
00095
00096 void writeAttributesNode(xmlTextWriterPtr writer, const std::string& element_class);
00097 void writeAttributeNode(xmlTextWriterPtr writer, const std::string& id, const std::string& title, const std::string& type, const std::string& default_value="", const std::string& options="");
00098 void writeAttributeDefaultNode(xmlTextWriterPtr writer, const std::string& default_value);
00099 void writeAttvaluesNode(xmlTextWriterPtr writer, const ElemType type, const std::string& id);
00100 void writeAttvalueNode(xmlTextWriterPtr writer, const std::string& attribute_id, const std::string& value);
00101 private:
00102 GEXF* _gexf;
00103 std::string _filepath;
00104 static const char* _ENCODING;
00105 };
00106
00107
00108 }
00109
00110 #endif
00111