OSDN Git Service

lexical2/variable.hpp: variable_ptr を variable_dlen としてみた。実装的には、こうかな…?
authormyun2 <myun2@nwhite.info>
Fri, 22 Jun 2012 02:41:59 +0000 (11:41 +0900)
committermyun2 <myun2@nwhite.info>
Fri, 22 Jun 2012 02:41:59 +0000 (11:41 +0900)
roast/include/roast/lexical2/variable.hpp

index abe8fd8..b1dbf19 100644 (file)
@@ -50,23 +50,24 @@ namespace roast
                ////////////////////////////////////////////////////////////////////
                
                template <typename T>
-               class variable_ptr
+               class variable_dlen
                {
-               private:
-                       const unsigned int length;
-                       const T* data;
-               public:
-                       variable_ptr(const T* ptr, unsigned int size=0) : data(ptr), length(size){}
+               protected:
+                       //      !! Require Implement There Methods in Sub Class !!!
+                       virtual T* get_data() =0{}
+                       virtual const T* get_data() const =0{}
+                       virtual unsigned int get_length() const =0{}
+                       virtual bool push_data(const T& data) =0{}
                        
+               public:
                        /////////////////
                        
                        template <typename InputIterator, typename _Param>
                        bool parse(InputIterator& it, const _Param& param) const
                        {
-                               const T* p = data;
                                for(unsigned int i=length; i!=0; i--, p++, it++)
                                {
-                                       if ( *it != data )
+                                       if ( push_data(*it) == false )
                                                return false;
                                }
                                return true;
@@ -77,7 +78,7 @@ namespace roast
                        template <typename OutputStream, typename _Document>
                        void generate(OutputStream& os, const _Document& doc) const
                        {
-                               os.write(data, length);
+                               os.write(get_data(), get_length());
                                
                                /*
                                const T* p = data;