本文整理汇总了C++中Attributes类的典型用法代码示例。如果您正苦于以下问题:C++ Attributes类的具体用法?C++ Attributes怎么用?C++ Attributes使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Attributes类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
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: getMapAttributes
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;
}
示例3: getEIC
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;
}
示例4: runtime_error
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());
}
示例5: createContext
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);
}
示例6:
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);
}
示例7: CheckForRelations
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 );
}
}
示例8: startElement
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 << ">";
}
示例9: PushFeature
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 );
}
}
示例10: istr
void AttributesParserTest::testParser2()
{
Attributes attrs;
std::istringstream istr("name=value");
AttributesParser parser(attrs, istr);
parser.parse();
assert (attrs.getString("name") == "value");
}
示例11: Show_attributes
/**
* 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());
}
}
示例12: inferSchema
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);
}
示例13: test_extendQuadrupleCharacterOperator_given_lessThan_should_give_correct_attributes
/* 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);
}
示例14: TEST
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);
}
示例15: test_extendDoubleCharacterOperator_given_divideEqual_should_give_correct_attributes
/* 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);
}