#include "c_interface.hpp" /* ********************************************************** */ /* CONVERSION FUNCTION */ /* ********************************************************** */ static inline std::string stringXtoStd(XString _str) { char * const temp = new char[_str.len+1](); memset(temp, '\0', _str.len+1); memcpy(temp, _str.str, _str.len); std::string _retstr(temp); size_t d = _retstr.find_first_not_of(' '); size_t f = _retstr.find_last_not_of (' '); delete[] temp; return (_retstr.substr(d, f-d+1)); } static inline XString stringXtoStd(const std::string& _str) { XString _retstr = {new char[_str.size()](), _str.size()}; memcpy(_retstr.str, _str.c_str(), _str.size()); return (_retstr); } /* ********************************************************** */ /* HANDLE INTERFACE */ /* ********************************************************** */ void xios_handle_create_(XHandle * _ret, const XDType * const _dtype, const XString * const _id) { try { switch(*_dtype) { /*ECONTEXT, EAXIS, EDOMAIN, EFIELD, EFILE, EGRID, GAXIS, GDOMAIN, GFIELD, GFILE, GGRID*/ case (ECONTEXT): //if (Context::) break; default : break; }; } catch(const Exception &exc) { ERROR(exc.displayText()); } } void xios_handle_verify_(XBool * _ret, const XHandle * const _hd) { try { } catch(const Exception &exc) { ERROR(exc.displayText()); } } void xios_handle_getType_(XDType * _ret, const XHandle * const _hd) { try { } catch(const Exception &exc) { ERROR(exc.displayText()); } } void xios_handle_isType_(XBool * _ret, const XHandle * const _hd, const XDType * const _dtype) { try { } catch(const Exception &exc) { ERROR(exc.displayText()); } } void xios_handle_isId_(XBool * _ret, const XHandle * const _hd, const XString * const _id) { try { } catch(const Exception &exc) { ERROR(exc.displayText()); } } void xios_handle_isGroup_(XBool * _ret, const XHandle * const _hd) { try { } catch(const Exception &exc) { ERROR(exc.displayText()); } } void xios_handle_isElement_(XBool * _ret, const XHandle * const _hd) { try { } catch(const Exception &exc) { ERROR(exc.displayText()); } } /* ********************************************************** */ /* XML INTERFACE */ /* ********************************************************** */ void xios_xml_parse_file_(XString _filename) { try { std::string __filename = stringXtoStd(_filename); std::ifstream __istr( __filename.c_str() , std::ifstream::in ); // On commence la lecture du flux de donnée xml. XMLNode node = XMLNode::CreateNode(__istr, Context::GetRootName()); // On parse le fichier xml noeud par noeud // (ie on construit dynamiquement notre arbre d'objets). XMLParser::Parse(node); } catch(const Exception &exc) { ERROR(exc.displayText()); } } void xios_xml_parse_string_(XString _xmlcontent) { try { std::string __xmlcontent = stringXtoStd(_xmlcontent); std::istringstream __istr(__xmlcontent); // On commence la lecture du flux de donnée xml. XMLNode node = XMLNode::CreateNode(__istr, Context::GetRootName()); // On parse le fichier xml noeud par noeud // (ie on construit dynamiquement notre arbre d'objets). XMLParser::Parse(node); } catch(const Exception &exc) { ERROR(exc.displayText()); } } /* ********************************************************** */ /* MAIN ENTRY */ /* ********************************************************** */ void main_c_(void) // voué à disparaître { /* Ne rien faire de plus */ }