--- /dev/null
+// 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__
--- /dev/null
+// 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__
--- /dev/null
+// 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__
#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>{};
-
- ////////////////////////////////////////////////////////
}
}