From 3831dbb9c8aa44654f218c4607f396558fce9747 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 24 Oct 2011 16:26:45 +0200 Subject: Add support for string representation of sql_token --- odb/sql-token.cxx | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) (limited to 'odb/sql-token.cxx') diff --git a/odb/sql-token.cxx b/odb/sql-token.cxx index fe6b836..6fc548b 100644 --- a/odb/sql-token.cxx +++ b/odb/sql-token.cxx @@ -3,7 +3,7 @@ // copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC // license : GNU GPL v3; see accompanying LICENSE file -#include +#include #include @@ -11,34 +11,36 @@ using namespace std; static char punctuation_literals[] = {';', ',', '(', ')', '='}; -ostream& -operator<< (ostream& os, sql_token const& t) +string sql_token:: +string () const { - switch (t.type ()) + switch (type ()) { case sql_token::t_eos: { - os << ""; - break; + return ""; } case sql_token::t_identifier: { - os << t.identifier (); - break; + return identifier (); } case sql_token::t_punctuation: { - os << punctuation_literals[t.punctuation ()]; - break; + return std::string (1, punctuation_literals[punctuation ()]); } case sql_token::t_string_lit: case sql_token::t_int_lit: case sql_token::t_float_lit: { - os << t.literal (); - break; + return literal (); } } - return os; + return ""; +} + +ostream& +operator<< (ostream& os, sql_token const& t) +{ + return os << t.string (); } -- cgit v1.1