Пример #1
0
inline bool hasProperties(Properties p, Properties requiredOnOrOff, bool on) {
  return on ? hasProperties(p, requiredOnOrOff) : hasPropertiesOff(p, requiredOnOrOff);
}
Пример #2
0
/*! This method compares the given attributes and properties with those already present.
	 It compares the given items as inseparable pairs - if the attribute or property is
	 present in name but contains a different value, that does not count and false is
	 returned.
	 \return A bool indicating (directly) both presence and equality.
*/
bool PP_AttrProp::areAlreadyPresent(const gchar ** attributes, const gchar ** properties) const
{
	if (attributes && *attributes)
	{
		const gchar ** p = attributes;
		while (*p)
		{
			/*
			    It seems that we also want empty strings for attributes,
				at least for the 'param' attribute which goes with fields.
				Is this bogus too? -PL

				Yes. 
				We use empty strings and NULL in values to indicate that the
				attribute/property should be absent. Sometimes these values filter down
				here, so we need to handle this. TF
			*/
			// UT_return_val_if_fail (p[1] /* && *p[1]*/, false);	// require value for each name

			// first deal with the case where the value is set to NULL or "" -- we want
			// that attribute to be absent, not present
			const gchar * szValue = NULL;

			if((!p[1] || !*p[1]) && getAttribute(p[0],szValue) && szValue && *szValue)
				return false;
			// the 'props' attribute has to be handled separatedly, since it is not
			// returned using getAttribute() (it is not stored as attribute)
			else if((!p[1] || !*p[1]) && !strcmp(p[0],"props") && hasProperties())
				return false;
			else if(p[1] && *p[1])
			{
				if (!getAttribute(p[0],szValue))
					return false;		// item not present
				if (strcmp(p[1],szValue)!=0)
					return false;		// item has different value
			}
					
			p += 2;
		}
	}

	if (properties && *properties)
	{
		const gchar ** p = properties;
		while (*p)
		{
			/*
				Jeff, I weakened the following assert because we
				*want* to represent no tabstops as an empty string.
				If this isn't safe, let me know.   -- PCR

				We use empty strings and NULL in values to indicate that the
				attribute/property should be absent. Sometimes these values filter down
				here, so we need to handle this. TF
			*/
			// UT_return_val_if_fail (p[1] /* && *p[1]*/, false);	// require value for each name

			// first deal with the case where the value is set to NULL or "" -- we want
			// that attribute to be absent, not present
			const gchar * szValue = NULL;

			if((!p[1] || !*p[1]) && getProperty(p[0],szValue) && szValue && *szValue)
				return false;
			else if(p[1] && p[1])
			{
				if (!getProperty(p[0],szValue))
					return false;		// item not present
				if (strcmp(p[1],szValue)!=0)
					return false;		// item has different value
			}
			
			p += 2;
		}
	}

	return true;						// everything matched
}