예제 #1
0
파일: node.cpp 프로젝트: halbbob/dff
void	Node::attributesNamesAndTypesFromVariant(Variant* variant, std::map<std::string, uint8_t> *namestypes, std::string current)
{
  if (!(variant))
    return ;
  if (variant->type() == typeId::List)
    {
      std::list<Variant*> lvariant = variant->value<std::list< Variant*> >();
      std::list<Variant*>::iterator it = lvariant.begin();
      for (; it != lvariant.end(); it++)
	this->attributesNamesAndTypesFromVariant((*it), namestypes, current);
    }
  else if (variant->type() == typeId::Map)
    {
      Attributes mvariant = variant->value<Attributes >();
      Attributes::iterator it = mvariant.begin();
      std::string	abs;
      for (; it != mvariant.end(); it++)
	{
	  if (current.empty())
	    abs = it->first;
	  else
	    abs = current + '.' + it->first;
	  namestypes->insert(std::pair<std::string, uint8_t>(abs, it->second->type()));
	  this->attributesNamesAndTypesFromVariant(it->second, namestypes, abs);
	}
    }  
}
예제 #2
0
파일: node.cpp 프로젝트: halbbob/dff
void 	Node::attributesByTypeFromVariant(Variant* variant, uint8_t type, Attributes* result)
{
  Variant*	vptr;

  if (!(variant))
    return ;
  if (variant->type() == typeId::List)
    {
      std::list<Variant*> lvariant = variant->value<std::list< Variant*> >();
      std::list<Variant*>::iterator it = lvariant.begin();
      for (; it != lvariant.end(); it++)
	this->attributesByTypeFromVariant((*it), type, result); 
    }
  else if (variant->type() == typeId::Map)
    {
      Attributes mvariant = variant->value<Attributes >();
      Attributes::iterator it = mvariant.begin();
      for (; it != mvariant.end(); it++)
	{
	  if (it->second->type() == type)
	    {
	      if (result->find(it->first) == result->end())
		{
		  vptr = new Variant(it->second);
		  result->insert(std::pair<std::string, Variant*>(it->first, vptr));
		}
	      else
		;//XXX, we have to find a way to manage same attributes naming at different level. At the moment, this condition is to avoid memleak
	    }
	  else
	    this->attributesByTypeFromVariant(it->second, type, result);
	}
    }
}
예제 #3
0
파일: node.cpp 프로젝트: halbbob/dff
void 	Node::attributesByTypeFromVariant(Variant* variant, uint8_t type, Attributes* result, std::string current)
{
  if (!(variant))
    return ;
  if (variant->type() == typeId::List)
    {
      std::list<Variant*> lvariant = variant->value<std::list< Variant*> >();
      std::list<Variant*>::iterator it = lvariant.begin();
      for (; it != lvariant.end(); it++)
	this->attributesByTypeFromVariant((*it), type, result, current);
    }
  else if (variant->type() == typeId::Map)
    {
      Attributes mvariant = variant->value<Attributes >();
      Attributes::iterator it = mvariant.begin();
      std::string	abs;
      for (; it != mvariant.end(); it++)
	{
	  if (current.empty())
	    abs = (*it).first;
	  else
	    abs = current + '.' + (*it).first;
	  if (it->second->type() == type)
	    result->insert(std::pair<std::string, Variant*>(abs, new Variant(it->second)));
	  else
	    this->attributesByTypeFromVariant(it->second, type, result, abs);
	}
    }
}
예제 #4
0
bool AgentObserverMap::draw()
{
    QList<Attributes *> attribList = getMapAttributes()->values();
    Attributes *attrib = 0;

    qStableSort(attribList.begin(), attribList.end(), sortAttribByType);

    for(int i = 0; i < attribList.size(); i++)
    {
        attrib = attribList.at(i);
        if ( (attrib->getType() != TObsCell)
              && (attrib->getType() != TObsAgent) )
            getPainterWidget()->plotMap(attrib);
    }

    //static int ss = 1;
    //for(int i = 0; i < attribList.size(); i++)
    //{
    //    //attrib = attribList.at(i);
    //    //if ( (attrib->getType() != TObsCell)
    //    //       && (attrib->getType() != TObsAgent) )
    //    //       attrib->getImage()->save("imgs/" + attrib->getName() + QString::number(ss) + ".png");

    //    qDebug() << attrib->getName() << ": " << getSubjectName(attrib->getType());
    //}

    //ss++;
    return true;
}
short BaseColumn::codeGen(Generator * generator)
{
  // if this column has not been added to the map table or
  // it does not have a valid offset, and
  // it has an EIC list, then add it to the map table and
  // assign attributes from the one of the EIC values.
  MapInfo * mapInfo = generator->getMapInfoAsIs(getValueId());
  if ((!mapInfo ||
       !mapInfo->isOffsetAssigned()) &&
      (!getEIC().isEmpty()))
    {
      MapInfo * index_col_map_info;
      short done = 0;
      for (ValueId val_id = getEIC().init();
	   !done && getEIC().next(val_id);
	   getEIC().advance(val_id))
	{
	  if (index_col_map_info = generator->getMapInfoAsIs(val_id))
	    {
	      Attributes * attr = 
		generator->addMapInfo(getValueId(), 0)->getAttr();
	      attr->copyLocationAttrs(index_col_map_info->getAttr());
	      done = -1;
	    }
	}
    }
      
  return 0;
}
예제 #6
0
SAXParser::Handler::Status HandlerPeak::startElement(const string& name, 
                                const Attributes& attributes,
                                stream_offset position)
{
    if (!peak)
        throw runtime_error("[PeakData::HandlerPeak::startElement()]  Null peak.");

    if (name == "peak")
    {
        for (Attributes::attribute_list::const_iterator it=attributes.begin(); it!=attributes.end(); ++it)
        {
            if (it->matchName("id")) peak->id = lexical_cast<int>(it->getValue());
            else if (it->matchName("mz")) peak->mz = lexical_cast<double>(it->getValue(NoXMLUnescape)); 
            else if (it->matchName("retentionTime")) peak->retentionTime = lexical_cast<double>(it->getValue(NoXMLUnescape));
            else if (it->matchName("intensity")) peak->intensity = lexical_cast<double>(it->getValue(NoXMLUnescape));
            else if (it->matchName("area")) peak->area = lexical_cast<double>(it->getValue(NoXMLUnescape));
            else if (it->matchName("error")) peak->error = lexical_cast<double>(it->getValue(NoXMLUnescape));
            else
            {
                Peak::Attribute a = stringToAttribute(it->getName());
                peak->attributes[a] = lexical_cast<double>(it->getValue(NoXMLUnescape)); 
            }
        }

        return Status::Ok;
    }
    else if (name == "data")
    {
        return Status::Ok;
    }

    throw runtime_error(("[HandlerPeak] Unexpected element name: " + name).c_str());
}
예제 #7
0
Context *
createContext(const Visual *_visual, Context *shareContext, Profile profile)
{
    const GlxVisual *visual = static_cast<const GlxVisual *>(_visual);
    GLXContext share_context = NULL;
    GLXContext context;

    if (profile != PROFILE_COMPAT) {
        return NULL;
    }

    if (shareContext) {
        share_context = static_cast<GlxContext*>(shareContext)->context;
    }

    if (glxVersion >= 0x0104 && has_GLX_ARB_create_context) {
        Attributes<int> attribs;
        attribs.add(GLX_RENDER_TYPE, GLX_RGBA_TYPE);
        if (debug) {
            attribs.add(GLX_CONTEXT_FLAGS_ARB, GLX_CONTEXT_DEBUG_BIT_ARB);
        }
        attribs.end();

        context = glXCreateContextAttribsARB(display, visual->fbconfig, share_context, True, attribs);
    } else 
           if (glxVersion >= 0x103) {
        context = glXCreateNewContext(display, visual->fbconfig, GLX_RGBA_TYPE, share_context, True);
    } else {
        context = glXCreateContext(display, visual->visinfo, share_context, True);
    }

    return new GlxContext(visual, profile, context);
}
예제 #8
0
void AgentObserverMap::setSubjectAttributes(const QStringList & attribs, TypesOfSubjects type,
                                          const QString & className)
{
    QHash<QString, Attributes*> * mapAttributes = getMapAttributes();

    for (int i = 0; i < attribs.size(); i++)
    {
        if (! subjectAttributes.contains(attribs.at(i)) )
            subjectAttributes.push_back(attribs.at(i));
 
        if (! mapAttributes->contains(attribs.at(i)))
        {
            if (! QUIET_MODE )
            {
                qWarning("Warning: The attribute called \"%s\" not found.", 
                    qPrintable(attribs.at(i)));
            }
        }
        else
        {
            Attributes *attrib = mapAttributes->value(attribs.at(i));
            attrib->setType(type);
            attrib->setClassName(className);
        }
    }

    if (type == TObsAgent)
        getPainterWidget()->setExistAgent(true);
}
void ILI2Handler::startElement(
        const   XMLCh* const    uri,
        const   XMLCh* const    localname,
        const   XMLCh* const    qname,
        const   Attributes& attrs
    ) {
  
  // start to add the layers, features with the DATASECTION
  char *tmpC = NULL;
  m_nEntityCounter = 0;
  if ((level >= 0) || (cmpStr(ILI2_DATASECTION, tmpC = XMLString::transcode(qname)) == 0)) {
    level++;
    
    if (level >= 2) { 
      
      // create the dom tree
      DOMElement *elem = (DOMElement*)dom_doc->createElement(qname);
      
      // add all attributes
      unsigned int len = attrs.getLength();
      for (unsigned int index = 0; index < len; index++)
        elem->setAttribute(attrs.getQName(index), attrs.getValue(index));
      dom_elem->appendChild(elem);
      dom_elem = elem;
    }
  }
  XMLString::release(&tmpC);
}
예제 #10
0
void NASReader::CheckForRelations( const char *pszElement,
                                   const Attributes &attrs,
                                   char **ppszCurField )

{
    GMLFeature *poFeature = GetState()->m_poFeature;

    CPLAssert( poFeature  != NULL );

    int nIndex;
    XMLCh  Name[100];

    tr_strcpy( Name, "xlink:href" );
    nIndex = attrs.getIndex( Name );

    if( nIndex != -1 )
    {
        char *pszHRef = tr_strdup( attrs.getValue( nIndex ) );

        if( EQUALN(pszHRef,"urn:adv:oid:", 12 ) )
        {
            poFeature->AddOBProperty( pszElement, pszHRef );
            CPLFree( *ppszCurField );
            *ppszCurField = CPLStrdup( pszHRef + 12 );
        }

        CPLFree( pszHRef );
    }
}
예제 #11
0
	void startElement(const XMLCh* const uri, const XMLCh* const localname, const XMLCh* const qname, const Attributes& attrs )      {
		theOStream << "<" << qname;
		for ( unsigned int i = 0; i < attrs.getLength(); i++ ) {
			theOStream  <<  " " << attrs.getQName( i ) << "=\"" << attrs.getValue( i ) << "\"";
		}
		theOStream << ">";
	}     
예제 #12
0
void NASReader::PushFeature( const char *pszElement, 
                             const Attributes &attrs )

{
    int iClass;

/* -------------------------------------------------------------------- */
/*      Find the class of this element.                                 */
/* -------------------------------------------------------------------- */
    for( iClass = 0; iClass < GetClassCount(); iClass++ )
    {
        if( EQUAL(pszElement,GetClass(iClass)->GetElementName()) )
            break;
    }

/* -------------------------------------------------------------------- */
/*      Create a new feature class for this element, if there is no     */
/*      existing class for it.                                          */
/* -------------------------------------------------------------------- */
    if( iClass == GetClassCount() )
    {
        CPLAssert( !IsClassListLocked() );

        GMLFeatureClass *poNewClass = new GMLFeatureClass( pszElement );

        AddClass( poNewClass );
    }

/* -------------------------------------------------------------------- */
/*      Create a feature of this feature class.                         */
/* -------------------------------------------------------------------- */
    GMLFeature *poFeature = new GMLFeature( GetClass( iClass ) );

/* -------------------------------------------------------------------- */
/*      Create and push a new read state.                               */
/* -------------------------------------------------------------------- */
    GMLReadState *poState;

    poState = new GMLReadState();
    poState->m_poFeature = poFeature;
    PushState( poState );

/* -------------------------------------------------------------------- */
/*      Check for gml:id, and if found push it as an attribute named    */
/*      gml_id.                                                         */
/* -------------------------------------------------------------------- */
    int nFIDIndex;
    XMLCh   anFID[100];

    tr_strcpy( anFID, "gml:id" );
    nFIDIndex = attrs.getIndex( anFID );
    if( nFIDIndex != -1 )
    {
        char *pszFID = tr_strdup( attrs.getValue( nFIDIndex ) );
        SetFeatureProperty( "gml_id", pszFID );
        CPLFree( pszFID );
    }

}
예제 #13
0
void AttributesParserTest::testParser2()
{
	Attributes attrs;
	std::istringstream istr("name=value");
	AttributesParser parser(attrs, istr);
	parser.parse();
	assert (attrs.getString("name") == "value");
}
예제 #14
0
void AttributesParserTest::testParser1()
{
	Attributes attrs;
	std::istringstream istr("");
	AttributesParser parser(attrs, istr);
	parser.parse();
	assert (attrs.begin() == attrs.end());
}
예제 #15
0
파일: Debug.cpp 프로젝트: bambams/Monday
/**
 * Function: Show_attributes
 *
 * Display both the key and value for an Attributes map.
 *
 * Since this is a non-critical message, it is only shown when the debug value
 * is set high enough.
 *
 * Parameter: attributes Defined as std::map<std::string, std::string> pair.
 *            Most commonly found in data as a "name = value" pair.
 */
void Show_attributes(std::ostream& os, Attributes& attributes)
{
	Monday_out(VERBOSE_LEVEL2, os, "- Num attributes: %d\n", attributes.size());
	for(Attributes::iterator i = attributes.begin(); i != attributes.end(); ++i)
	{
		Monday_out(VERBOSE_LEVEL2, os, "  \"%s\" = \"%s\"\n", i->first.c_str(), i->second.c_str());
	}
}
예제 #16
0
 ArrayDesc inferSchema(std::vector< ArrayDesc> schemas, boost::shared_ptr< Query> query)
 {
     Attributes outputAttrs;
     outputAttrs.push_back(AttributeDesc(0, "dummy", TID_DOUBLE, AttributeDesc::IS_NULLABLE, 0));
     Dimensions outputDims;
     outputDims.push_back(DimensionDesc("i",0,0,1,0));
     return ArrayDesc("test_cache", outputAttrs, outputDims);
 }
예제 #17
0
/* Given                            should become
 *            OperatorToken *                 OperatorToken *
 *            --------------                  --------------
 * type:      TOKEN_OPERATOR_TYPE             TOKEN_OPERATOR_TYPE
 * symbol:       '<'                          '<'
 * arity:         0                           INFIX
 * assoc:         0                           LEFT_TO_RIGHT
 * precedence:    0                           8
 *
 */
void test_extendQuadrupleCharacterOperator_given_lessThan_should_give_correct_attributes(void)
{
  OperatorToken *op = (OperatorToken*)createOperatorToken("<");
  Attributes *attr = &operatorAttributesTable[(int)*(op->symbol)];
  op =(OperatorToken *)attr->extend((Token *)op, attr);

  TEST_ASSERT_EQUAL_ATTRIBUTE_OPERATOR(INFIX, LEFT_TO_RIGHT, 8, "<", op);
}
예제 #18
0
TEST(AttributesTest, get_decoded_value)
{
    string s;
    Attributes a;
    a.addFromGFF("foo=hello%20world%2Cplanet");
    a.get("foo", s);
    EXPECT_EQ("hello world,planet", s);
}
예제 #19
0
TEST(AttributesTest, funky_attribute_def)
{
    vector<string> v;
    Attributes a;
    a.addFromGFF("foo=1;foo=2");
    EXPECT_TRUE(a.all("foo", v));
    EXPECT_THAT(v, ElementsAre("1", "2"));
}
예제 #20
0
TEST(AttributesTest, invalid_attrib_is_ignored)
{
    string s = "default";
    Attributes a;
    a.addFromGFF("foo");
    EXPECT_FALSE(a.get("foo", s));
    EXPECT_EQ("default", s);
}
예제 #21
0
TEST(AttributesTest, get_first_of_many)
{
    string s;
    Attributes a;
    a.addFromGFF("foo=bar,baz");
    a.get("foo", s);
    EXPECT_EQ("bar", s);
}
예제 #22
0
TEST(AttributesTest, get_empty_value)
{
    string s;
    Attributes a;
    a.addFromGFF("foo=");
    a.get("foo", s);
    EXPECT_EQ("", s);
}
예제 #23
0
TEST(AttributesTest, raw)
{
    string s;
    Attributes a;
    a.addFromGFF("foo=hello%20world%2Fplanet");
    a.raw("foo", s);
    EXPECT_EQ("hello%20world%2Fplanet", s);
}
예제 #24
0
TEST(AttributesTest, get)
{
    string s;
    Attributes a;
    a.addFromGFF("foo=bar");
    a.get("foo", s);
    EXPECT_EQ("bar", s);
}
예제 #25
0
TEST(AttributesTest, has)
{
    Attributes a;
    a.addFromGFF("foo=bar;baz=bat");
    EXPECT_TRUE(a.has("foo"));
    EXPECT_TRUE(a.has("baz"));
    EXPECT_FALSE(a.has("blah"));
}
예제 #26
0
/* Given                            should become
 *            OperatorToken *                 OperatorToken *
 *            --------------                  --------------
 * type:      TOKEN_OPERATOR_TYPE             TOKEN_OPERATOR_TYPE
 * symbol:       '/='                          '/='
 * arity:         0                           INFIX
 * assoc:         0                           RIGHT_TO_LEFT
 * precedence:    0                           1
 *
 */
void test_extendDoubleCharacterOperator_given_divideEqual_should_give_correct_attributes(void)
{
  OperatorToken *op = (OperatorToken*)createOperatorToken("/=");
  Attributes *attr = &operatorAttributesTable[(int)*(op->symbol)];
  op =(OperatorToken *)attr->extend((Token *)op, attr);

  TEST_ASSERT_EQUAL_ATTRIBUTE_OPERATOR(INFIX, RIGHT_TO_LEFT, 1, "/=", op);
}
예제 #27
0
/* Given                            should become
 *            OperatorToken *                 OperatorToken *
 *            --------------                  --------------
 * type:      TOKEN_OPERATOR_TYPE             TOKEN_OPERATOR_TYPE
 * symbol:       '('                          '('
 * arity:         0                           PREFIX
 * assoc:         0                           LEFT_TO_RIGHT
 * precedence:    0                           13
 *
 */
void test_extendSingleCharacterOperator_given_openBracket_should_give_correct_attributes(void)
{
  OperatorToken *op = (OperatorToken*)createOperatorToken("(");
  Attributes *attr = &operatorAttributesTable[(int)*(op->symbol)];
  op =(OperatorToken *)attr->extend((Token *)op, attr);

  TEST_ASSERT_EQUAL_ATTRIBUTE_OPERATOR(PREFIX, LEFT_TO_RIGHT, 13, "(", op);
}
예제 #28
0
TEST(AttributesTest, all)
{
    vector<string> v;
    Attributes a;
    a.addFromGFF("foo=bar%2Cbaz,bat");
    EXPECT_TRUE(a.all("foo", v));
    EXPECT_FALSE(a.all("non-existent", v));
    EXPECT_THAT(v, ElementsAre("bar,baz", "bat"));
}
예제 #29
0
Attributes
Device::GetBasicAttributes()
{
	Attributes attributes;
	attributes.push_back(Attribute(B_TRANSLATE("Device name:"), GetName()));
	attributes.push_back(Attribute(B_TRANSLATE("Manufacturer:"),
		GetManufacturer()));
	return attributes;
}
예제 #30
0
 virtual Status startElement(const string& name,
                             const Attributes& attributes,
                             stream_offset position)
 {
     os_ << "[0x" << hex << position << "] startElement: " << name;
     for_each(attributes.begin(), attributes.end(), PrintAttribute(os_));
     os_ << endl;
     return Status::Ok;
 };