Beispiel #1
0
// Called when terminal type is selected.
// This procedure should parse options on the command line.
// A list of the currently selected options should be stored in term_options[],
// in a form suitable for use with the set term command.
// term_options[] is used by the save command.  Use options_null() if no options are available." *
void qt_options()
{
	char *s = NULL;
	QString fontSettings;
	bool duplication = false;
	bool set_enhanced = false, set_font = false;
	bool set_persist = false, set_number = false;
	bool set_raise = false, set_ctrl = false;
	bool set_title = false, set_close = false;
	bool set_capjoin = false, set_size = false;
	bool set_widget = false;

#define SETCHECKDUP(x) { c_token++; if (x) duplication = true; x = true; }

	while (!END_OF_COMMAND)
	{
		FPRINTF((stderr, "processing token\n"));
		switch (lookup_table(&qt_opts[0], c_token)) {
		case QT_WIDGET:
			SETCHECKDUP(set_widget);
			if (!(s = try_to_get_string()))
				int_error(c_token, "widget: expecting string");
			if (*s)
				qt_optionWidget = QString(s);
			free(s);
			break;
		case QT_FONT:
			SETCHECKDUP(set_font);
			if (!(s = try_to_get_string()))
				int_error(c_token, "font: expecting string");
			if (*s)
			{
				fontSettings = QString(s);
				QStringList list = fontSettings.split(',');
				if ((list.size() > 0) && !list[0].isEmpty())
					qt_optionFontName = list[0];
				if ((list.size() > 1) && (list[1].toInt() > 0))
					qt_optionFontSize = list[1].toInt();
			}
			free(s);
			break;
		case QT_ENHANCED:
			SETCHECKDUP(set_enhanced);
			qt_optionEnhanced = true;
			term->flags |= TERM_ENHANCED_TEXT;
			break;
		case QT_NOENHANCED:
			SETCHECKDUP(set_enhanced);
			qt_optionEnhanced = false;
			term->flags &= ~TERM_ENHANCED_TEXT;
			break;
		case QT_SIZE:
			SETCHECKDUP(set_size);
			if (END_OF_COMMAND)
				int_error(c_token, "size requires 'width,heigth'");
			qt_optionWidth = real_expression();
			if (!equals(c_token++, ","))
				int_error(c_token, "size requires 'width,heigth'");
			qt_optionHeight = real_expression();
			if (qt_optionWidth < 1 || qt_optionHeight < 1)
				int_error(c_token, "size is out of range");
			break;
		case QT_PERSIST:
			SETCHECKDUP(set_persist);
			qt_optionPersist = true;
			break;
		case QT_NOPERSIST:
			SETCHECKDUP(set_persist);
			qt_optionPersist = false;
			break;
		case QT_RAISE:
			SETCHECKDUP(set_raise);
			qt_optionRaise = true;
			break;
		case QT_NORAISE:
			SETCHECKDUP(set_raise);
			qt_optionRaise = false;
			break;
		case QT_CTRL:
			SETCHECKDUP(set_ctrl);
			qt_optionCtrl = true;
			break;
		case QT_NOCTRL:
			SETCHECKDUP(set_ctrl);
			qt_optionCtrl = false;
			break;
		case QT_TITLE:
			SETCHECKDUP(set_title);
			if (!(s = try_to_get_string()))
				int_error(c_token, "title: expecting string");
			if (*s)
				qt_optionTitle = qt_codec->toUnicode(s);
			free(s);
			break;
		case QT_CLOSE:
			SETCHECKDUP(set_close);
			break;
		case QT_OTHER:
		default:
			qt_optionWindowId = int_expression();
			qt_optionWidget = "";
			if (set_number) duplication = true;
			set_number = true;
			break;
		}

		if (duplication)
			int_error(c_token-1, "Duplicated or contradicting arguments in qt term options.");
	}

	// Save options back into options string in normalized format
	QString termOptions = QString::number(qt_optionWindowId);

	if (set_title)
	{
		termOptions += " title \"" + qt_optionTitle + '"';
		if (qt_initialized)
			qt_out << GETitle << qt_optionTitle;
	}

	if (set_size)
	{
		termOptions += " size " + QString::number(qt_optionWidth) + ", "
		                        + QString::number(qt_optionHeight);
		qt_setSize   = true;
		qt_setWidth  = qt_optionWidth;
		qt_setHeight = qt_optionHeight;
	}

	if (set_enhanced) termOptions +=  qt_optionEnhanced ? " enhanced" : " noenhanced";
	if (set_font)     termOptions += " font \"" + fontSettings + '"';
	if (set_widget)   termOptions += " widget \"" + qt_optionWidget + '"';
	if (set_persist)  termOptions += qt_optionPersist ? " persist" : " nopersist";
	if (set_raise)    termOptions += qt_optionRaise ? " raise" : " noraise";
	if (set_ctrl)     termOptions += qt_optionCtrl ? " ctrl" : " noctrl";

	if (set_close && qt_initialized) qt_out << GECloseWindow << qt_optionWindowId;

	/// @bug change Utf8 to local encoding
	strncpy(term_options, termOptions.toUtf8().data(), MAX_LINE_LEN);
}
Beispiel #2
0
bool URI::operator != (const URI& uri) const
{
	return !equals(uri);
}
Beispiel #3
0
static void testFindIndexForSingleMonth() {
	const int months[] = {6};
	
	assert(equals(0, findIndex(1, months, 1)));
	assert(equals(0, findIndex(2, months, 1)));
	assert(equals(0, findIndex(3, months, 1)));
	assert(equals(0, findIndex(4, months, 1)));
	assert(equals(0, findIndex(5, months, 1)));
	assert(equals(0, findIndex(6, months, 1)));
	assert(equals(0, findIndex(7, months, 1)));
	assert(equals(0, findIndex(8, months, 1)));
	assert(equals(0, findIndex(9, months, 1)));
	assert(equals(0, findIndex(10, months, 1)));
	assert(equals(0, findIndex(11, months, 1)));
	assert(equals(0, findIndex(12, months, 1)));
}
/**
 * Construct an AVT by parsing the string, and either 
 * constructing a vector of AVTParts, or simply hold 
 * on to the string if the AVT is simple.
 */
AVT::AVT(
            StylesheetConstructionContext&  constructionContext,
            const LocatorType*              locator,
            const XalanDOMChar*             name,
            const XalanDOMChar*             stringedValue,
            const PrefixResolver&           resolver) :
        m_parts(0),
        m_partsSize(0),
        m_simpleString(0),
        m_simpleStringLength(0),
        m_name(constructionContext.getPooledString(name))
{
    StringTokenizer     tokenizer(stringedValue, theTokenDelimiterCharacters, true);

    const StringTokenizer::size_type    nTokens = tokenizer.countTokens();

    if(nTokens < 2)
    {
        // Do the simple thing
        m_simpleStringLength = length(stringedValue);

        m_simpleString = constructionContext.allocateXalanDOMCharVector(stringedValue, m_simpleStringLength, false);
    }
    else
    {
        // This over-allocates, but we probably won't waste that much space.  If necessary,
        // we could tokenize twice, just counting the numbers of AVTPart instances we
        // will need the first time.
        m_parts = constructionContext.allocateAVTPartPointerVector(nTokens + 1);

        XalanDOMString  buffer(constructionContext.getMemoryManager());
        XalanDOMString  exprBuffer(constructionContext.getMemoryManager());
        XalanDOMString  t(constructionContext.getMemoryManager()); // base token
        XalanDOMString  lookahead(constructionContext.getMemoryManager()); // next token

        while(tokenizer.hasMoreTokens())
        {
            if(length(lookahead))
            {
                t = lookahead;

                clear(lookahead);
            }
            else
            {
                nextToken(constructionContext, locator, tokenizer, t);
            }

            if(length(t) == 1)
            {
                const XalanDOMChar  theChar = charAt(t, 0);

                switch(theChar)
                {
                    case(XalanUnicode::charLeftCurlyBracket):
                    {
                        // Attribute Value Template start
                        nextToken(constructionContext, locator, tokenizer, lookahead);

                        if(equals(lookahead, theLeftCurlyBracketString))
                        {
                            // Double braces mean escape to show brace
                            append(buffer, lookahead);

                            clear(lookahead);

                            break; // from switch
                        }
                        else
                        {
                            if(length(buffer) > 0)
                            {
                                assert(m_partsSize + 1 < nTokens);

                                m_parts[m_partsSize++] =
                                    constructionContext.createAVTPart(
                                        c_wstr(buffer),
                                        length(buffer));

                                clear(buffer);
                            }
                                    
                            clear(exprBuffer);

                            while(length(lookahead) > 0 && !equals(lookahead, theRightCurlyBracketString))
                            {
                                if(length(lookahead) == 1)
                                {
                                    switch(charAt(lookahead, 0))
                                    {
                                        case XalanUnicode::charApostrophe:
                                        case XalanUnicode::charQuoteMark:
                                        {
                                            // String start
                                            append(exprBuffer, lookahead);

                                            const XalanDOMChar  quote[2] =
                                            {
                                                lookahead[0],
                                                0
                                            };

                                            // Consume stuff 'till next quote
                                            nextToken(constructionContext, locator, tokenizer, lookahead);

                                            while(!equals(lookahead, quote))
                                            {
                                                append(exprBuffer, lookahead);

                                                nextToken(constructionContext, locator, tokenizer, lookahead);
                                            }

                                            append(exprBuffer,lookahead);

                                            break;
                                        }

                                        case XalanUnicode::charLeftCurlyBracket:
                                            {
                                                GetCachedString     theGuard(constructionContext);

                                                // What's another brace doing here?
                                                constructionContext.error(
                                                    XalanMessageLoader::getMessage(
                                                        theGuard.get(),
                                                        XalanMessages::LeftBraceCannotAppearWithinExpression),
                                                    0,
                                                    locator);
                                                break;
                                            }

                                        default:
                                            // part of the template stuff, just add it.
                                            append(exprBuffer, lookahead);
                                            break;

                                    } // end inner switch
                                } // end if lookahead length == 1
                                else
                                {
                                    // part of the template stuff, just add it.
                                    append(exprBuffer,lookahead);
                                }

                                nextToken(constructionContext, locator, tokenizer, lookahead);
                            } // end while(!equals(lookahead, "}"))
                            assert(equals(lookahead, theRightCurlyBracketString));

                            // Proper close of attribute template. Evaluate the
                            // expression.
                            clear(buffer);

                            assert(m_partsSize + 1 < nTokens);

                            m_parts[m_partsSize++] =
                                constructionContext.createAVTPart(
                                    locator,
                                    c_wstr(exprBuffer),
                                    length(exprBuffer),
                                    resolver);

                            clear(lookahead); // breaks out of inner while loop
                        }
                        break;
                    }
                    case(XalanUnicode::charRightCurlyBracket):
                    {
                        nextToken(constructionContext, locator, tokenizer, lookahead);

                        if(equals(lookahead, theRightCurlyBracketString))
                        {
                            // Double brace mean escape to show brace
                            append(buffer, lookahead);

                            clear(lookahead); // swallow
                        }
                        else
                        {
                            GetCachedString     theGuard(constructionContext);

                            constructionContext.error(
                                XalanMessageLoader::getMessage(
                                    theGuard.get(),
                                    XalanMessages::UnmatchedWasFound),
                                0,
                                locator);

                        }
                        break;
                    }
                    default:
                    {
                        // Anything else just add to string.
                        append(buffer, theChar);
                    }
                } // end switch t
            } // end if length == 1
            else
            {
                // Anything else just add to string.
                append(buffer,t);
            }
        } // end while(tokenizer.hasMoreTokens())

        if(length(buffer) > 0)
        {
            assert(m_partsSize + 1 < nTokens);

            m_parts[m_partsSize++] = constructionContext.createAVTPart(c_wstr(buffer), length(buffer));

            clear(buffer);
        }
    } // end else nTokens > 1
}
Beispiel #5
0
bool SFVec3f::equals(float x, float y, float z) 
{
	SFVec3f vector(x, y, z);
	return equals(&vector);
}
ConditionResponse Condition::evaluateFeatures(Request* req){
	LOGD("[COND EVALUATE FEAT] 1 : %d",resource_attrs.size());
	map<string,vector<match_info_str*> >::iterator it;
	vector<match_info_str*> my_features = (it = resource_attrs.find(API_FEATURE))!=resource_attrs.end() 
			? it->second 
			: vector<match_info_str*>();
	
	map<string, vector<string>* > requestResource_attrs = req->getResourceAttrs();
	map<string, vector<string>* >::iterator rraIT = requestResource_attrs.find(API_FEATURE);
	vector<string>* req_features = (rraIT != requestResource_attrs.end())
			? rraIT->second
			: NULL;
	
	bool found;	
	bool anyUndetermined = resource_attrs.find(API_FEATURE)!= resource_attrs.end() 
			&& requestResource_attrs.find(API_FEATURE) == requestResource_attrs.end();	

	LOGD("Condition.evaluateFeatures - 03");
	if(combine == AND){
		LOGD("Condition.evaluateFeatures - 04");
		// find any No Match
		for(unsigned int j=0; req_features && j<my_features.size(); j++){
			found = false;
			for(unsigned int i=0; i<req_features->size(); i++){
				string mod_function = my_features[j]->mod_func;
				string s = (mod_function != "") 
							? modFunction(mod_function, req_features->at(i))
							: req_features->at(i);
				if(equals(s,my_features[j]->value, string2strcmp_mode(my_features[j]->equal_func)))
				{
					found = true;
					break;
				}
			}
			if (found == false)
				return NO_MATCH;
		}
		if (anyUndetermined)
			return NOT_DETERMINED;
		else
			return MATCH;
	}
	else if(combine == OR){
		LOGD("Condition.evaluateFeatures - 05");
		// find any Match
		for(unsigned int j=0; req_features && j<my_features.size(); j++){
			for(unsigned int i=0; i<req_features->size(); i++){
				string mod_function = my_features[j]->mod_func;
				string s = (mod_function != "") 
							? modFunction(mod_function, req_features->at(i))
							: req_features->at(i);
				if(equals(s,my_features[j]->value, string2strcmp_mode(my_features[j]->equal_func)))
					return MATCH;
			}
		}
		if (anyUndetermined)
			return NOT_DETERMINED;
		else
			return NO_MATCH;
	}
	// TODO: is that right? What should happen if policy is invalid?
	LOGD("Condition.evaluateFeatures - 09");
	return NOT_DETERMINED;
}
Beispiel #7
0
 inline bool equals( 
     const Range1T& Input, 
     const Range2T& Test)
 {
     return equals(Input, Test, is_equal());
 }
Beispiel #8
0
static inline bool
equals(const Angle a, const Angle b)
{
    return equals(a.Degrees(), b.Degrees());
}
Beispiel #9
0
static inline bool
equals(const GeoPoint a, const Angle lat, const Angle lon)
{
    return equals(a.latitude, lat) && equals(a.longitude, lon);
}
Beispiel #10
0
int main(int argc, char **argv)
{
  plan_tests(46);

  // test constructor
  GeoPoint p1(Angle::Degrees(fixed(345.32)), Angle::Degrees(fixed(-6.332)));
  ok1(equals(p1, -6.332, 345.32));

  // test normalize()
  p1.Normalize();
  ok1(equals(p1, -6.332, -14.68));

  // test parametric()
  GeoPoint p2(Angle::Degrees(fixed_two), Angle::Degrees(fixed_one));
  GeoPoint p3 = p1.Parametric(p2, fixed(5));
  ok1(equals(p3, -1.332, -4.68));

  // test interpolate
  GeoPoint p4 = p1.Interpolate(p3, fixed_half);
  ok1(equals(p4, -3.832, -9.68));

  GeoPoint p5 = p1.Interpolate(p3, fixed(0.25));
  ok1(equals(p5, -5.082, -12.18));

  // test *
  GeoPoint p6 = p2 * fixed(3.5);
  ok1(equals(p6, 3.5, 7));

  // test +
  p6 = p6 + p2;
  ok1(equals(p6, 4.5, 9));

  // test +=
  p6 += p2;
  ok1(equals(p6, 5.5, 11));

  // test -
  p6 = p6 - p2;
  ok1(equals(p6, 4.5, 9));

  // test sort()
  ok1(!p1.Sort(p3));
  ok1(p3.Sort(p1));
  ok1(!p1.Sort(p4));
  ok1(p4.Sort(p1));
  ok1(!p1.Sort(p5));
  ok1(p5.Sort(p1));
  ok1(!p4.Sort(p3));
  ok1(p3.Sort(p4));
  ok1(!p5.Sort(p3));
  ok1(p3.Sort(p5));
  ok1(!p5.Sort(p4));
  ok1(p4.Sort(p5));

  // test distance()
  //
  // note: distance between p1 and p4 and between p3 and p4 is not
  // the same due to linear interpolation instead of real geographic
  // intermediate point calculation
  ok1(equals(p2.Distance(p6), 869326.653160));
  ok1(equals(p6.Distance(p2), 869326.653160));
  ok1(equals(p1.Distance(p5), 309562.219016));
  ok1(equals(p1.Distance(p4), 619603.149273));
  ok1(equals(p1.Distance(p3), 1240649.267606));
  ok1(equals(p3.Distance(p4), 621053.760625));

  // test bearing()
  //
  // note: the bearings p1 -> p5, p5 -> p4 and so on are not the same due to
  // linear interpolation instead of real geographic intermediate point
  // calculation
  ok1(equals(p2.Bearing(p6), 63.272424));
  ok1(equals(p6.Bearing(p2), 243.608847));
  ok1(equals(p1.Bearing(p5), 63.449343));
  ok1(equals(p1.Bearing(p4), 63.582620));
  ok1(equals(p1.Bearing(p3), 63.784526));
  ok1(equals(p5.Bearing(p4), 63.466726));
  ok1(equals(p5.Bearing(p3), 63.646072));
  ok1(equals(p4.Bearing(p3), 63.540756));
  ok1(equals(p5.Bearing(p6), 65.982854));
  ok1(equals(p2.Bearing(p3), 250.786774));

  // test distance_bearing()
  // note: should be the same output as bearing() and distance()
  GeoVector v = p2.DistanceBearing(p6);
  ok1(equals(v.distance, 869326.653160));
  ok1(equals(v.bearing, 63.272424));

  // test intermediate_point()
  GeoPoint p7(Angle::Degrees(fixed_zero), Angle::Degrees(fixed_zero));
  GeoPoint p8 = p7.IntermediatePoint(p2, fixed(100000));
  ok1(equals(p8, 0.402274, 0.804342));
  ok1(equals(p8.Distance(p7), 100000));
  GeoPoint p9 = p7.IntermediatePoint(p2, fixed(100000000));
  ok1(equals(p9, p2));

  // test projected_distance()
  ok1(equals(p8.ProjectedDistance(p7, p2), 100000));
  ok1(equals(p4.ProjectedDistance(p1, p3), 619599.304393));
  ok1(equals((p2 * fixed_two).ProjectedDistance(p2, p6), 248567.832772));

  // Tests moved here from test_fixed.cpp
  GeoPoint l1(Angle::Zero(), Angle::Zero());
  GeoPoint l2(Angle::Degrees(fixed(-0.3)), Angle::Degrees(fixed(1.0)));
  GeoPoint l3(Angle::Degrees(fixed(0.00001)), Angle::Degrees(fixed_zero));
  GeoPoint l4(Angle::Degrees(fixed(10)), Angle::Degrees(fixed_zero));

  v = l1.DistanceBearing(l2);
  printf("Dist %g bearing %d\n",
         FIXED_DOUBLE(v.distance), FIXED_INT(v.bearing.Degrees()));
  // 116090 @ 343

  v = l1.DistanceBearing(l3);
  printf("Dist %g bearing %d\n",
         FIXED_DOUBLE(v.distance), FIXED_INT(v.bearing.Degrees()));
  ok(positive(v.distance) && v.distance < fixed_two, "earth distance short", 0);

  v = l1.DistanceBearing(l4);
  printf("Dist %g bearing %d\n",
         FIXED_DOUBLE(v.distance), FIXED_INT(v.bearing.Degrees()));

  return exit_status();
}
Beispiel #11
0
ConditionResponse Condition::evaluateEnvironment(Request* req){	
	vector<match_info_str*> my_environment_params;
	map<string, string> requestEnvironment_attrs = req->getEnvironmentAttrs();
	
	map<string,vector<match_info_str*> >::iterator it;
	match_info_str * my_roaming = (it = environment_attrs.find("roaming"))!=environment_attrs.end() 
		? it->second.at(0) 
		: NULL;
	
	vector<match_info_str *> my_bearer_vet = (it = environment_attrs.find("bearer-type"))!=environment_attrs.end() 
		? it->second 
		: vector<match_info_str*>();
	
	vector<match_info_str *> my_profile_vet = (it = environment_attrs.find("profile"))!=environment_attrs.end() 
		? it->second 
		: vector<match_info_str*>();
	
	if(combine == OR){
		LOGD("[ENVIRONMENT] dentro OR");
		if(my_roaming != NULL){
			string req_roaming = requestEnvironment_attrs["roaming"];
			LOGD("[ENVIRONMENT] req_roaming : %s",req_roaming.data());
			if(equals(req_roaming, my_roaming->value, string2strcmp_mode(my_roaming->equal_func)))
				return MATCH;
		}
		else
			LOGD("[ENVIRONMENT] my_roaming null");
		
		string req_bearer = requestEnvironment_attrs["bearer-type"];
		for(unsigned int j=0; j<my_bearer_vet.size(); j++){
			if(equals(req_bearer, my_bearer_vet[j]->value, string2strcmp_mode(my_bearer_vet[j]->equal_func)))
				return MATCH;
		}
		string req_profile = requestEnvironment_attrs["profile"];
		for(unsigned int j=0; j<my_profile_vet.size(); j++){
			if(equals(req_profile, my_profile_vet[j]->value, string2strcmp_mode(my_profile_vet[j]->equal_func)))
				return MATCH;
		}
		return NO_MATCH;
	}
	else{ //combine == AND
		// find any No Match
		LOGD("[ENVIRONMENT] dentro AND");
		if(my_roaming != NULL){
			string req_roaming = requestEnvironment_attrs["roaming"];
			LOGD("[ENVIRONMENT] confronto : %s con %s",req_roaming.data(),my_roaming->value.data());
			if(!equals(req_roaming, my_roaming->value, string2strcmp_mode(my_roaming->equal_func)))
				return NO_MATCH;
		}
		else
			LOGD("[ENVIRONMENT] my_roaming null");
		
		string req_bearer = requestEnvironment_attrs["bearer-type"];
		for(unsigned int j=0; j<my_bearer_vet.size(); j++){
			if(!equals(req_bearer, my_bearer_vet[j]->value, string2strcmp_mode(my_bearer_vet[j]->equal_func)))
				return NO_MATCH;
		}
		string req_profile = requestEnvironment_attrs["profile"];
		for(unsigned int j=0; j<my_profile_vet.size(); j++){
			if(!equals(req_profile, my_profile_vet[j]->value, string2strcmp_mode(my_profile_vet[j]->equal_func)))
				return NO_MATCH;
		}
		return MATCH;
	}
}
bool GMBoundingSphere::operator!=(const GMBoundingSphere& sphere) const
{
    return !equals(sphere, GMMath::kDoubleEqThreshold);
}
Beispiel #13
0
XALAN_CPP_NAMESPACE_BEGIN



ElemWithParam::ElemWithParam(
			StylesheetConstructionContext&	constructionContext,
			Stylesheet&						stylesheetTree,
			const AttributeListType&		atts,
			int								lineNumber,
			int								columnNumber) :
	ElemTemplateElement(constructionContext,
						stylesheetTree,
						lineNumber,
						columnNumber,
						StylesheetConstructionContext::ELEMNAME_WITH_PARAM),
	m_selectPattern(0),
	m_qname(0)
{
	const unsigned int	nAttrs = atts.getLength();

	for(unsigned int i = 0; i < nAttrs; i++)
	{
		const XalanDOMChar* const	aname = atts.getName(i);

		if(equals(aname, Constants::ATTRNAME_SELECT))
		{
			m_selectPattern = constructionContext.createXPath(getLocator(), atts.getValue(i), *this);
		}
		else if(equals(aname, Constants::ATTRNAME_NAME))
		{
			m_qname = constructionContext.createXalanQName(
						atts.getValue(i),
						stylesheetTree.getNamespaces(),
						getLocator());

			if (m_qname->isValid() == false)
			{
				constructionContext.error(
						XalanMessageLoader::getMessage(
							XalanMessages::AttributeValueNotValidQName_2Param,
							Constants::ATTRNAME_NAME.c_str(),
							atts.getValue(i)),
						0,
						this);
			}
		}
		else if(!isAttrOK(aname, atts, i, constructionContext))
		{
			constructionContext.error(
					XalanMessageLoader::getMessage(
						XalanMessages::TemplateHasIllegalAttribute_2Param,
						Constants::ELEMNAME_WITHPARAM_WITH_PREFIX_STRING.c_str(),
						aname),
					0,
					this);
		}
	}

	if(m_qname == 0)
	{
		constructionContext.error(
			XalanMessageLoader::getMessage(
				XalanMessages::TemplateMustHaveAttribute_2Param,
				Constants::ELEMNAME_WITHPARAM_WITH_PREFIX_STRING,
				Constants::ATTRNAME_NAME),
			0,
			this);
	}
}
Beispiel #14
0
/** Set up variable with value. In this case allow any amount of whitespace,
  * so re-tokenize the original argument line (minus the command).
  */
CpptrajState::RetType
  Control_Set::SetupControl(CpptrajState& State, ArgList& argIn, Varray& CurrentVars)
{
  ArgList remaining = argIn.RemainingArgs();
  size_t pos0 = remaining.ArgLineStr().find_first_of("=");
  if (pos0 == std::string::npos) {
    mprinterr("Error: Expected <var>=<value>\n");
    return CpptrajState::ERR;
  }
  size_t pos1 = pos0;
  bool append = false;
  if (pos0 > 0 && remaining.ArgLineStr()[pos0-1] == '+') {
    pos0--;
    append = true;
  }
  std::string variable = NoWhitespace( remaining.ArgLineStr().substr(0, pos0) );
  if (variable.empty()) {
    mprinterr("Error: No variable name.\n");
    return CpptrajState::ERR;
  }
  ArgList equals( NoLeadingWhitespace(remaining.ArgLineStr().substr(pos1+1)) );
  std::string value;
  if (equals.Contains("inmask")) {
    AtomMask mask( equals.GetStringKey("inmask") );
    Topology* top = State.DSL().GetTopByIndex( equals );
    if (top == 0) return CpptrajState::ERR;
    if (top->SetupIntegerMask( mask )) return CpptrajState::ERR;
    if (equals.hasKey("atoms"))
      value = integerToString( mask.Nselected() );
    else if (equals.hasKey("residues")) {
      int curRes = -1;
      int nres = 0;
      for (AtomMask::const_iterator at = mask.begin(); at != mask.end(); ++at) {
        int res = (*top)[*at].ResNum();
        if (res != curRes) {
          nres++;
          curRes = res;
        }
      }
      value = integerToString( nres );
    } else if (equals.hasKey("molecules")) {
      int curMol = -1;
      int nmol = 0;
      for (AtomMask::const_iterator at = mask.begin(); at != mask.end(); ++at) {
        int mol = (*top)[*at].MolNum();
        if (mol != curMol) {
          nmol++;
          curMol = mol;
        }
      }
      value = integerToString( nmol );
    } else {
      mprinterr("Error: Expected 'atoms', 'residues', or 'molecules'.\n");
      return CpptrajState::ERR;
    }
  } else if (equals.hasKey("trajinframes")) {
    value = integerToString(State.InputTrajList().MaxFrames());
  } else
    value = equals.ArgLineStr();
  if (append)
    CurrentVars.AppendVariable( "$" + variable, value );
  else
    CurrentVars.UpdateVariable( "$" + variable, value );
  mprintf("\tVariable '%s' set to '%s'\n", variable.c_str(), value.c_str());
  for (int iarg = 0; iarg < argIn.Nargs(); iarg++)
    argIn.MarkArg( iarg );
  return CpptrajState::OK;
}
int main(int argc, char** argv){
	//srand will force the random numbers to be always the same, so we can verify that our code works
	//normally we would want them to be different.
	srand(100);
	struct DataSet* setA;
	setA = allocDataSet();

	struct DataSet* setB;
	setB = allocDataSet();


	int i = 0;
	for(i = 0; i < 30; ++i){
		Byte element = rand() % 20;
		appendDataSet(setA, element);
		Byte event = rand() % 100;
		if(event < 30){
			//30% of chance of repeating the same number
			appendDataSet(setB, element);
		}
		else if(event < 65){
			//65% of chance of adding a different element
			//event should be a number between 0 and 99
			//make it between 0 and 49 included
			appendDataSet(setB, event % 50);
		}
		else{
			//C requires an else, even if it is empty,
			//this else does nothing, so setB could be smaller than setA
		}
	}
	//Data has been initialized, now lets test the other methods
	//Print
	printf("SET A IS:\n");
	printDataSet(setA);
	printf("SET B IS:\n");
	printDataSet(setB);

	//Union (notice that union is another C keyword),
	//actually what is does is like a struct,
	//but guarantees the block will be put right after the other
	//in this class you dont need to know it, but once more, if you want to learn
	struct DataSet* unionSet;
	unionSet = unionDataSet(setA, setB);

	printf("A UNION B:\n");
	printDataSet(unionSet);

	//Intersection
	struct DataSet* intersectionSet;
	intersectionSet = intersectionDataSet(setA, setB);

	printf("A INTERSECTION B:\n");
	printDataSet(intersectionSet);

	//Set difference
	struct DataSet* diffSet;
	diffSet = diffDataSet(setA, setB);

	printf("A DIFF B:\n");
	printDataSet(diffSet);

	//Subset Test
	struct DataSet* subsetTest;
	subsetTest = subset(unionSet, 3, 7);

	printf("ORIGINAL SET:\n");
	printDataSet(unionSet);

	printf("SUBSET:\n");
	printDataSet(subsetTest);
	printf("subsetTest %s a subset of unionSet\n", isSubset(subsetTest, unionSet) ? "IS" : "IS NOT");
	printf("unionSet %s a subset of subsetSet\n", isSubset(unionSet, subsetTest) ? "IS" : "IS NOT");

	struct DataSet* emptySet = allocDataSet();
	//no data added so it should be the nullSet
	printf("THE EMPTY SET LOOKS LIKE:\n");
	printDataSet(emptySet);
	printf("emptySet %s equal to the NULL set\n", isNull(emptySet) ? "IS" : "IS NOT");

	struct DataSet* reverseSet = allocDataSet();
	for(i = unionSet->length - 1; i >= 0; --i){
		appendDataSet(reverseSet, unionSet->data[i]);
	}
	printf("reverseSet %s equal unionSet\n", equals(unionSet, reverseSet) ? "IS" : "IS NOT");
	printf("reverseSet %s %u\n", contains(reverseSet, unionSet->data[0]) ? "CONTAINSS" : "DOES NOT CONTAIN", unionSet->data[0]);
	printDataSet(reverseSet);

	//Statistics:
	printf("ORGINAL SET FOR STATISTICS:\n");
	printDataSet(unionSet);
	printf("Min value %u\n", unionSet->min);
	printf("Max value %u\n", unionSet->max);
	printf("Avg value %f\n", AverageDataSet(unionSet));
	printf("Range value %u\n", RangeDataSet(unionSet));

	//Release the DataSets resources after finish their usage.
	releaseDataSet(setA);
	releaseDataSet(setB);

	return 0;
}
Beispiel #16
0
static inline bool
equals(const GeoPoint a, const GeoPoint b)
{
    return equals(a.latitude, b.latitude) && equals(a.longitude, b.longitude);
}
Beispiel #17
0
 bool operator !=(const_pointer value) const {
   return !equals(value);
 }
Beispiel #18
0
static inline bool
equals(const fixed a, int b)
{
    return equals(a, fixed(b));
}
ConditionResponse Condition::evaluateCapabilities(Request* req){
	LOGD("condition: device-cap size %d",req->getResourceAttrs()["device-cap"]->size());
	vector<match_info_str*> my_capabilities_params;
	vector<string>* req_capabilities_params = new vector<string>();
	map<string, vector<string>* > requestResource_attrs = req->getResourceAttrs();
	bool anyUndetermined = false;
	bool found;
	
	for(map<string, vector<match_info_str*> >::iterator it = resource_attrs.begin(); it!= resource_attrs.end(); it++)
	{
		if (it->first != API_FEATURE)

		{
			if(requestResource_attrs.find(it->first) == requestResource_attrs.end())
			{
				LOGD("Capabilities %s undetermined ",it->first.data());		
				anyUndetermined = true;
			}
			else
			{
				LOGD("Capabilities %s determined ",it->first.data());	
				my_capabilities_params.insert(my_capabilities_params.end(), it->second.begin(), it->second.end());
			}
		}
	}
	LOGD("[ANY CAP] %d", anyUndetermined);

	for(map<string, vector<string>* >::iterator itr = requestResource_attrs.begin(); itr!= requestResource_attrs.end(); itr++)
	{
		if (itr->first != API_FEATURE)
		{
//			LOGD("REQ Capabilities %s", itr->first.data());
//			LOGD("REQ Capabilities size %d", itr->second->size());
			req_capabilities_params->insert(req_capabilities_params->end(), itr->second->begin(), itr->second->end());
		}
	}
	
	if(combine == AND){
		// find any No Match
		LOGD("my_capabilities_params.size() %d",my_capabilities_params.size());
		for(unsigned int j=0; j<my_capabilities_params.size(); j++){
			found = false;
			LOGD("req_capabilities_params->size() %d",req_capabilities_params->size());
			for(unsigned int i=0; i<req_capabilities_params->size(); i++){
				string mod_function = my_capabilities_params[j]->mod_func;
				string s = (mod_function != "") 
							? modFunction(mod_function, req_capabilities_params->at(i))
							: req_capabilities_params->at(i);
				
				LOGD("Confronto %s con %s",s.data(),my_capabilities_params[j]->value.data());
				if(equals(s.data(),my_capabilities_params[j]->value.data(), string2strcmp_mode(my_capabilities_params[j]->equal_func)))
//				if(equals(req_capabilities_params->at(i).data(),my_capabilities_params[j]->value.data(), string2strcmp_mode(my_capabilities_params[j]->equal_func)))
				{
					LOGD("UGUALI");
					found = true;
					break;
				}
				else
					LOGD("DIVERSI");
			}
			if (found == false)
				return NO_MATCH;
		}
		if (anyUndetermined)
			return NOT_DETERMINED;
		else
			return MATCH;
	}
	else if(combine == OR){
	// find any Match
		for(unsigned int j=0; j<my_capabilities_params.size(); j++){
			for(unsigned int i=0; i<req_capabilities_params->size(); i++){
				string mod_function = my_capabilities_params[j]->mod_func;
				string s = (mod_function != "") 
							? modFunction(mod_function, req_capabilities_params->at(i))
							: req_capabilities_params->at(i);
				
				LOGD("Compare %s with %s",s.data(),my_capabilities_params[j]->value.data());
//				LOGD("Compare %s with %s",req_capabilities_params->at(i).data(),my_capabilities_params[j]->value.data());
				if(equals(s.data(),my_capabilities_params[j]->value.data(), string2strcmp_mode(my_capabilities_params[j]->equal_func))){
//				if(equals(req_capabilities_params->at(i),my_capabilities_params[j]->value, string2strcmp_mode(my_capabilities_params[j]->equal_func)))
					return MATCH;
				}
			}
		}
		if (anyUndetermined)
			return NOT_DETERMINED;
		else
			return NO_MATCH;
	}
	// TODO: is that right? What should happen if policy invalid?
	return NOT_DETERMINED;
}
Beispiel #20
0
static inline bool
equals(const Angle a, int b)
{
    return equals(a.Degrees(), fixed(b));
}
Beispiel #21
0
void
multiplot_start()
{
    TBOOLEAN set_spacing = FALSE;
    TBOOLEAN set_margins = FALSE;

    c_token++;

    /* Only a few options are possible if we are already in multiplot mode */
    /* So far we have "next".  Maybe also "previous", "clear"? */
    if (multiplot) {
	if (equals(c_token, "next")) {
	    c_token++;
	    if (!mp_layout.auto_layout)
		int_error(c_token, "only valid inside an auto-layout multiplot");
	    multiplot_next();
	    return;
	} else if (almost_equals(c_token, "prev$ious")) {
	    c_token++;
	    if (!mp_layout.auto_layout)
		int_error(c_token, "only valid inside an auto-layout multiplot");
	    multiplot_previous();
	    return;
	} else {
	    term_end_multiplot();
	}
    }

    /* FIXME: more options should be reset/initialized each time */
    mp_layout.auto_layout = FALSE;
    mp_layout.auto_layout_margins = FALSE;
    mp_layout.current_panel = 0;
    mp_layout.title.noenhanced = FALSE;
    free(mp_layout.title.text);
    mp_layout.title.text = NULL;
    free(mp_layout.title.font);
    mp_layout.title.font = NULL;
    mp_layout.title.boxed = 0;

    /* Parse options */
    while (!END_OF_COMMAND) {

	if (almost_equals(c_token, "ti$tle")) {
	    c_token++;
	    mp_layout.title.text = try_to_get_string();
 	    continue;
       }

       if (equals(c_token, "font")) {
	    c_token++;
	    mp_layout.title.font = try_to_get_string();
	    continue;
	}

        if (almost_equals(c_token,"enh$anced")) {
            mp_layout.title.noenhanced = FALSE;
            c_token++;
            continue;
        }

        if (almost_equals(c_token,"noenh$anced")) {
            mp_layout.title.noenhanced = TRUE;
            c_token++;
            continue;
        }
        
	if (equals(c_token,"boxed")) {
            mp_layout.title.boxed = 1;
            c_token++;
            continue;
        }

	if (almost_equals(c_token, "lay$out")) {
	    if (mp_layout.auto_layout)
		int_error(c_token, "too many layout commands");
	    else
		mp_layout.auto_layout = TRUE;

	    c_token++;
	    if (END_OF_COMMAND) {
		int_error(c_token,"expecting '<num_cols>,<num_rows>'");
	    }

	    /* read row,col */
	    mp_layout.num_rows = int_expression();
	    if (END_OF_COMMAND || !equals(c_token,",") )
		int_error(c_token, "expecting ', <num_cols>'");

	    c_token++;
	    if (END_OF_COMMAND)
		int_error(c_token, "expecting <num_cols>");
	    mp_layout.num_cols = int_expression();

	    /* remember current values of the plot size and the margins */
	    mp_layout.prev_xsize = xsize;
	    mp_layout.prev_ysize = ysize;
	    mp_layout.prev_xoffset = xoffset;
	    mp_layout.prev_yoffset = yoffset;
	    mp_layout.prev_lmargin = lmargin;
	    mp_layout.prev_rmargin = rmargin;
	    mp_layout.prev_bmargin = bmargin;
	    mp_layout.prev_tmargin = tmargin;

	    mp_layout.act_row = 0;
	    mp_layout.act_col = 0;

	    continue;
	}

	/* The remaining options are only valid for auto-layout mode */
	if (!mp_layout.auto_layout)
	    int_error(c_token, "only valid in the context of an auto-layout command");

	switch(lookup_table(&set_multiplot_tbl[0],c_token)) {
	    case S_MULTIPLOT_COLUMNSFIRST:
		mp_layout.row_major = TRUE;
		c_token++;
		break;
	    case S_MULTIPLOT_ROWSFIRST:
		mp_layout.row_major = FALSE;
		c_token++;
		break;
	    case S_MULTIPLOT_DOWNWARDS:
		mp_layout.downwards = TRUE;
		c_token++;
		break;
	    case S_MULTIPLOT_UPWARDS:
		mp_layout.downwards = FALSE;
		c_token++;
		break;
	    case S_MULTIPLOT_SCALE:
		c_token++;
		mp_layout.xscale = real_expression();
		mp_layout.yscale = mp_layout.xscale;
		if (!END_OF_COMMAND && equals(c_token,",") ) {
		    c_token++;
		    if (END_OF_COMMAND) {
			int_error(c_token, "expecting <yscale>");
		    }
		    mp_layout.yscale = real_expression();
		}
		break;
	    case S_MULTIPLOT_OFFSET:
		c_token++;
		mp_layout.xoffset = real_expression();
		mp_layout.yoffset = mp_layout.xoffset;
		if (!END_OF_COMMAND && equals(c_token,",") ) {
		    c_token++;
		    if (END_OF_COMMAND) {
			int_error(c_token, "expecting <yoffset>");
		    }
		    mp_layout.yoffset = real_expression();
		}
		break;
	    case S_MULTIPLOT_MARGINS:
		c_token++;
		if (END_OF_COMMAND)
		    int_error(c_token,"expecting '<left>,<right>,<bottom>,<top>'");
		
		mp_layout.lmargin.scalex = screen;
		mp_layout_set_margin_or_spacing(&(mp_layout.lmargin));
		if (!END_OF_COMMAND && equals(c_token,",") ) {
		    c_token++;
		    if (END_OF_COMMAND)
			int_error(c_token, "expecting <right>");

		    mp_layout.rmargin.scalex = mp_layout.lmargin.scalex;
		    mp_layout_set_margin_or_spacing(&(mp_layout.rmargin));
		} else {
		    int_error(c_token, "expecting <right>");
		}
		if (!END_OF_COMMAND && equals(c_token,",") ) {
		    c_token++;
		    if (END_OF_COMMAND)
			int_error(c_token, "expecting <top>");

		    mp_layout.bmargin.scalex = mp_layout.rmargin.scalex;
		    mp_layout_set_margin_or_spacing(&(mp_layout.bmargin));
		} else {
		    int_error(c_token, "expecting <bottom>");
		}
		if (!END_OF_COMMAND && equals(c_token,",") ) {
		    c_token++;
		    if (END_OF_COMMAND)
			int_error(c_token, "expecting <bottom>");

		    mp_layout.tmargin.scalex = mp_layout.bmargin.scalex;
		    mp_layout_set_margin_or_spacing(&(mp_layout.tmargin));
		} else {
		    int_error(c_token, "expection <top>");
		}
		set_margins = TRUE;
		break;
	    case S_MULTIPLOT_SPACING:
		c_token++;
		if (END_OF_COMMAND)
		    int_error(c_token,"expecting '<xspacing>,<yspacing>'");
		mp_layout.xspacing.scalex = screen;
		mp_layout_set_margin_or_spacing(&(mp_layout.xspacing));
		mp_layout.yspacing = mp_layout.xspacing;

		if (!END_OF_COMMAND && equals(c_token, ",")) {
		    c_token++;
		    if (END_OF_COMMAND)
			int_error(c_token, "expecting <yspacing>");
		    mp_layout_set_margin_or_spacing(&(mp_layout.yspacing));
		}
		set_spacing = TRUE;
		break;
	    default:
		int_error(c_token,"invalid or duplicate option");
		break;
	}
    }

    if (set_spacing || set_margins) {
	if (set_spacing && set_margins) {
	    if (mp_layout.lmargin.x >= 0 && mp_layout.rmargin.x >= 0 
	    &&  mp_layout.tmargin.x >= 0 && mp_layout.bmargin.x >= 0 
	    &&  mp_layout.xspacing.x >= 0 && mp_layout.yspacing.x >= 0)
		mp_layout.auto_layout_margins = TRUE;
	    else
		int_error(NO_CARET, "must give positive margin and spacing values");
	} else if (set_margins) {
	    mp_layout.auto_layout_margins = TRUE;
	    mp_layout.xspacing.scalex = screen;
	    mp_layout.xspacing.x = 0.05;
	    mp_layout.yspacing.scalex = screen;
	    mp_layout.yspacing.x = 0.05;
	}
	/* Sanity check that screen tmargin is > screen bmargin */
	if (mp_layout.bmargin.scalex == screen && mp_layout.tmargin.scalex == screen)
	    if (mp_layout.bmargin.x > mp_layout.tmargin.x) {
		double tmp = mp_layout.bmargin.x;
		mp_layout.bmargin.x = mp_layout.tmargin.x;
		mp_layout.tmargin.x = tmp;
	    }
    }

    /* If we reach here, then the command has been successfully parsed.
     * Aug 2013: call term_start_plot() before setting multiplot so that
     * the wxt and qt terminals will reset the plot count to 0 before
     * ignoring subsequent TERM_LAYER_RESET requests. 
     */
    term_start_plot();
    multiplot = TRUE;
    fill_gpval_integer("GPVAL_MULTIPLOT", 1);

    /* Place overall title before doing anything else */
    if (mp_layout.title.text) {
	unsigned int x, y;
	char *p = mp_layout.title.text;

	x = term->xmax  / 2;
	y = term->ymax - term->v_char;

	write_label(x, y, &(mp_layout.title));
	reset_textcolor(&(mp_layout.title.textcolor));

	/* Calculate fractional height of title compared to entire page */
	/* If it would fill the whole page, forget it! */
	for (y=1; *p; p++)
	    if (*p == '\n')
		y++;

	/* Oct 2012 - v_char depends on the font used */
	if (mp_layout.title.font && *mp_layout.title.font)
	    term->set_font(mp_layout.title.font);
	mp_layout.title_height = (double)(y * term->v_char) / (double)term->ymax;
	if (mp_layout.title.font && *mp_layout.title.font)
	    term->set_font("");

	if (mp_layout.title_height > 0.9)
	    mp_layout.title_height = 0.05;
    } else {
	mp_layout.title_height = 0.0;
    }

    if (mp_layout.auto_layout_margins)
	mp_layout_margins_and_spacing();
    else
	mp_layout_size_and_offset();
}
int main(void) {
    std::unordered_map<int, std::unordered_map<int, cv::Mat1f>> map;

    map[2][1] = cv::Mat1f::ones(1, 1);
    map[3][1] = cv::Mat1f::ones(1, 1);
    map[3][1] *= 2;
    map[4][3] = cv::Mat1f::ones(1, 1);
    map[5][3] *= 4;
    map[7][4] = cv::Mat1f::ones(1, 1);
    map[3][7] = cv::Mat1f::ones(1, 1);

    std::cout << "before:" << std::endl;

    for(int r = 0; r < 8; ++r) {
        for(int c = 0; c < 8; ++c) {
            if(map[r][c].empty()) {
                std::cout << cv::Mat1f::zeros(1, 1);
            } else {
                std::cout << map[r][c];
            }
        }
        std::cout << std::endl;
    }

    if(map[0][0].empty()) {
        map[0][0] = cv::Mat1f::zeros(1, 1);
    }

    cv::Mat_<cv::Mat1f*> mapping(8, 8);
    mapping.at<cv::Mat1f*>(0, 0) = &map[0][0];

    for(int r = 1; r < 8; ++r) {
        cv::Mat1f lastElement = *(mapping.at<cv::Mat1f*>(r - 1, 0));
        if(!map[r][0].empty()) {
            map[r][0] += lastElement;
            mapping.at<cv::Mat1f*>(r, 0) = &map[r][0];
        } else {
            mapping.at<cv::Mat1f*>(r, 0) = mapping.at<cv::Mat1f*>(r - 1, 0);
        }
    }

    for(int c = 1; c < 8; ++c) {
        cv::Mat1f lastElement = *(mapping.at<cv::Mat1f*>(0, c - 1));
        if(!map[0][c].empty()) {
            map[0][c] += lastElement;
            mapping.at<cv::Mat1f*>(0, c) = &map[0][c];
        } else {
            mapping.at<cv::Mat1f*>(0, c) = mapping.at<cv::Mat1f*>(0, c - 1);
        }
    }

    for(int r = 1; r < 8; ++r) {
        for(int c = 1; c < 8; ++c) {
            cv::Mat1f lastLeft = *(mapping.at<cv::Mat1f*>(r, c - 1));
            cv::Mat1f lastTop = *(mapping.at<cv::Mat1f*>(r - 1, c));
            cv::Mat1f lastTopLeft = *(mapping.at<cv::Mat1f*>(r - 1, c - 1));

            cv::Mat1f tmp;

            if(!map[r][c].empty()) {
                tmp = map[r][c] + lastLeft + lastTop - lastTopLeft;
            } else {
                tmp = lastLeft + lastTop - lastTopLeft;
            }

            cv::Scalar s = cv::sum(tmp - lastLeft);

            if(equals(tmp, lastLeft)) {
                mapping.at<cv::Mat1f*>(r, c) = mapping.at<cv::Mat1f*>(r, c - 1);
            } else {
                if(equals(tmp, lastTop)) {
                    std::cout << "Value changed, top entry equal" << std::endl;
                    mapping.at<cv::Mat1f*>(r, c) = mapping.at<cv::Mat1f*>(r - 1, c);
                } else {
                    std::cout << "Value changed, new value" << std::endl;
                    map[r][c] = tmp;
                    mapping.at<cv::Mat1f*>(r, c) = &map[r][c];
                }
            }
        }
    }

    std::cout << "after:" << std::endl;

    for(int r = 0; r < 8; ++r) {
        for(int c = 0; c < 8; ++c) {
            if(map[r][c].empty()) {
                std::cout << cv::Mat1f::zeros(1, 1);
            } else {
                std::cout << map[r][c];
            }
        }
        std::cout << std::endl;
    }

    std::cout << "mapping:" << std::endl;
    for(int y = 0; y < mapping.rows; ++y) {
        for(int x = 0; x < mapping.cols; ++x) {
            std::cout << "(" << mapping.at<cv::Mat1f*>(y, x) << "," << mapping.at<cv::Mat1f*>(y, x) << ")";
        }
        std::cout << std::endl;
    }
    
    std::cout << "result:" << std::endl;
    for(int y = 0; y < mapping.rows; ++y) {
        for(int x = 0; x < mapping.cols; ++x) {
            std::cout << *mapping.at<cv::Mat1f*>(y, x);
        }
        std::cout << std::endl;
    }

    cv::Mat1f result;
    result = (*mapping.at<cv::Mat1f*>(4, 4) - *mapping.at<cv::Mat1f*>(0, 4) - *mapping.at<cv::Mat1f*>(4, 0) + *mapping.at<cv::Mat1f*>(0, 0));

    std::cout << result << std::endl;

    return 0;
}
Beispiel #23
0
bool SFVec3f::equals(float value[3]) 
{
	SFVec3f vector(value);
	return equals(&vector);
}
Beispiel #24
0
/**
 * Callback function for reading of config.txt
 */
static void kitConfig(char* pName, const void* pValue, DWORD a)
{
    kattr_data* kd = (kattr_data*)a;
    if (!kd) return;

    switch (kd->attr)
    {
        case ATT_MODEL:
            kd->kit.model = *(DWORD*)pValue;
            kd->kit.attDefined |= MODEL;
            GDB_DEBUG(wlog,(slog,L"model = %d\n",kd->kit.model));
            break;

        case ATT_COLLAR:
            kd->kit.collar = *(DWORD*)pValue;
            kd->kit.attDefined |= COLLAR;
            GDB_DEBUG(wlog,(slog,L"collar = %d\n",kd->kit.collar));
            break;

        case ATT_SHIRT_NUMBER_LOCATION:
            if (equals(pValue, L"off"))
                kd->kit.shirtNumberLocation = 0;
            else if (equals(pValue, L"center"))
                kd->kit.shirtNumberLocation = 1;
            else if (equals(pValue, L"topright"))
                kd->kit.shirtNumberLocation = 2;
            kd->kit.attDefined |= SHIRT_NUMBER_LOCATION;
            GDB_DEBUG(wlog,(slog,L"shirtNumberLocation = %d\n",kd->kit.shirtNumberLocation));
            break;

        case ATT_SHORTS_NUMBER_LOCATION:
            if (equals(pValue,L"off"))
                kd->kit.shortsNumberLocation = 0;
            else if (equals(pValue,L"left"))
                kd->kit.shortsNumberLocation = 1;
            else if (equals(pValue,L"right"))
                kd->kit.shortsNumberLocation = 2;
            kd->kit.attDefined |= SHORTS_NUMBER_LOCATION;
            GDB_DEBUG(wlog,(slog,L"shortsNumberLocation = %d\n",kd->kit.shortsNumberLocation));
            break;

        case ATT_NAME_LOCATION:
            if (equals(pValue, L"off"))
                kd->kit.nameLocation = 0;
            else if (equals(pValue, L"top"))
                kd->kit.nameLocation = 1;
            else if (equals(pValue, L"bottom"))
                kd->kit.nameLocation = 2;
            kd->kit.attDefined |= NAME_LOCATION;
            GDB_DEBUG(wlog,(slog,L"nameLocation = %d\n",kd->kit.nameLocation));
            break;

        case ATT_NAME_SHAPE:
            if (equals(pValue, L"type1"))
                kd->kit.nameShape = 0;
            else if (equals(pValue, L"type2"))
                kd->kit.nameShape = 1;
            else if (equals(pValue, L"type3"))
                kd->kit.nameShape = 2;
            else if (equals(pValue, L"type4"))
                kd->kit.nameShape = 3;
            kd->kit.attDefined |= NAME_SHAPE;
            GDB_DEBUG(wlog,(slog,L"nameShape = %d\n",kd->kit.nameShape));
            break;

        case ATT_LOGO_LOCATION:
            if (equals(pValue, L"off"))
                kd->kit.logoLocation = 0;
            else if (equals(pValue, L"top"))
                kd->kit.logoLocation = 1;
            else if (equals(pValue, L"bottom"))
                kd->kit.logoLocation = 2;
            kd->kit.attDefined |= LOGO_LOCATION;
            GDB_DEBUG(wlog,(slog,L"logoLocation = %d\n",kd->kit.logoLocation));
            break;

        case ATT_MAIN_COLOR:
            if (ParseColor((wchar_t*)pValue, &kd->kit.mainColor))
                kd->kit.attDefined |= MAIN_COLOR;
            GDB_DEBUG(wlog,(slog,L"mainColor = %02x%02x%02x%02x\n",
                        kd->kit.mainColor.r,
                        kd->kit.mainColor.g,
                        kd->kit.mainColor.b,
                        kd->kit.mainColor.a
                        ));
            break;

        case ATT_SHORTS_COLOR:
            if (ParseColor((wchar_t*)pValue, &kd->kit.shortsFirstColor))
                kd->kit.attDefined |= SHORTS_MAIN_COLOR;
            GDB_DEBUG(wlog,(slog,L"shortsFirstColor = %02x%02x%02x%02x\n",
                        kd->kit.shortsFirstColor.r,
                        kd->kit.shortsFirstColor.g,
                        kd->kit.shortsFirstColor.b,
                        kd->kit.shortsFirstColor.a
                        ));
            break;

        case ATT_DESCRIPTION:
            kd->kit.description = (wchar_t*)pValue;
            GDB_DEBUG(wlog,(slog,L"description = {%s}\n",kd->kit.description));
            break;
    }
}
Beispiel #25
0
static size_t
gl_carray_indexof_from_to (gl_list_t list, size_t start_index, size_t end_index,
                           const void *elt)
{
  size_t count = list->count;

  if (!(start_index <= end_index && end_index <= count))
    /* Invalid arguments.  */
    abort ();

  if (start_index < end_index)
    {
      gl_listelement_equals_fn equals = list->base.equals_fn;
      size_t allocated = list->allocated;
      size_t i_end;

      i_end = list->offset + end_index;
      if (i_end >= allocated)
        i_end -= allocated;

      if (equals != NULL)
        {
          size_t i;

          i = list->offset + start_index;
          if (i >= allocated) /* can only happen if start_index > 0 */
            i -= allocated;

          for (;;)
            {
              if (equals (elt, list->elements[i]))
                return (i >= list->offset ? i : i + allocated) - list->offset;
              i++;
              if (i == allocated)
                i = 0;
              if (i == i_end)
                break;
            }
        }
      else
        {
          size_t i;

          i = list->offset + start_index;
          if (i >= allocated) /* can only happen if start_index > 0 */
            i -= allocated;

          for (;;)
            {
              if (elt == list->elements[i])
                return (i >= list->offset ? i : i + allocated) - list->offset;
              i++;
              if (i == allocated)
                i = 0;
              if (i == i_end)
                break;
            }
        }
    }
  return (size_t)(-1);
}
Beispiel #26
0
bool String::operator !=(const String &x) const {
	return !equals(x);
}
Beispiel #27
0
bool URI::operator != (const std::string& uri) const
{
	URI parsedURI(uri);
	return !equals(parsedURI);
}
Beispiel #28
0
bool String::operator !=(const char *x) const {
	assert(x != 0);
	return !equals(x);
}
Beispiel #29
0
static void testFindIndexForAllMonths() {
	const int months[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};
	
	assert(equals(0, findIndex(1, months, 12)));
	assert(equals(1, findIndex(2, months, 12)));
	assert(equals(2, findIndex(3, months, 12)));
	assert(equals(3, findIndex(4, months, 12)));
	assert(equals(4, findIndex(5, months, 12)));
	assert(equals(5, findIndex(6, months, 12)));
	assert(equals(6, findIndex(7, months, 12)));
	assert(equals(7, findIndex(8, months, 12)));
	assert(equals(8, findIndex(9, months, 12)));
	assert(equals(9, findIndex(10, months, 12)));
	assert(equals(10, findIndex(11, months, 12)));
	assert(equals(11, findIndex(12, months, 12)));
}
Beispiel #30
0
bool GMVector3D::operator!=(const GMVector3D& vec) const
{
    return !equals(vec, GMMathHelper::DoubleEqThreshold);
}