コード例 #1
0
gboolean
url_addrspec_start (const char *in, const char *pos, const char *inend, urlmatch_t *match)
{
	register const char *inptr = pos;
	
	g_assert (*inptr == '@');
	
	if (inptr == in)
		return FALSE;
	
	inptr--;
	
	while (inptr > in) {
		if (is_atom (*inptr))
			inptr--;
		else
			break;
		
		while (inptr > in && is_atom (*inptr))
			inptr--;
		
		if (inptr > in && *inptr == '.')
			inptr--;
	}
	
	if (!is_atom (*inptr) || is_open_brace (*inptr))
		inptr++;
	
	if (inptr == pos)
		return FALSE;
	
	match->um_so = (inptr - in);
	
	return TRUE;
}
コード例 #2
0
ファイル: string_generator.hpp プロジェクト: imos/icfpc2015
    uuid operator()(CharIterator begin, CharIterator end) const
    {
        typedef typename std::iterator_traits<CharIterator>::value_type char_type;

        // check open brace
        char_type c = get_next_char(begin, end);
        bool has_open_brace = is_open_brace(c);
        char_type open_brace_char = c;
        if (has_open_brace) {
            c = get_next_char(begin, end);
        }

        bool has_dashes = false;

        uuid u;
        int i=0;
        for (uuid::iterator it_byte=u.begin(); it_byte!=u.end(); ++it_byte, ++i) {
            if (it_byte != u.begin()) {
                c = get_next_char(begin, end);
            }
            
            if (i == 4) {
                has_dashes = is_dash(c);
                if (has_dashes) {
                    c = get_next_char(begin, end);
                }
            }
            
            if (has_dashes) {
                if (i == 6 || i == 8 || i == 10) {
                    if (is_dash(c)) {
                        c = get_next_char(begin, end);
                    } else {
                        throw_invalid();
                    }
                }
            }

            *it_byte = get_value(c);

            c = get_next_char(begin, end);
            *it_byte <<= 4;
            *it_byte |= get_value(c);
        }

        // check close brace
        if (has_open_brace) {
            c = get_next_char(begin, end);
            check_close_brace(c, open_brace_char);
        }
        
        return u;
    }
コード例 #3
0
ファイル: cql_uuid.cpp プロジェクト: denji/cpp-driver
// Adapted from boost::uuids
cql::cql_uuid_t::cql_uuid_t(const std::string& uuid_string) {
    typedef std::string::value_type char_type;
    std::string::const_iterator begin = uuid_string.begin(),
                                end   = uuid_string.end();
    
    // check open brace
    char_type c = get_next_char(begin, end);
    bool has_open_brace = is_open_brace(c);
    char_type open_brace_char = c;
    if (has_open_brace) {
        c = get_next_char(begin, end);
    }
    
    bool has_dashes = false;
    
    size_t i = 0u;
    for (cql_byte_t* it_byte = _uuid; it_byte != _uuid+_size; ++it_byte, ++i) {
        if (it_byte != _uuid) {
            c = get_next_char(begin, end);
        }
        
        if (i == 4) {
            has_dashes = is_dash(c);
            if (has_dashes) {
                c = get_next_char(begin, end);
            }
        }
        
        if (has_dashes) {
            if (i == 6 || i == 8 || i == 10) {
                if (is_dash(c)) {
                    c = get_next_char(begin, end);
                } else {
                    throw std::invalid_argument("String to make UUID from has a misplaced dash");
                }
            }
        }
        
        *it_byte = get_value(c);
        
        c = get_next_char(begin, end);
        *it_byte <<= 4;
        *it_byte |= get_value(c);
    }
    
    // check close brace
    if (has_open_brace) {
        c = get_next_char(begin, end);
        check_close_brace(c, open_brace_char);
    }
}
コード例 #4
0
ファイル: camel-url-scanner.c プロジェクト: Pecisk/eds-gtasks
gboolean
camel_url_web_start (const gchar *in,
                     const gchar *pos,
                     const gchar *inend,
                     urlmatch_t *match)
{
	if (pos > in && !strncmp (pos, "www", 3)) {
		/* make sure we aren't actually part of another word */
		if (!is_open_brace (pos[-1]) && !isspace (pos[-1]))
			return FALSE;
	}

	match->um_so = (pos - in);

	return TRUE;
}