inline bool 
    handle_identifier(boost::wave::token_id prev, 
        boost::wave::token_id before, StringT const &value)
    {
        using namespace boost::wave;
        switch (static_cast<unsigned int>(prev)) {
        case T_IDENTIFIER:
        case T_NONREPLACABLE_IDENTIFIER:
        case T_COMPL_ALT:
        case T_OR_ALT:
        case T_AND_ALT:
        case T_NOT_ALT:
        case T_XOR_ALT:
        case T_ANDASSIGN_ALT:
        case T_ORASSIGN_ALT:
        case T_XORASSIGN_ALT:
        case T_NOTEQUAL_ALT:
        case T_FIXEDPOINTLIT:
            return true;

        case T_FLOATLIT:
        case T_INTLIT:
        case T_PP_NUMBER:
            return (value.size() > 1 || (value[0] != 'e' && value[0] != 'E'));
            
         // avoid constructing universal characters (\u1234)
        case TOKEN_FROM_ID('\\', UnknownTokenType):
            return would_form_universal_char(value);
        }
        return false;
    }
Exemplo n.º 2
0
void
read_s(
	StringT& str,
	void const* data,
	std::size_t const size
) {
	duct::IO::StreamContext ctx(FromU::id, duct::Endian::system);
	duct::IO::imemstream stream(data, size * FromU::char_size);
	std::printf(
		"stream size: %lu\n",
		static_cast<unsigned long>(duct::IO::size(stream))
	);
	DUCT_ASSERTE(stream.good());
	ctx.read_string(
		stream, str, static_cast<std::streamsize>(size), duct::CHAR_NULL
	);
	DUCT_ASSERTE(stream.good());
	print_states(stream);
	std::printf(
		"String [size: %lu bsize: %lu len: %lu]: |",
		static_cast<unsigned long>(size),
		static_cast<unsigned long>(size*FromU::char_size),
		static_cast<unsigned long>(str.size())
	);
	std::cout << str << "|\n";
	str.clear();
}
 inline bool
 would_form_universal_char (StringT const &value)
 {
     if ('u' != value[0] && 'U' != value[0])
         return false;
     if ('u' == value[0] && value.size() < 5)
         return false;
     if ('U' == value[0] && value.size() < 9)
         return false;
 
 typename StringT::size_type pos = 
     value.find_first_not_of("0123456789abcdefABCDEF", 1);
     
     if (StringT::npos == pos || 
         ('u' == value[0] && pos > 5) ||
         ('U' == value[0] && pos > 9))
     {
         return true;        // would form an universal char
     }
     return false;
 }
Exemplo n.º 4
0
inline bool 
is_trigraph(StringT const& trigraph)
{
    if (trigraph.size() < 3 || '?' != trigraph[0] || '?' != trigraph[1])
        return false;
        
    switch (trigraph[2]) {
    case '\'': case '=': case '/': case '(':
    case ')':  case '<': case '>': case '!':
    case '-':
        break;

    default:
        return false;
    }

    return true;
}
inline bool 
is_special_macroname (StringT const &name)
{
    if (name.size() < 7)
        return false;

    if ("defined" == name)
        return true;

    if ('_' == name[0] && '_' == name[1]) {
    StringT str = name.substr(2);

        if (str == "cplusplus"  || str == "STDC__" || 
            str == "TIME__"     || str == "DATE__" ||
            str == "LINE__"     || str == "FILE__" ||
            str == "INCLUDE_LEVEL__")
        {
            return true;
        }
    }
    return false;
}
Exemplo n.º 6
0
 /**
  * show help and usage information
  *
  * @param out output stream
  * @param program_name the name of executable to display
  * @param usage_str additional help shown before help for options
  *
  * @param show_usage should "Usage:" information be shown, can be
  * useful when this help is shown additionally to main help
  */
 void show_help(std::ostream &out, char const *program_name
                , StringT const &usage_str = ""
                , bool show_usage = true) const
 {
     if (show_usage) {
         if (usage_str.size()) {
             out << "Usage: " << program_name << " " << usage_str;
         } else {
             out << "Usage: " << program_name << " [options]\n"
                 << "\twhere [options] are:\n";
         }
     } else {
         out << usage_str;
     }
     std::map<StringT, std::pair<char, StringT> > grouped;
     for (auto p : short_opts_)
         grouped[p.second].first = p.first;
     for (auto p : long_opts_)
         grouped[p.second].second = p.first;
     for (auto p : grouped) {
         auto &sl = p.second;
         out << "\t";
         if (sl.first) {
             out << '-' << sl.first;
             if (opt_with_params_.count(p.first))
                 out << " <" << p.first << '>';
         }
         out << "\t";
         if (sl.second.size()) {
             out << "--" << sl.second;
             if (opt_with_params_.count(p.first))
                 out << " <" << p.first << '>';
         }
         out << "\n";
     }
 }
Exemplo n.º 7
0
	static int inline mg_write(struct mg_connection* conn, const StringT& string)
	{
		return mg_write(conn, string.c_str(), string.size());
	}