From 09c0cacee257cd5997913b5b01265b1bc36c3d4c Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Sun, 15 Nov 2009 16:27:56 +0100 Subject: [PATCH] add comparison to c-string for Literal --- src/lib/symbol.hpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/lib/symbol.hpp b/src/lib/symbol.hpp index 562a6bf09..fcc9041ce 100644 --- a/src/lib/symbol.hpp +++ b/src/lib/symbol.hpp @@ -51,6 +51,7 @@ namespace lib { /** inline string literal * @todo improve interaction with Symbol * @todo make it non-nullable + * @todo maybe use boost/operators Ticket #417 */ class Literal { @@ -126,6 +127,32 @@ namespace lib { return ! (sy1 == sy2); } + /// comparison with c-strings //////TICKET #417 + inline bool + operator== (Literal sy1, const char* const sy2) + { + return (sy1 == Literal(sy2)); + } + + inline bool + operator== (const char* const sy1, Literal sy2) + { + return (Literal(sy1) == sy2); + } + + inline bool + operator!= (Literal sy1, const char* const sy2) + { + return ! (sy1 == Literal(sy2)); + } + + inline bool + operator!= (const char* const sy1, Literal sy2) + { + return ! (Literal(sy1) == sy2); + } + + /// string concatenation inline std::string operator+ (std::string str, Literal const& sym) {