Re: [Quickfix-developers] DataDictionary::isFieldValue doesn't cope with MultipleValueStrin g
Brought to you by:
orenmnero
From: Oren M. <ore...@ya...> - 2003-07-16 19:50:45
|
Here is a new version of the method that takes this into account: bool isFieldValue( int field, const std::string& value ) const { FieldToValue::const_iterator i = m_fieldValues.find( field ); if ( i == m_fieldValues.end() ) return false; if( !isMultipleValueStringField( field ) ) return i->second.find( value ) != i->second.end(); // MultipleValueString std::string::size_type startPos = 0; std::string::size_type endPos = 0; do { endPos = value.find_first_of(' ', startPos); std::string singleValue = value.substr( startPos, endPos - startPos ); if( i->second.find( singleValue ) == i->second.end() ) return false; startPos = endPos + 1; } while( endPos != std::string::npos ); return true; } You will also need to add this method: bool isMultipleValueStringField( int field ) const { FieldTypes::const_iterator i = m_fieldTypes.find( field ); return i != m_fieldTypes.end() && i->second == TYPE::MultipleValueString; } Also, here is the updated unit test. bool DataDictionaryTestCase::checkValue::onSetup ( DataDictionary*& pObject ) { pObject = new DataDictionary; pObject->setVersion( BeginString_FIX40 ); pObject->addField( FIELD::BeginString ); pObject->addField( FIELD::BodyLength ); pObject->addField( FIELD::MsgType ); pObject->addField( FIELD::CheckSum ); pObject->addField( FIELD::OrdType ); pObject->addField( FIELD::OrderRestrictions ); pObject->addMsgType( MsgType_NewOrderSingle ); pObject->addMsgField( MsgType_NewOrderSingle, FIELD::OrdType ); pObject->addMsgField( MsgType_NewOrderSingle, FIELD::OrderRestrictions ); pObject->addFieldType( FIELD::OrdType, TYPE::Char ); pObject->addFieldValue( FIELD::OrdType, "1" ); pObject->addFieldType( FIELD::OrderRestrictions, TYPE::MultipleValueString ); pObject->addFieldValue( FIELD::OrderRestrictions, "1" ); pObject->addFieldValue( FIELD::OrderRestrictions, "2" ); pObject->addFieldValue( FIELD::OrderRestrictions, "3" ); return true; } void DataDictionaryTestCase::checkValue::onRun ( DataDictionary& object ) { FIX40::NewOrderSingle message; message.setField( OrdType( '1' ) ); try{ object.validate( message ); } catch ( IncorrectTagValue& ) { assert( false ); } message.setField( OrdType( '2' ) ); try{ object.validate( message ); assert( false ); } catch ( IncorrectTagValue& ) {} message.setField( OrdType( '1' ) ); message.setField( OrderRestrictions("1 2 3") ); try{ object.validate( message ); } catch ( IncorrectTagValue& e ) { assert(false); } message.setField( OrderRestrictions("1 4 3") ); try{ object.validate( message ); assert(false); } catch ( IncorrectTagValue& e ) {} } --- Chris Patmore <Chr...@BT...> wrote: > Field ExecInst can contain a space separated list of > execution instructions. > In quickfix it is defined > > <field number="18" name="ExecInst" > type="MULTIPLEVALUESTRING"> > > When an incoming message contains multiple values, > e.g. "G Q" the method > > bool isFieldValue( int field, const std::string& > value ) const > { > FieldToValue::const_iterator i = > m_fieldValues.find( field ); > if ( i == m_fieldValues.end() ) > return false; > return i->second.find( value ) != > i->second.end(); > } > > will return false and the message will be rejected. > This method does not > take into account the fact that this field type can > contain multiple > entries, each of which needs to be checked > individually against the > enumerated values. > > Chris > > **************************************************************************** > This message is confidential to the sender and > addressee, and may contain > proprietary or legally privileged information. If > you are not the intended > recipient, please delete it from your system, > destroy any copies, and notify > the sender immediately. Opinions stated herein are > not necessarily those of > BrokerTec. BrokerTec reserves the right to monitor > messages that pass > through it's networks. BrokerTec Europe Ltd is > regulated by FSA. > > > ------------------------------------------------------- > This SF.net email is sponsored by: VM Ware > With VMware you can run multiple operating systems > on a single machine. > WITHOUT REBOOTING! Mix Linux / Windows / Novell > virtual machines at the > same time. Free trial click here: > http://www.vmware.com/wl/offer/345/0 > _______________________________________________ > Quickfix-developers mailing list > Qui...@li... > https://lists.sourceforge.net/lists/listinfo/quickfix-developers __________________________________ Do you Yahoo!? SBC Yahoo! DSL - Now only $29.95 per month! http://sbc.yahoo.com |