OSDN Git Service

repeat.hpp を、 fixed_repeat.hpp, hard_repeat.hpp, optional_repeat.hpp へ分離
authormyun2 <myun2@nwhite.info>
Sat, 7 Jul 2012 13:48:47 +0000 (22:48 +0900)
committermyun2 <myun2@nwhite.info>
Sat, 7 Jul 2012 13:48:47 +0000 (22:48 +0900)
roast/include/roast/lexical2/fixed_repeat.hpp [new file with mode: 0644]
roast/include/roast/lexical2/hard_repeat.hpp [new file with mode: 0644]
roast/include/roast/lexical2/optional_repeat.hpp [new file with mode: 0644]
roast/include/roast/lexical2/repeat.hpp

diff --git a/roast/include/roast/lexical2/fixed_repeat.hpp b/roast/include/roast/lexical2/fixed_repeat.hpp
new file mode 100644 (file)
index 0000000..638de56
--- /dev/null
@@ -0,0 +1,63 @@
+//     Roast+ License
+/*
+*/
+#ifndef __SFJP_ROAST__lexical2__fixed_repeat_HPP__
+#define __SFJP_ROAST__lexical2__fixed_repeat_HPP__
+
+namespace roast
+{
+       namespace lexical
+       {
+               ////////////////////////////////////////////////////////
+
+               template <typename T, unsigned int N>
+               class fixed_repeat// : public lengthable
+               {
+               public:
+                       const T t;
+                       
+                       fixed_repeat(){}
+                       fixed_repeat(const T& t_in) : t(t_in){}
+
+                       //const static int length = length_of<T>::value * N;
+
+                       /////////////////////////////////////////////////////////////
+
+                       template <typename _It, typename _Param>
+                       bool parse(_It& it, _Param& param)
+                       {
+                               _It it_work = it;
+                               for(unsigned int i=0; i<N; i++)
+                               {
+                                       if ( t.parse(it_work, param) == false )
+                                               return false;
+                                       else
+                                               it = it_work;
+                               }
+                               return true;
+                       }
+
+                       //----
+
+                       template <typename _Strm, typename _Document>
+                       bool generate(_Strm& strm, _Document& doc) const
+                       {
+                               for(unsigned int i=0; i<N; i++)
+                               {
+                                       /*if ( t.generate(strm, doc) == false )
+                                               return false;*/
+                                       t.generate(strm, doc);
+                               }
+                               return true;
+                       }
+               };
+               template <typename T, unsigned int N>
+               class fixed_loop : public fixed_repeat<T,N>{};
+               /*template <typename T, unsigned int N>
+               class n_loop : public fixed_loop<T,N>{};*/
+               
+               ////////////////////////////////////////////////////////
+       }
+}
+
+#endif//__SFJP_ROAST__lexical2__repeat_HPP__
diff --git a/roast/include/roast/lexical2/hard_repeat.hpp b/roast/include/roast/lexical2/hard_repeat.hpp
new file mode 100644 (file)
index 0000000..02f2216
--- /dev/null
@@ -0,0 +1,86 @@
+//     Roast+ License
+/*
+*/
+#ifndef __SFJP_ROAST__lexical2__hard_repeat_HPP__
+#define __SFJP_ROAST__lexical2__hard_repeat_HPP__
+
+namespace roast
+{
+       namespace lexical
+       {
+               ////////////////////////////////////////////////////////
+
+               template <typename T, unsigned int N>
+               class hard_repeat// : public lengthable
+               {
+               public:
+                       const T t;
+                       
+                       hard_repeat(){}
+                       hard_repeat(const T& t_in) : t(t_in){}
+                       
+                       //const static int length = length_of<T>::value * N;
+
+                       template <typename _It, typename _Param>
+                       bool parse(_It& it, _Param& param)
+                       {
+                               //T t;
+                               _It it_work = it;
+                               if ( t.parse(it_work, param) == false )
+                                       return false;
+                               else
+                               {
+                                       hard_repeat<T,N-1> fr2;
+                                       return fr2.parse(it_work,param);
+                               }
+                       }
+
+                       //----
+
+                       template <typename _Strm, typename _Document>
+                       bool generate(_Strm& strm, _Document& doc) const
+                       {
+                               //T t;
+                               if ( t.generate(strm, doc) == false )
+                                       return false;
+                               else
+                               {
+                                       hard_repeat<T,N-1> fr2;
+                                       return fr2.generate(strm,doc);
+                               }
+                       }
+               };
+
+               template <typename T>
+               class hard_repeat<T,1>
+               {
+               public:
+                       template <typename _It, typename _Param>
+                       bool parse(_It& it, _Param& param)
+                       {
+                               T t;
+                               _It it_work = it;
+                               if ( t.parse(it_work, param) == false )
+                                       return false;
+                               else
+                                       it = it_work;
+                               return true;
+                       }
+
+                       //----
+
+                       template <typename _Strm, typename _Document>
+                       bool generate(_Strm& strm, _Document& doc) const
+                       {
+                               T t;
+                               if ( t.generate(strm, doc) == false )
+                                       return false;
+                               return true;
+                       }
+               };
+               
+               ////////////////////////////////////////////////////////
+       }
+}
+
+#endif//__SFJP_ROAST__lexical2__hard_repeat_HPP__
diff --git a/roast/include/roast/lexical2/optional_repeat.hpp b/roast/include/roast/lexical2/optional_repeat.hpp
new file mode 100644 (file)
index 0000000..dfe9f73
--- /dev/null
@@ -0,0 +1,67 @@
+//     Roast+ License
+/*
+*/
+#ifndef __SFJP_ROAST__lexical2__optional_repeat_HPP__
+#define __SFJP_ROAST__lexical2__optional_repeat_HPP__
+
+namespace roast
+{
+       namespace lexical
+       {
+               ////////////////////////////////////////////////////////
+               
+               template <typename T>
+               class optional_repeat
+               {
+               public:
+                       template <typename _It, typename _Param>
+                       bool parse(_It& it, _Param& param)
+                       {
+                               T t;
+                               _It it_work = it;
+                               for(;;)
+                               {
+                                       if ( t.parse(it_work, param) == false )
+                                               break;
+                                       else
+                                               it = it_work;
+                               }
+                               return true;
+                       }
+
+                       //----
+                       
+                       template <typename _Strm, typename _Document>
+                       bool generate(_Strm& strm, _Document& doc) const
+                       {
+                               T t;
+                               for(;;)
+                               {
+                                       /*if ( t.generate(strm, doc) == false )
+                                               break;*/
+                                       t.generate(strm, doc);
+                               }
+                               return true;
+                       }
+               };
+               template <typename T>
+               class opt_repeat : public optional_repeat<T>{};
+               
+               //////
+               
+               template <typename T>
+               class optional_repeat_nogen : public optional_repeat<T>
+               {
+               public:
+                       template <typename _Strm, typename _Document>
+                       bool generate(_Strm& strm, _Document& doc) const
+                       {
+                               return true;
+                       }
+               };
+               
+               ////////////////////////////////////////////////////////
+       }
+}
+
+#endif//__SFJP_ROAST__lexical2__optional_repeat_HPP__
index c2eb21a..1eeb14b 100644 (file)
 #ifndef __SFJP_ROAST__lexical2__repeat_HPP__
 #define __SFJP_ROAST__lexical2__repeat_HPP__
 
+#include "roast/lexical2/fixed_repeat.hpp"
+#include "roast/lexical2/hard_repeat.hpp"
+#include "roast/lexical2/optional_repeat.hpp"
+
 namespace roast
 {
        namespace lexical
        {
-               ////////////////////////////////////////////////////////
-               
-               template <typename T>
-               class optional_repeat
-               {
-               public:
-                       template <typename _It, typename _Param>
-                       bool parse(_It& it, _Param& param)
-                       {
-                               T t;
-                               _It it_work = it;
-                               for(;;)
-                               {
-                                       if ( t.parse(it_work, param) == false )
-                                               break;
-                                       else
-                                               it = it_work;
-                               }
-                               return true;
-                       }
-
-                       //----
-                       
-                       template <typename _Strm, typename _Document>
-                       bool generate(_Strm& strm, _Document& doc) const
-                       {
-                               T t;
-                               for(;;)
-                               {
-                                       /*if ( t.generate(strm, doc) == false )
-                                               break;*/
-                                       t.generate(strm, doc);
-                               }
-                               return true;
-                       }
-               };
-               template <typename T>
-               class opt_repeat : public optional_repeat<T>{};
-               
-               //////
-               
-               template <typename T>
-               class optional_repeat_nogen : public optional_repeat<T>
-               {
-               public:
-                       template <typename _Strm, typename _Document>
-                       bool generate(_Strm& strm, _Document& doc) const
-                       {
-                               return true;
-                       }
-               };
-
-               ////////////////////
-
-               template <typename T, unsigned int N>
-               class fixed_repeat// : public lengthable
-               {
-               public:
-                       const T t;
-                       
-                       fixed_repeat(){}
-                       fixed_repeat(const T& t_in) : t(t_in){}
-
-                       //const static int length = length_of<T>::value * N;
-
-                       /////////////////////////////////////////////////////////////
-
-                       template <typename _It, typename _Param>
-                       bool parse(_It& it, _Param& param)
-                       {
-                               _It it_work = it;
-                               for(unsigned int i=0; i<N; i++)
-                               {
-                                       if ( t.parse(it_work, param) == false )
-                                               return false;
-                                       else
-                                               it = it_work;
-                               }
-                               return true;
-                       }
-
-                       //----
-
-                       template <typename _Strm, typename _Document>
-                       bool generate(_Strm& strm, _Document& doc) const
-                       {
-                               for(unsigned int i=0; i<N; i++)
-                               {
-                                       /*if ( t.generate(strm, doc) == false )
-                                               return false;*/
-                                       t.generate(strm, doc);
-                               }
-                               return true;
-                       }
-               };
-               template <typename T, unsigned int N>
-               class fixed_loop : public fixed_repeat<T,N>{};
-               /*template <typename T, unsigned int N>
-               class n_loop : public fixed_loop<T,N>{};*/
-
-               ////////////////////
-
-               template <typename T, unsigned int N>
-               class hard_repeat// : public lengthable
-               {
-               public:
-                       const T t;
-                       
-                       hard_repeat(){}
-                       hard_repeat(const T& t_in) : t(t_in){}
-                       
-                       //const static int length = length_of<T>::value * N;
-
-                       template <typename _It, typename _Param>
-                       bool parse(_It& it, _Param& param)
-                       {
-                               //T t;
-                               _It it_work = it;
-                               if ( t.parse(it_work, param) == false )
-                                       return false;
-                               else
-                               {
-                                       hard_repeat<T,N-1> fr2;
-                                       return fr2.parse(it_work,param);
-                               }
-                       }
-
-                       //----
-
-                       template <typename _Strm, typename _Document>
-                       bool generate(_Strm& strm, _Document& doc) const
-                       {
-                               //T t;
-                               if ( t.generate(strm, doc) == false )
-                                       return false;
-                               else
-                               {
-                                       hard_repeat<T,N-1> fr2;
-                                       return fr2.generate(strm,doc);
-                               }
-                       }
-               };
-
-               template <typename T>
-               class hard_repeat<T,1>
-               {
-               public:
-                       template <typename _It, typename _Param>
-                       bool parse(_It& it, _Param& param)
-                       {
-                               T t;
-                               _It it_work = it;
-                               if ( t.parse(it_work, param) == false )
-                                       return false;
-                               else
-                                       it = it_work;
-                               return true;
-                       }
-
-                       //----
-
-                       template <typename _Strm, typename _Document>
-                       bool generate(_Strm& strm, _Document& doc) const
-                       {
-                               T t;
-                               if ( t.generate(strm, doc) == false )
-                                       return false;
-                               return true;
-                       }
-               };
-               
-               //
-
                template <typename T, unsigned int N>
                class repeat : public fixed_repeat<T,N>{};
-               
-               ////////////////////////////////////////////////////////
        }
 }