[Mobies-commit] [commit] r4284 - UDM/trunk/src/UdmJson
endre at redhat3.isis.vanderbilt.edu
endre at redhat3.isis.vanderbilt.edu
Fri Apr 4 12:12:16 CDT 2014
Author: endre
Date: Fri Apr 4 12:12:16 2014
New Revision: 4284
Log:
UdmJson utility to export any data network to JSON file.
Added:
UDM/trunk/src/UdmJson/
UDM/trunk/src/UdmJson/Makefile.OSX
UDM/trunk/src/UdmJson/UdmJson.cpp
Added: UDM/trunk/src/UdmJson/Makefile.OSX
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ UDM/trunk/src/UdmJson/Makefile.OSX Fri Apr 4 12:12:16 2014 (r4284)
@@ -0,0 +1,11 @@
+include ../../Makefile.OSX.incl
+
+SOURCES=UdmJson.cpp
+OBJECTS=$(SOURCES:.cpp=.o)
+
+all: $(SOURCES) $(OBJECTS)
+
+.cpp.o:
+ $(CC) $(CFLAGS) $(INCLUDE) $< -o $@
+clean:
+ rm -f *.o
Added: UDM/trunk/src/UdmJson/UdmJson.cpp
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ UDM/trunk/src/UdmJson/UdmJson.cpp Fri Apr 4 12:12:16 2014 (r4284)
@@ -0,0 +1,67 @@
+
+#include <Uml.h>
+#include <UdmUtil.h>
+#include <UmlExt.h>
+
+UDM_USE_DOM
+#ifdef _WIN32
+UDM_USE_MGA
+#endif
+
+#include <string>
+void dummy(void) {; }
+
+
+int main(int argc, char **argv)
+{
+
+ bool child_attr_subtree = false;
+ if (argc > 2 && strcmp(argv[1], "-s") == 0)
+ {
+ child_attr_subtree = true;
+ argc--;
+ argv++;
+ }
+
+ if (argc != 4 )
+ {
+ cout << "Usage: UdmJson [-s] <inputdatafile> <outputjsonfile> <diagramname> " << endl;
+ cout << " where: <diagramname>: Udm .xml file" << endl;
+ cout << " -s : generate children and attributes in _children and _attributes subtrees" << endl;
+ cout << "Available backends: " + Udm::DataNetwork::DumpBackendNames() << endl;
+ return(-1);
+
+
+ }
+ // Loading the meta
+ Udm::SmartDataNetwork ddnMeta(::Uml::diagram);
+ ::Uml::Diagram theUmlDiagram;
+ try {
+
+ // Opening the XML meta of the host graph
+ Udm::SmartDataNetwork ddnMeta_in(::Uml::diagram);
+ ddnMeta_in.OpenExisting(argv[3],"uml.dtd", Udm::CHANGES_LOST_DEFAULT);
+
+ // Casting the DataNetwork to diagram
+ theUmlDiagram = ::Uml::Diagram::Cast(ddnMeta_in.GetRootObject());
+
+ // Creating the UDM diagram
+ Udm::UdmDiagram udmDataDiagram;
+ udmDataDiagram.dgr = &theUmlDiagram;
+ udmDataDiagram.init = dummy;
+
+ Udm::SmartDataNetwork DN(udmDataDiagram);
+ DN.OpenExisting(argv[1],"",Udm::CHANGES_LOST_DEFAULT);
+ ::UdmUtil::write_json(DN.GetRootObject(), argv[2],child_attr_subtree);
+ DN.CloseNoUpdate();
+ }
+ catch(udm_exception u)
+ {
+ cerr << u.what() << endl;
+ exit(-1);
+ }
+
+ return 0;
+
+}
+
More information about the Mobies-commit
mailing list