コード例 #1
0
ファイル: MordentHandler.cpp プロジェクト: aleph7/mxml
void MordentHandler::startElement(const lxml::QName& qname, const AttributeMap& attributes) {
    _result.reset(new Mordent());

    auto placement = attributes.find(kPlacementAttribute);
    if (placement != attributes.end())
        _result->setPlacement(presentOptional(EmptyPlacementHandler::placementFromString(placement->second)));

    auto longv = attributes.find(kLongAttribute);
    if (longv != attributes.end())
        _result->setLong(longv->second == "yes");
}
コード例 #2
0
ファイル: KeyHandler.cpp プロジェクト: aleph7/mxml
void KeyHandler::startElement(const QName& qname, const AttributeMap& attributes) {
    _result.reset(new Key());
    
    auto number = attributes.find(kNumberAttribute);
    if (number != attributes.end())
        _result->setNumber(lxml::IntegerHandler::parseInteger(number->second));
    
    auto print = attributes.find(kPrintObjectAttribute);
    if (print != attributes.end())
        _result->setPrintObject(print->second == "no" ? false : true);
}
コード例 #3
0
bool
TemplateBuilder::hasAttribute(
  const AttributeMap& attributes,
  const std::string& name)
{
  return attributes.find(name) != attributes.end();
}
コード例 #4
0
ファイル: StyleSheetTable.cpp プロジェクト: 2php/FBReaderJ
void StyleSheetTable::setLength(ZLTextStyleEntry &entry, ZLTextStyleEntry::Feature featureId, const AttributeMap &map, const std::string &attributeName) {
	StyleSheetTable::AttributeMap::const_iterator it = map.find(attributeName);
	if (it != map.end()) {
		::trySetLength(entry, featureId, it->second);
		return;
	}
}
コード例 #5
0
ファイル: PartHandler.cpp プロジェクト: aleph7/mxml
void PartHandler::startElement(const QName& qname, const AttributeMap& attributes) {
    _result.reset(new Part());
    _measureIndex = 0;

    auto id = attributes.find(kIdTag);
    if (id != attributes.end())
        _result->setId(id->second);
}
コード例 #6
0
void onObserve(const HeaderOptions &headerOption , const OCRepresentation& rep , const int& eCode, const int& sequenceNumber)
{
	std::cout << "onObserve" << std::endl;
//    if(eCode == SUCCESS_RESPONSE)
	if(eCode <= OC_STACK_RESOURCE_DELETED)
    {

        AttributeMap attributeMap = rep.getAttributeMap();

        for(auto it = attributeMap.begin() ; it != attributeMap.end() ; ++it)
        {
            if(attributeMap.find(it->first) == attributeMap.end())
            {
                return;
            }
        }

        if(rep.getUri().empty())
        {
        	cout << "uri is null\n";
            return;
        }

        std::cout << std::endl;
        std::cout << "========================================================" << std::endl;
        std::cout << "Receive OBSERVE RESULT:" << std::endl;
        std::cout << "\tSequenceNumber: " << sequenceNumber << std::endl;
        for(auto it = attributeMap.begin() ; it != attributeMap.end() ; ++it)
        {
            std::cout << "\tAttribute name: " << it->first << " value: ";
            for(auto valueItr = it->second.begin() ; valueItr != it->second.end() ; ++valueItr)
            {
                std::cout << "\t" << *valueItr << " ";
            }

            std::cout << std::endl;
        }

        if(observe_count() > 30)
        {
            std::cout << "Cancelling Observe..." << std::endl;
            OCStackResult result = g_curResource->cancelObserve();

            std::cout << "Cancel result: " << result << std::endl;
            sleep(10);
            std::cout << "DONE" << std::endl;
            std::exit(0);
        }
    }
    else
    {
        std::cout << "onObserve Response error: " << eCode << std::endl;
        std::exit(-1);
    }
}
コード例 #7
0
ファイル: DirectionTypeHandler.cpp プロジェクト: aleph7/mxml
void PedalHandler::startElement(const lxml::QName& qname, const AttributeMap& attributes) {
    using dom::presentOptional;
    using lxml::DoubleHandler;
    using lxml::StringHandler;

    _result.reset(new Pedal{});
    _result->position = PositionFactory::buildFromAttributes(attributes);

    auto type = attributes.find(kTypeAttribute);
    if (type != attributes.end())
        _result->setType(typeFromString(type->second));

    auto line = attributes.find(kLineAttribute);
    if (line != attributes.end())
        _result->setLine(presentOptional(line->second == "yes"));

    auto sign = attributes.find(kSignAttribute);
    if (sign != attributes.end())
        _result->setSign(presentOptional(sign->second == "yes"));
}
コード例 #8
0
ファイル: StyleSheetTable.cpp プロジェクト: ALEXGUOQ/FBReader
void StyleSheetTable::setLength(ZLTextStyleEntry &entry, ZLTextStyleEntry::Length name, const AttributeMap &map, const std::string &attributeName) {
	StyleSheetTable::AttributeMap::const_iterator it = map.find(attributeName);
	if (it == map.end()) {
		return;
	}
	const std::vector<std::string> &values = it->second;
	if (!values.empty() && !values[0].empty()) {
		short size;
		ZLTextStyleEntry::SizeUnit unit;
		parseLength(values[0], size, unit);
		entry.setLength(name, size, unit);
	}
}
コード例 #9
0
ファイル: DirectionTypeHandler.cpp プロジェクト: aleph7/mxml
void WedgeHandler::startElement(const QName& qname, const AttributeMap& attributes) {
    using dom::presentOptional;
    using lxml::DoubleHandler;

    _result.reset(new Wedge{});
    _result->position = PositionFactory::buildFromAttributes(attributes);

    auto type = attributes.find(kTypeAttribute);
    if (type != attributes.end())
        _result->setType(typeFromString(type->second));
    
    auto number = attributes.find(kNumberAttribute);
    if (number != attributes.end())
        _result->setNumber(lxml::IntegerHandler::parseInteger(number->second));
    
    auto spread = attributes.find(kSpreadAttribute);
    if (spread != attributes.end()) {
        auto spreadValue = DoubleHandler::parseDouble(spread->second);
        if (spreadValue > 0)
            _result->setSpread(spreadValue);
    }
}
コード例 #10
0
bool
TemplateBuilder::getRequiredBooleanAttribute(
  const AttributeMap& attributes,
  const std::string& name)
{
  AttributeMap::const_iterator it = attributes.find(name);
  if(it == attributes.end())
  {
    std::string errMsg;
    errMsg +=
      "[ERR S1] Missing required attribute \"" + name + "\"";
    throw TemplateDefinitionError(errMsg);
  }
  return getOptionalBooleanAttribute(attributes, name, false);
}
コード例 #11
0
bool
TemplateBuilder::getOptionalAttribute(
  const AttributeMap& attributes,
  const std::string& name,
  std::string & result
  )
{
  AttributeMap::const_iterator it = attributes.find(name);
  if(it == attributes.end())
  {
    return false;
  }
  result = it->second;
  return true;
}
コード例 #12
0
ファイル: IQParser.cpp プロジェクト: bessey/picnic-doc-server
void IQParser::handleStanzaAttributes(const AttributeMap& attributes) {
	AttributeMap::const_iterator type = attributes.find("type");
	if (type != attributes.end()) {
		if (type->second == "set") {
			getStanzaGeneric()->setType(IQ::Set);
		}
		else if (type->second == "get") {
			getStanzaGeneric()->setType(IQ::Get);
		}
		else if (type->second == "result") {
			getStanzaGeneric()->setType(IQ::Result);
		}
		else if (type->second == "error") {
			getStanzaGeneric()->setType(IQ::Error);
		}
		else {
			std::cerr << "Unknown IQ type: " << type->second << std::endl;
			getStanzaGeneric()->setType(IQ::Get);
		}
	}
}
コード例 #13
0
bool
TemplateBuilder::getOptionalBooleanAttribute(
  const AttributeMap& attributes,
  const std::string& name,
  bool defaultResult)
{
  bool result = defaultResult;
  AttributeMap::const_iterator it = attributes.find(name);
  if(it != attributes.end())
  {
    char yn = it->second[0];
    yn = toupper(yn);
    if(yn != 'Y' && yn != 'N' && yn != 'T' && yn != 'F')
    {
      std::stringstream msg;
      msg << "[ERR S1] Invalid boolean \"" << name << "=\"" << it->second;
      throw TemplateDefinitionError(msg.str());
    }
    result = (yn == 'Y' || yn == 'T');
  }
  return result;
}
コード例 #14
0
void ManufacturingSchematic::sendAttributes(PlayerObject* playerObject)
{

	if(playerObject->getConnectionState() != PlayerConnState_Connected)
		return;

	TangibleObject* tItem = this->getItem();
	if(!tItem)
		return;

	AttributeMap::iterator		mapIt;
	AttributeMap*				iAttributeMap		= tItem->getAttributeMap();
	AttributeOrderList*			iAttributeOrderList	= tItem->getAttributeOrder();

	AttributeMap*				rAttributeMap		= getAttributeMap();
	AttributeOrderList*			rAttributeOrderList	= getAttributeOrder();

	//DraftSchematic*				draftSchematic		= gSchematicManager->getSchematicBySlotId(mDynamicInt32);
	//DraftSlots*					draftSlots			= draftSchematic->getDraftSlots();

	Message*					newMessage;
	string						value,aStr;
	BStringVector				dataElements;

	//uint32	amountSlots		= draftSlots->size();
	//uint8	i				= 0;

	gMessageFactory->StartMessage();
	gMessageFactory->addUint32(opAttributeListMessage);
	gMessageFactory->addUint64(mId);

	//add slots and resource/item requirements

	gMessageFactory->addUint32(iAttributeMap->size()+ rAttributeMap->size()+1);

	AttributeOrderList::iterator	orderIt = rAttributeOrderList->begin();

	while(orderIt != rAttributeOrderList->end())
	{
		mapIt = rAttributeMap->find(*orderIt);

		gMessageFactory->addString(gWorldManager->getAttributeKey((*mapIt).first));

		value = (*mapIt).second.c_str();
		value.convert(BSTRType_Unicode16);

		gMessageFactory->addString(value);

		++orderIt;
	}

	//attributes ....
	gMessageFactory->addString(BString("manf_attribs"));
	aStr = "\\#"SOE_RED" --------------";
	aStr.convert(BSTRType_Unicode16);
	gMessageFactory->addString(aStr);


	orderIt = iAttributeOrderList->begin();

	while(orderIt != iAttributeOrderList->end())
	{
		mapIt = iAttributeMap->find(*orderIt);

		gMessageFactory->addString(gWorldManager->getAttributeKey((*mapIt).first));

		value = (*mapIt).second.c_str();
		value.convert(BSTRType_Unicode16);

		gMessageFactory->addString(value);

		++orderIt;
	}

	//gMessageFactory->addUint32(0xffffffff);

	newMessage = gMessageFactory->EndMessage();

	(playerObject->getClient())->SendChannelAUnreliable(newMessage, playerObject->getAccountId(),CR_Client,9);

}
コード例 #15
0
ファイル: FactoryCrate.cpp プロジェクト: jason83/mmoserver
void FactoryCrate::sendAttributes(PlayerObject* playerObject)
{

    if(!(playerObject->isConnected()))
        return;

    AttributeMap*				iAttributeMap		= this->getLinkedObject()->getAttributeMap();
    AttributeOrderList*			iAttributeOrderList	= this->getLinkedObject()->getAttributeOrder();

    Message* newMessage;

    gMessageFactory->StartMessage();
    gMessageFactory->addUint32(opAttributeListMessage);
    gMessageFactory->addUint64(mId);

    gMessageFactory->addUint32(2 + mAttributeMap.size()+iAttributeMap->size());

    BString	tmpValueStr = BString(BSTRType_Unicode16,64);
    BString	value,aStr;

    tmpValueStr.setLength(swprintf(tmpValueStr.getUnicode16(),50,L"%u/%u",mMaxCondition - mDamage,mMaxCondition));

    gMessageFactory->addString(BString("condition"));
    gMessageFactory->addString(tmpValueStr);

    AttributeMap::iterator			mapIt;
    AttributeOrderList::iterator	orderIt = mAttributeOrderList.begin();



    while(orderIt != mAttributeOrderList.end())
    {
        mapIt = mAttributeMap.find(*orderIt);

        gMessageFactory->addString(gWorldManager->getAttributeKey((*mapIt).first));

        value = (*mapIt).second.c_str();
        value.convert(BSTRType_Unicode16);

        gMessageFactory->addString(value);

        ++orderIt;
    }

    gMessageFactory->addString(BString("factory_attribs"));
    aStr = "\\#"SOE_RED" --------------";
    aStr.convert(BSTRType_Unicode16);
    gMessageFactory->addString(aStr);

    orderIt = iAttributeOrderList->begin();

    while(orderIt != iAttributeOrderList->end())
    {
        mapIt = iAttributeMap->find(*orderIt);

        gMessageFactory->addString(gWorldManager->getAttributeKey((*mapIt).first));

        value = (*mapIt).second.c_str();
        value.convert(BSTRType_Unicode16);

        gMessageFactory->addString(value);

        ++orderIt;
    }

    newMessage = gMessageFactory->EndMessage();

    (playerObject->getClient())->SendChannelAUnreliable(newMessage, playerObject->getAccountId(), CR_Client, 9);
}