Parser/QueryParser.cpp
void QueryParser::addTriple(string subject, string predicate, string object, \
	QueryTree::GroupPattern &group_pattern)
{
	// Add one pattern
	group_pattern.addOnePattern(QueryTree::GroupPattern::Pattern(QueryTree::GroupPattern::Pattern::Element(subject), \
		QueryTree::GroupPattern::Pattern::Element(predicate), \
		QueryTree::GroupPattern::Pattern::Element(object)));

	// Scope of filter
	for (int j = (int)group_pattern.sub_group_pattern.size() - 1; j > 0; j--)
	{
		if (group_pattern.sub_group_pattern[j].type == QueryTree::GroupPattern::SubGroupPattern::Pattern_type &&
			group_pattern.sub_group_pattern[j - 1].type == QueryTree::GroupPattern::SubGroupPattern::Filter_type)
		{
			QueryTree::GroupPattern::SubGroupPattern tmp(group_pattern.sub_group_pattern[j - 1]);
			group_pattern.sub_group_pattern[j - 1] = group_pattern.sub_group_pattern[j];
			group_pattern.sub_group_pattern[j] = tmp;
		}
		else
			break;
	}
}
/**
	Helper function that adds a triple to group_pattern given its subject, predicate, 
	and object; and reorders triples so that FILTER is moved to the back of its scope.
	Called from visitTriplesSameSubjectpath and visitTriplesSameSubject.

	@param subject subject string.
	@param predicate predicate string.
	@param object object string.
	@param group_pattern a group graph pattern.
*/
Helper function that adds a triple to group_pattern given its subject, predicate,
and object; and reorders triples so that FILTER is moved to the back of its scope.
Helper function that adds a triple to group_pattern given its subject predicate and object ; and reorders triples so that FILTER is moved to the back of its scope .
void QueryParser::addTriple(string subject, string predicate, string object, \
	QueryTree::GroupPattern &group_pattern)
{
	group_pattern.addOnePattern(QueryTree::GroupPattern::Pattern(QueryTree::GroupPattern::Pattern::Element(subject), \
		QueryTree::GroupPattern::Pattern::Element(predicate), \
		QueryTree::GroupPattern::Pattern::Element(object)));
	for (int j = (int)group_pattern.sub_group_pattern.size() - 1; j > 0; j--)
	{
		if (group_pattern.sub_group_pattern[j].type == QueryTree::GroupPattern::SubGroupPattern::Pattern_type &&
			group_pattern.sub_group_pattern[j - 1].type == QueryTree::GroupPattern::SubGroupPattern::Filter_type)
		{
			QueryTree::GroupPattern::SubGroupPattern tmp(group_pattern.sub_group_pattern[j - 1]);
			group_pattern.sub_group_pattern[j - 1] = group_pattern.sub_group_pattern[j];
			group_pattern.sub_group_pattern[j] = tmp;
		}
		else
			break;
	}
}
void QueryParser :: addTriple ( string subject , string predicate , string object , QueryTree :: GroupPattern & group_pattern ) { group_pattern . addOnePattern ( QueryTree :: GroupPattern :: Pattern ( QueryTree :: GroupPattern :: Pattern :: Element ( subject ) , QueryTree :: GroupPattern :: Pattern :: Element ( predicate ) , QueryTree :: GroupPattern :: Pattern :: Element ( object ) ) ) ; for ( int j = ( int ) group_pattern . sub_group_pattern . size ( ) - 1 ; j > 0 ; j -- ) { if ( group_pattern . sub_group_pattern [ j ] . type == QueryTree :: GroupPattern :: SubGroupPattern :: Pattern_type && group_pattern . sub_group_pattern [ j - 1 ] . type == QueryTree :: GroupPattern :: SubGroupPattern :: Filter_type ) { QueryTree :: GroupPattern :: SubGroupPattern tmp ( group_pattern . sub_group_pattern [ j - 1 ] ) ; group_pattern . sub_group_pattern [ j - 1 ] = group_pattern . sub_group_pattern [ j ] ; group_pattern . sub_group_pattern [ j ] = tmp ; } else break ; } }
Helper function that adds a triple to group_pattern given its subject, predicate,
and object; and reorders triples so that FILTER is moved to the back of its scope.
Helper function that adds a triple to group_pattern given its subject predicate and object ; and reorders triples so that FILTER is moved to the back of its scope .
// Add one pattern // Scope of filter