From 598b17a21fc9d9d9b09b6c0734493c51528c696b Mon Sep 17 00:00:00 2001 From: myun2 Date: Mon, 11 Jun 2012 13:25:06 +0900 Subject: [PATCH] lexical2/fixed_numeric.hpp --- roast/include/roast/lexical2/fixed_numeric.hpp | 170 ++++++------------------- 1 file changed, 36 insertions(+), 134 deletions(-) diff --git a/roast/include/roast/lexical2/fixed_numeric.hpp b/roast/include/roast/lexical2/fixed_numeric.hpp index 1e25311e..2f57f8a4 100644 --- a/roast/include/roast/lexical2/fixed_numeric.hpp +++ b/roast/include/roast/lexical2/fixed_numeric.hpp @@ -4,147 +4,49 @@ #ifndef __SFJP_ROAST__lexical2__fixed_numeric_HPP__ #define __SFJP_ROAST__lexical2__fixed_numeric_HPP__ -#include "roast/memory/sized_ptr.hpp" +#include "roast/lexical2/fixed.hpp" namespace roast { namespace lexical { - namespace rule - { - //////////////////////////////////////////////////////////////////// - - template - class range : public lengthable - { - public: - static const int length = sizeof(T); - - template - bool analyze(_It& it, _Param& param) - { - T n = *it; - if ( n >= _Min && n <= _Max ) - { - it++; - return true; - } - else - return false; - } - }; - - template - class char_range : public range {}; - - template - class short_range : public range {}; - - template - class int_range : public range {}; - - template - class uchar_range : public range {}; - - template - class ushort_range : public range {}; - - template - class uint_range : public range {}; - - ///////////////////////////////////////////////////////////// - - template - class fixed_numeric : public lengthable - { - public: - static const int length = sizeof(T); - - template - bool analyze(_It& it, _Param& param) - { - switch(*it) - { - case _Val: - it++; - return true; - } - return false; - } - - //---- - - template - bool generate(_Strm& strm, _Document& doc) - { - //strm << _Val; - T v = _Val; - //strm << v; - strm << sized_ptr_((char*)&v,sizeof(T)); - return true; - } - /*template - bool generate(::std::fstream& strm, _Document& doc) - { - //strm << _Val; - T v = _Val; - strm.write((const char*)&v, sizeof(_Val)); - return true; - }*/ - }; + ///////////////////////////////////////////////////////////// - ///////////////////////////////////////////////////////////// - - /* - template - class unibyte - { - public: - template - bool analyze(_It& it, _Param& param) - { - switch(*it) - { - case _Byte: - it++; - return true; - } - return false; - } - - template - bool generate(_Strm& strm, _Document& doc) - { - strm << _ByteCode; - return true; - } - }; - */ - template - class unibyte : public fixed_numeric {}; - - template - class fixed_char : public fixed_numeric {}; - template - class fixed_short : public fixed_numeric {}; - template - class fixed_int : public fixed_numeric {}; - template - class fixed_long : public fixed_numeric {}; - - template - class fixed_uchar : public fixed_numeric {}; - template - class fixed_ushort : public fixed_numeric {}; - template - class fixed_uint : public fixed_numeric {}; - template - class fixed_ulong : public fixed_numeric {}; + template + class fixed_numeric : public fixed + { + private: + typedef fixed _Base; + public: + fixed_numeric() : _Base(FixedNumericValue) {} + }; - typedef unibyte<0> zeroterm; - - //////////////////////////////////////////////////////////////////// - } + ///////////////////////////////////////////////////////////// +/* + template + class unibyte : public fixed_numeric {}; + + template + class fixed_char : public fixed_numeric {}; + template + class fixed_short : public fixed_numeric {}; + template + class fixed_int : public fixed_numeric {}; + template + class fixed_long : public fixed_numeric {}; + + template + class fixed_uchar : public fixed_numeric {}; + template + class fixed_ushort : public fixed_numeric {}; + template + class fixed_uint : public fixed_numeric {}; + template + class fixed_ulong : public fixed_numeric {}; + + typedef unibyte<0> zeroterm; + */ + //////////////////////////////////////////////////////////////////// } } -- 2.11.0