#define __SFJP_ROAST__lexical__debug_util_HPP__
//#define ROAST_LEXICAL_DEBUG
+#include <string>
+#include <memory.h>
+#include <string.h>
namespace roast
{
class named_base
{
private:
- const char* m_name;
+ //const char* m_name;
+ ::std::string m_name;
protected:
named_base(const char* name):m_name(name){}
+ named_base(::std::string name):m_name(name){}
public:
- const char* get_name() const { return m_name; }
+ const char* get_name() const { return m_name.c_str(); }
};
#define ROAST_LEXICAL_DECL_NAMED(TARGET) \
class _##TARGET##_name : public named_base{ public: _##TARGET##_name() : named_base(#TARGET){} };
- class named_start : public named_base{ public: named_start(const char* name):named_base(name){} };
+ class named_start : public named_base{
+ ::std::string _get_name_it(const char* name, const char* it){
+ char work[32];
+ memset(work,0,sizeof(work));
+ strncpy(work, it, sizeof(work)-1);
+ if ( strlen(work) == sizeof(work)-1 )
+ strncpy(work+(sizeof(work)-1-4), "...", 3);
+
+ ::std::string s = name;
+ return s + " (it=\"" + work + "\")";
+ }
+ public:
+ named_start(const char* name):named_base(name){}
+ named_start(const char* name, const char* it):named_base(_get_name_it(name,it)){}
+ };
class named_end : public named_base{ public: named_end(const char* name):named_base(name){}};
}
template <typename _It, typename _Param>
void on_analyze_start(_It& it, _Param& param)
{
- param << named_start(_namer.get_name());
+ param << named_start(_namer.get_name(), it);
}
template <typename _It, typename _Param>
void on_analyze_end(_It& it, _Param& param)