From 477359a5bf8717320d7e0f0d5ed8932df4f21200 Mon Sep 17 00:00:00 2001 From: myun2 Date: Tue, 12 Jun 2012 13:14:15 +0900 Subject: [PATCH] lexical2/string.hpp Add. --- roast/include/roast/lexical2/string.hpp | 88 +++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 roast/include/roast/lexical2/string.hpp diff --git a/roast/include/roast/lexical2/string.hpp b/roast/include/roast/lexical2/string.hpp new file mode 100644 index 00000000..1881abe1 --- /dev/null +++ b/roast/include/roast/lexical2/string.hpp @@ -0,0 +1,88 @@ +// Roast+ License +/* +*/ +#ifndef __SFJP_ROAST__lexical2__string_HPP__ +#define __SFJP_ROAST__lexical2__string_HPP__ + +#pragma warning(disable:4503) + +namespace roast +{ + namespace lexical + { + /////////////////////////////////////////////////////////////////// + + template + struct string_// : not_lengthable + { + ::std::string m_str; + + ////////////////////////////////////////////////// + string_(){} + string_(const char* s) : m_str(s){} + string_(const ::std::string& s) : m_str(s){} + + template + bool analyze(_It& it, _Param& param) + { + for(const char* p=m_str.c_str(); *p!='\0'; p++, it++) + { + // Check the char + const _It it_work = it; + _EncCheck checker; + if ( checker.analyze(it_work, param) == false ) + break; + + m_str.append(1,*p); + } + return true; + } + + template + bool generate(_Strm& strm, _Document& doc) const + { + strm << m_str; + return true; + } + + operator ::std::string() { return m_str; } + operator const ::std::string() const { return m_str; } + operator const char*() const { return m_str.c_str(); } + const char* c_str() const { return m_str.c_str(); } + + bool operator == (const char* s) const { + return m_str == s; + } + bool operator != (const char* s) const { + return m_str != s; + } + }; + ///// + class string : public string_ + { + private: + typedef string_ _Base; + public: + string(){} + string(const char* s) : _Base(s){} + string(const ::std::string& s) : _Base(s){} + + string operator = (const char* s){ + _Base::m_str = s; + return *this; + } + string operator = (const ::std::string& s){ + _Base::m_str = s; + return *this; + } + /*string operator = (const string& s){ + _Base::m_str = s.m_str; + return *this; + }*/ + }; + + /////////////////////////////////////////////////////////////////// + } +} + +#endif//__SFJP_ROAST__lexical2__string_HPP__ -- 2.11.0