From 5506b0842f7f628a0c761950a196fc935ffa8fb4 Mon Sep 17 00:00:00 2001 From: Myun2 Date: Thu, 22 Jul 2010 03:41:55 +0900 Subject: [PATCH] =?utf8?q?lexical,=20roast=5Fxml:=20=E3=81=A8=E3=82=8A?= =?utf8?q?=E3=81=82=E3=81=88=E3=81=9A=E5=B1=9E=E6=80=A7=E5=90=8D=E3=81=AE?= =?utf8?q?=E5=8F=96=E5=BE=97=E3=81=BE=E3=81=A7=E5=AF=BE=E5=BF=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- roast/include/roast/lexical/string_parser_base.hpp | 6 ++- roast/include/roast/lexical/structure_base.hpp | 56 +++++++++++++++++++++- roast/include/roast/xml/roast_xml/structure.hpp | 6 +++ 3 files changed, 65 insertions(+), 3 deletions(-) diff --git a/roast/include/roast/lexical/string_parser_base.hpp b/roast/include/roast/lexical/string_parser_base.hpp index e7476dfa..1ed8e3b7 100644 --- a/roast/include/roast/lexical/string_parser_base.hpp +++ b/roast/include/roast/lexical/string_parser_base.hpp @@ -14,10 +14,12 @@ namespace roast ////////////////////////////////////////////////////////// template - class string_parser_base : public parser_base + //class string_parser_base : public parser_base + class string_parser_base : public parser_base< _linear_iterator_arithmetic, _Impl> { private: - typedef parser_base _Base; + //typedef parser_base _Base; + typedef parser_base< _linear_iterator_arithmetic, _Impl> _Base; public: string_parser_base(){} string_parser_base(const char* s) : _Base( ccharbuf_iterator(s) ) {} diff --git a/roast/include/roast/lexical/structure_base.hpp b/roast/include/roast/lexical/structure_base.hpp index fcac66be..c88d0ebd 100644 --- a/roast/include/roast/lexical/structure_base.hpp +++ b/roast/include/roast/lexical/structure_base.hpp @@ -315,10 +315,64 @@ namespace roast return true; } + template + bool analyze(const T& it) + { + fail. (Cant const Iterator); + } } _nrqws, _noreqws, nrqws, noreqws, optws; - /////////////////////////////////////////////////// + //////////////////////////////////////////////////////////// + + template + class get_string + { + public: + __It start_it; + __It end_it; + + template + bool analyze(T& it) + { + start_it = it; + + _EndProc proc; + for(;;) + { + if ( proc((const T&)start_it, (const T&)it) ) + break; + it++; + } + end_it = it; + return true; + } + + template + bool analyze(const T& it) + { + T cant const. + } + }; + + template + class _get_string_end_proc_analyze + { + public: + template + bool operator()(const _It& start_it, const _It& it) + { + T t; + _It it_work = it; + return t.analyze(it_work); + } + }; + + template + class get_string_end_analyze : public get_string<_get_string_end_proc_analyze<_EndAnalyzeT>, __It> + {}; + + //////////////////////////////////////////////////////////// } /////////////////////////////////////// diff --git a/roast/include/roast/xml/roast_xml/structure.hpp b/roast/include/roast/xml/roast_xml/structure.hpp index e2e7b9b3..b05a8ebd 100644 --- a/roast/include/roast/xml/roast_xml/structure.hpp +++ b/roast/include/roast/xml/roast_xml/structure.hpp @@ -7,6 +7,7 @@ #include "roast/lexical/base.hpp" #include "roast/lexical/structure_base.hpp" +#include "roast/str/sized_charbuf.hpp" namespace roast { @@ -143,6 +144,11 @@ namespace roast template bool analyze(T& it) { + get_string_end_analyze< unichar<'='>, T> gs; + gs.analyze(it); + sized_ptr_ str(&*gs.start_it, gs.end_it - gs.start_it); + sized_ccharbuf cb(str.ptr, str.size); + printf( cb.to_string().c_str() ); return true; } }; -- 2.11.0