MeVisLabToolboxReference
MeVisLab/Standard/Sources/ML/MLParser/mlIOHandler.h
Go to the documentation of this file.
00001 // **InsertLicense** code
00002 //----------------------------------------------------------------------------------
00006 
00011 //----------------------------------------------------------------------------------
00012 
00013 #ifndef __mlIOHandler_H
00014 #define __mlIOHandler_H
00015 
00016 #include "mlParserSystem.h"
00017 
00018 // include your parser (= TreeNode derivate) header here:
00019 #include "mlXMLParser/mlXMLTreeNode.h"
00020 #include "mlDebug.h"
00021 
00022 ML_START_NAMESPACE
00023 
00028   class PARSER_EXPORT IOHandler {
00029 
00030     public:
00031 
00034       typedef enum {
00036         IO_MODE_XML,
00037 
00039         IO_MODE_AUTO,
00040 
00042         IO_MODE_COUNT
00043 
00044       } IO_MODE;
00045 
00048       static const char* IO_MODE_TOKENS[];
00049 
00052       static TreeNode* createRootTreeNode(IO_MODE ioMode, TreeNode::ConstructionMode conMode) {
00053         try {
00054           switch (ioMode) {
00055 
00056             // create XML node:
00057             case IO_MODE_XML:            
00058               return new XMLTreeNode(conMode);
00059 
00060             // current default: XML
00061             default:
00062               return new XMLTreeNode(conMode);
00063           }
00064         } catch (const TreeNodeException& /*e*/) {          
00065           return NULL;
00066         }
00067       }
00068 
00071       static const char* getDefaultFileExtension(IO_MODE ioMode) {
00072       
00073         switch (ioMode) {
00074 
00075           // return preferred XML extension:
00076           case IO_MODE_XML:          
00077             return ".xml";
00078         
00079           default:
00080             return NULL;
00081         }
00082       }
00083     
00085       static IO_MODE getModeFromExtension(const char* fileName);      
00086 
00088       static IO_MODE getModeFromContents(const char* fileName);
00089 
00090   };
00091      
00092 
00093 ML_END_NAMESPACE
00094 
00095 
00096 
00097 #endif // __mlIOHandler_H
00098