コード例 #1
0
ファイル: k8s_component.cpp プロジェクト: PerthCharles/sysdig
bool k8s_component::selectors_in_labels(const k8s_pair_list& labels) const
{
	const k8s_pair_list& selectors = get_selectors();
	for(const auto& selector : selectors)
	{
		if(!selector_in_labels(selector, labels))
		{
			return false;
		}
	}
	return true;
}
コード例 #2
0
/**
 * Read the next rule from the input data
 * @param data the CSS data to read from
 * @param offset VAR param of the offset into data to read from
 * @return the rule or NULL
 */
static css_rule *get_css_rule( const char *data, int *offset )
{
	int pos = *offset;
	int state = 0;
	int bodyStart=-1,bodyEnd=-1;
	css_rule *rule = NULL;
	while ( state >= 0 && data[pos] != 0 )
	{
		switch ( state )
		{
			case 0:	// collecting selector
				if ( data[pos] == '{' )
				{
					bodyStart = pos;
					state = 1;
				}
				pos++;
				break;
			case 1:	// collecting body
				if ( data[pos] == '}' )
				{
					bodyEnd = pos;
					state = -1;
				}
				pos++;
				break;
		}
	}
	if ( (bodyStart == -1 || bodyEnd == -1)&&state!=0 )
	{
		warning("failed to find css rule body", 0 );
		return NULL;
	}
	else
	{
		rule = css_rule_create();
		if ( rule != NULL )
        {
            int res = get_selectors( data, *offset, bodyStart-(*offset), rule );
            if ( res )
                res = get_properties( &data[bodyStart+1], (bodyEnd-bodyStart), 
                    rule );
        }
        // update pos even if rule-reading fails
        *offset = pos;
        if ( css_rule_valid(rule) )
            return rule;
        else if ( rule != NULL )
            css_rule_dispose( rule );
        return NULL;
	}
}