From 7b770032fb42f312a91e451da1481ad914ede1bc Mon Sep 17 00:00:00 2001 From: Myun2 Date: Wed, 22 Sep 2010 02:22:03 +0900 Subject: [PATCH] =?utf8?q?static=5Fmap.cpp=20=E3=81=B8=E3=81=AE=E5=88=86?= =?utf8?q?=E9=9B=A2=20parser=5Ftest.cpp:=20DOM=E5=AF=BE=E5=BF=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- roast/test/lexical_test/parser_test.cpp | 112 ++++++++++++++++++-------------- roast/test/lexical_test/static_map.cpp | 26 ++++++++ 2 files changed, 90 insertions(+), 48 deletions(-) create mode 100644 roast/test/lexical_test/static_map.cpp diff --git a/roast/test/lexical_test/parser_test.cpp b/roast/test/lexical_test/parser_test.cpp index 62264189..c2611eaa 100644 --- a/roast/test/lexical_test/parser_test.cpp +++ b/roast/test/lexical_test/parser_test.cpp @@ -1,69 +1,85 @@ -#//include "roast/xml/roast_dom_driver.hpp" +//#include "roast/xml/roast_dom_driver.hpp" #include "roast/xml/roast_xml/roast_xml_dom_parser.hpp" #include "roast/xml/roast_xml/roast_xml_sax_parser.hpp" -#include "roast/tp/static_map.hpp" #include -#include +#include using namespace roast; using namespace roast::lexical; #define BUFF_SIZE 200*1024*1024 - - class test +class A +{ +private: + ::std::string m_indent; +public: + void found_attribute( const sized_ccharbuf &attr_name, const sized_ccharbuf &attr_value ) { - private: - int attr_count ; - int text_count ; - int element_count ; - public: - void attribute( const sized_ccharbuf &attr_name, const sized_ccharbuf &attr_value ) - { - attr_count ++; - } - - void comment( const sized_ccharbuf &s ) - { - } + printf("%sattr: %s=\"%s\"\n", + m_indent.c_str(), + attr_name.to_string().c_str(), + attr_value.to_string().c_str() ); + } - void text( const sized_ccharbuf &s ) - { - text_count ++; - } - void start_element( const sized_ccharbuf &s ) - { - element_count ++; - } - void end_element(){ - } - }; + void found_comment( const sized_ccharbuf &s ) + { + printf("%scomment: \"%s\"\n", + m_indent.c_str(), + s.to_string().c_str() ); + } + void found_text( const sized_ccharbuf &s ) + { + printf("%stext: \"%s\"\n", + m_indent.c_str(), + s.to_string().c_str() ); + } + void start_element( const sized_ccharbuf &s ) + { + printf("%s\n", m_indent.c_str(), m_indent.c_str()); + } +}; int main() { - //static_map, pair<2,20>, pair<3,40> > > sm; - //printf("%d\n", sm::get<1>::value ); - using namespace std; - static_map sm( make_ul_tuple( make_pair(1,"hoge"), make_pair(2,"huge"), make_pair(3,"hige") ) ); - printf("%s\n", sm.get<1>() ); - //(long long)'hoge'; + try + { + FILE* fp = fopen("temp.xml","r"); + char* work = new char [20*1024*1024]; + memset(work,0,20*1024*1024); + fread(work,(20*1024*1024),1,fp); - FILE* fp = fopen("temp.xml","r"); - //FILE* fp = fopen("MIDIƒfƒoƒCƒXƒ}ƒl[ƒWƒƒ3.xml","r"); - //char work[256]; - //fread(work,sizeof(work),1,fp); - char *work = new char [BUFF_SIZE]; - fread(work,BUFF_SIZE,1,fp); + roast_xml::dom_parser xml(work); + //roast_xml::sax_parser sax(work); + roast_xml::document* pdoc = xml.analyze(); - printf("%d\n", clock()); + using namespace roast_xml; + element *e = pdoc->get_root_element(); + element_list_t el = e->get_child_elements(); - roast_xml::dom_parser xml(work); - /*roast_xml::sax_parser< - roast_xml::sax_callback_sample> xml(work); - //test> xml(work);*/ - xml.analyze(); - printf("%d\n", clock()); + for(int i=0; iname.c_str() ); + } + /* + for(int i=0; inode_list.size(); i++) + { + node *n = e->node_list[i]; + }*/ + + delete pdoc; + } + catch(int) + { + printf("\n\n[Exception!]\n"); + } return 0; } diff --git a/roast/test/lexical_test/static_map.cpp b/roast/test/lexical_test/static_map.cpp new file mode 100644 index 00000000..9e752017 --- /dev/null +++ b/roast/test/lexical_test/static_map.cpp @@ -0,0 +1,26 @@ +#include "roast/tp/static_map.hpp" +#include +#include + +using namespace roast; +using namespace roast::lexical; + + +int main() +{ + //static_map, pair<2,20>, pair<3,40> > > sm; + //printf("%d\n", sm::get<1>::value ); + using namespace std; + static_map sm( make_ul_tuple( make_pair(1,"hoge"), make_pair(4,"huge"), make_pair(6,"hige") ) ); + printf("%s\n", sm.get<4>() ); + + map mp; + mp[1] = "hoge"; + mp[4] = "huge"; + mp[6] = "hige"; + printf("%s\n", mp[4] ); + + //(long long)'hoge'; + + return 0; +} -- 2.11.0