MeVisLab Toolbox Reference
Loading...
Searching...
No Matches
mlIOHandler.h
Go to the documentation of this file.
1/*************************************************************************************
2**
3** Copyright 2007, MeVis Medical Solutions AG
4**
5** The user may use this file in accordance with the license agreement provided with
6** the Software or, alternatively, in accordance with the terms contained in a
7** written agreement between the user and MeVis Medical Solutions AG.
8**
9** For further information use the contact form at https://www.mevislab.de/contact
10**
11**************************************************************************************/
12
13#ifndef ML_IOHANDLER_H
14#define ML_IOHANDLER_H
15
16
20
21#include "mlParserSystem.h"
22
23// include your parser (= TreeNode derivate) header here:
25#include "mlDebug.h"
26
28
34{
35
36public:
39 typedef enum {
42
45
47 IO_MODE_COUNT
48
49 } IO_MODE;
50
53 static const char* IO_MODE_TOKENS[];
54
58 {
59 try {
60 switch (ioMode) {
61
62 // create XML node:
63 case IO_MODE_XML:
64 return new XMLTreeNode(conMode);
65
66 // current default: XML
67 default:
68 return new XMLTreeNode(conMode);
69 }
70 }
71 catch (const TreeNodeException& /*e*/) {
72 return nullptr;
73 }
74 }
75
79 {
80
81 switch (ioMode) {
82
83 // return preferred XML extension:
84 case IO_MODE_XML:
85 return ".xml";
86
87 default:
88 return nullptr;
89 }
90 }
91
94
97};
98
99
101
102
103#endif // __mlIOHandler_H
Handles the different possible IO modes.
Definition mlIOHandler.h:34
static IO_MODE getModeFromExtension(const char *fileName)
Returns the mode that fits to file's extension (using getDefaultFileExtension);.
static IO_MODE getModeFromContents(const char *fileName)
Returns the mode that fits to file's contents (only a small part of the file's contents is evaluated)
IO_MODE
Register your parser type here.
Definition mlIOHandler.h:39
@ IO_MODE_XML
import/export in XML format
Definition mlIOHandler.h:41
@ IO_MODE_AUTO
auto detect format
Definition mlIOHandler.h:44
static const char * getDefaultFileExtension(IO_MODE ioMode)
Get the default file extension Register your own TreeNode type here.
Definition mlIOHandler.h:78
static TreeNode * createRootTreeNode(IO_MODE ioMode, TreeNode::ConstructionMode conMode)
Creates a root node for reading or writing.
Definition mlIOHandler.h:57
The class TreeNodeException is the base class for all exceptions thrown by the class TreeNode and all...
Definition mlTreeNode.h:95
The class TreeNode is the abstract base class for the import/export of ML objects.
Definition mlTreeNode.h:160
ConstructionMode
TreeNode construction modes.
Definition mlTreeNode.h:240
The class XMLTreeNode implements the abstract class TreeNode to allow export and import of ML objects...
#define PARSER_EXPORT
Definiert systemspezifische Macros, die f"ur diese DLL gelten sollen.
Target mlrange_cast(Source arg)
Generic version of checked ML casts.