/usr/include/boost/spirit/home/x3/string
Edit: /usr/include/boost/spirit/home/x3/string/literal_string.hpp (8275B)
/*=============================================================================
Copyright (c) 2001-2014 Joel de Guzman
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#if !defined(BOOST_SPIRIT_X3_LITERAL_STRING_APR_18_2006_1125PM)
#define BOOST_SPIRIT_X3_LITERAL_STRING_APR_18_2006_1125PM
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
namespace boost { namespace spirit { namespace x3
{
template >
struct literal_string : parser>
{
typedef typename Encoding::char_type char_type;
typedef Encoding encoding;
typedef Attribute attribute_type;
static bool const has_attribute =
!is_same::value;
static bool const handles_container = has_attribute;
constexpr literal_string(typename add_reference< typename add_const::type >::type str)
: str(str)
{}
template
bool parse(Iterator& first, Iterator const& last
, Context const& context, unused_type, Attribute_& attr) const
{
x3::skip_over(first, last, context);
return detail::string_parse(str, first, last, attr, get_case_compare(context));
}
String str;
};
namespace standard
{
constexpr literal_string
string(char const* s)
{
return { s };
}
inline literal_string, char_encoding::standard>
string(std::basic_string const& s)
{
return { s };
}
inline constexpr literal_string
lit(char const* s)
{
return { s };
}
template
literal_string, char_encoding::standard, unused_type>
lit(std::basic_string const& s)
{
return { s };
}
}
#ifndef BOOST_SPIRIT_NO_STANDARD_WIDE
namespace standard_wide
{
constexpr literal_string
string(wchar_t const* s)
{
return { s };
}
inline literal_string, char_encoding::standard_wide>
string(std::basic_string const& s)
{
return { s };
}
constexpr literal_string
lit(wchar_t const* s)
{
return { s };
}
inline literal_string, char_encoding::standard_wide, unused_type>
lit(std::basic_string const& s)
{
return { s };
}
}
#endif
#if defined(BOOST_SPIRIT_X3_UNICODE)
namespace unicode
{
constexpr literal_string
string(char32_t const* s)
{
return { s };
}
inline literal_string, char_encoding::unicode>
string(std::basic_string const& s)
{
return { s };
}
constexpr literal_string
lit(char32_t const* s)
{
return { s };
}
inline literal_string, char_encoding::unicode, unused_type>
lit(std::basic_string const& s)
{
return { s };
}
}
#endif
namespace ascii
{
constexpr literal_string
string(wchar_t const* s)
{
return { s };
}
inline literal_string, char_encoding::ascii>
string(std::basic_string const& s)
{
return { s };
}
constexpr literal_string
lit(char const* s)
{
return { s };
}
template
literal_string, char_encoding::ascii, unused_type>
lit(std::basic_string const& s)
{
return { s };
}
}
namespace iso8859_1
{
constexpr literal_string
string(wchar_t const* s)
{
return { s };
}
inline literal_string, char_encoding::iso8859_1>
string(std::basic_string const& s)
{
return { s };
}
constexpr literal_string
lit(char const* s)
{
return { s };
}
template
literal_string, char_encoding::iso8859_1, unused_type>
lit(std::basic_string const& s)
{
return { s };
}
}
using standard::string;
using standard::lit;
#ifndef BOOST_SPIRIT_NO_STANDARD_WIDE
using standard_wide::string;
using standard_wide::lit;
#endif
namespace extension
{
template
struct as_parser
{
typedef literal_string<
char const*, char_encoding::standard, unused_type>
type;
typedef type value_type;
static constexpr type call(char const* s)
{
return type(s);
}
};
template
struct as_parser : as_parser {};
#ifndef BOOST_SPIRIT_NO_STANDARD_WIDE
template
struct as_parser
{
typedef literal_string<
wchar_t const*, char_encoding::standard_wide, unused_type>
type;
typedef type value_type;
static constexpr type call(wchar_t const* s)
{
return type(s);
}
};
template
struct as_parser : as_parser {};
#endif
template <>
struct as_parser
{
typedef literal_string<
char const*, char_encoding::standard, unused_type>
type;
typedef type value_type;
static constexpr type call(char const* s)
{
return type(s);
}
};
template
struct as_parser< std::basic_string >
{
typedef literal_string<
Char const*, char_encoding::standard, unused_type>
type;
typedef type value_type;
static type call(std::basic_string const& s)
{
return type(s.c_str());
}
};
}
template
struct get_info>
{
typedef std::string result_type;
std::string operator()(literal_string const& p) const
{
return '"' + to_utf8(p.str) + '"';
}
};
}}}
#endif