本文整理汇总了C++中MamaMsgField类的典型用法代码示例。如果您正苦于以下问题:C++ MamaMsgField类的具体用法?C++ MamaMsgField怎么用?C++ MamaMsgField使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MamaMsgField类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onUpdate
void onUpdate (MamdaFundamentalListener::MamdaFundamentalListenerImpl& impl,
const MamaMsgField& field)
{
switch (field.getType())
{
case MAMA_FIELD_TYPE_I8:
case MAMA_FIELD_TYPE_U8:
case MAMA_FIELD_TYPE_I16:
case MAMA_FIELD_TYPE_U16:
case MAMA_FIELD_TYPE_I32:
case MAMA_FIELD_TYPE_U32:
impl.mDivFreq = impl.getDividendFrequency (field.getU32());
impl.mDivFreqFieldState = MODIFIED;
break;
case MAMA_FIELD_TYPE_STRING:
impl.mDivFreq = impl.getDividendFrequency (field.getString());
impl.mDivFreqFieldState = MODIFIED;
break;
default:
mama_log (MAMA_LOG_LEVEL_FINE,
"Unhandled type %d for wDivFreq. "
"Expected string or integer.",
field.getType());
break;
}
}
示例2: onUpdate
void onUpdate (MamdaQuoteToBookListenerImpl& impl,
const MamaMsgField& field)
{
if (field.getType () == MAMA_FIELD_TYPE_STRING)
{
impl.mQuoteCache.mQuoteQualNative = field.getString();
}
else if (field.getType () == MAMA_FIELD_TYPE_CHAR)
{
impl.mQuoteCache.mQuoteQualNative = field.getChar();
}
}
示例3: encodeVectorMsg
uint32_t MamaRecordedMessageCodec::encodeVectorMsg(char*& buffer, MamaMsgField& mmf)
{
const MamaMsg** mmpp = NULL;
char* orig_buffer = buffer;
// Reserve these four bytes for the vector size
buffer += 4;
MamaMsg* mmp = NULL;
mama_size_t count = 0;
uint16_t r = 4;
uint16_t msg_size = 0;
mmf.getVectorMsg(mmpp, count);
if(count == 0)
{
return 0;
}
uint16_t msg_length = (uint16_t)count;
for(mama_size_t i = 0; i < count; i++)
{
mmp = (MamaMsg*)*mmpp;
//printf("Encountering Message: %s\n", mmp->toString());
msg_size += encodeMsg(buffer, mmp);
r += msg_size;
buffer += msg_size;
mmpp++;
}
// Now we know the total vector size, write it in.
memcpy(orig_buffer, &r, 2);
memcpy(orig_buffer+2, &msg_length, 2);
//printf("Encoded [%d] Vector Message Fields of size [%d]...\n", count, r);
return (uint32_t)r;
}
示例4: encodeTime
uint32_t MamaRecordedMessageCodec::encodeTime(char*& buffer, MamaMsgField& mmf)
{
mmf.getDateTime(*mTempMamaDateTime);
// Get the C version as well because some functionality is missing from C++ for some reason
*mTempCMamaDateTime = mTempMamaDateTime->getCValue();
mama_u32_t seconds = 0; // 4 bytes
mama_u32_t microseconds = 0; // 4 bytes
mamaDateTimePrecision precision = (mamaDateTimePrecision)0; // 4 bytes
mama_u8_t hints = 0; // 1 byte
if(mTempMamaDateTime->hasDate())
hints = hints | MAMA_DATE_TIME_HAS_DATE;
if(mTempMamaDateTime->hasTime())
hints = hints | MAMA_DATE_TIME_HAS_TIME;
mamaDateTime_getWithHints(*mTempCMamaDateTime, &seconds,
µseconds, &precision, &hints);
memcpy(buffer, &seconds, 4);
buffer += 4;
memcpy(buffer, µseconds, 4);
buffer += 4;
memcpy(buffer, &precision, 4);
buffer += 4;
memcpy(buffer, &hints, 1);
buffer += 1;
//printf("Encoding DateTime Field [%d] = %d.%d (%d:%d)...\n", 13, seconds, microseconds, hints, precision);
return 13;
}
示例5: sizeof
uint32_t MamaRecordedMessageCodec::encodeF64(char*& buffer, MamaMsgField& mmf)
{
mama_f64_t mfv = mmf.getF64();
size_t s = sizeof(mfv);
memcpy(buffer, &mfv, s);
buffer += s;
//printf("Encoding U16 Field [%d] = %g...\n", s, mfv);
return s;
}
示例6: encodeBool
uint32_t MamaRecordedMessageCodec::encodeBool(char*& buffer, MamaMsgField& mmf)
{
bool mfv = mmf.getBool();
size_t s = sizeof(mfv);
memcpy(buffer, &mfv, s);
buffer += s;
//printf("Encoding Boolean Field [%d] = %d...\n", s, mfv);
return s;
}
示例7: encodeChar
uint32_t MamaRecordedMessageCodec::encodeChar(char*& buffer, MamaMsgField& mmf)
{
char mfv = mmf.getChar();
size_t s = sizeof(mfv);
memcpy(buffer, &mfv, s);
buffer += s;
//printf("Encoding Char Field [%d] = %c...\n", s, mfv);
return s;
}
示例8: encodeString
uint32_t MamaRecordedMessageCodec::encodeString(char*& buffer, MamaMsgField& mmf)
{
const char* mfv = mmf.getString();
mama_u16_t s = (mama_u16_t)strlen(mfv);
// Add the size to the buffer as this is a non-fixed width field type
memcpy(buffer, &s, 2);
buffer += 2;
memcpy(buffer, mfv, s);
buffer += s;
//printf("Encoding String Field[%d] = %s...\n", s, mfv);
return (s+2);
}
示例9: onField
void MamdaQuoteToBookListenerImpl::onField (const MamaMsg& msg,
const MamaMsgField& field,
void* closure)
{
uint16_t fid = field.getFid();
if (fid <= mFieldUpdatersSize)
{
QuoteToBookFieldUpdate* updater = mFieldUpdaters[fid];
if (updater)
{
updater->onUpdate (*this, field);
}
}
}
示例10:
void MamdaFundamentalListener::MamdaFundamentalListenerImpl::onField (
const MamaMsg& msg,
const MamaMsgField& field,
void* closure)
{
uint16_t fid = field.getFid();
if (fid <= mFieldUpdatersSize)
{
FundamentalFieldUpdate* updater = mFieldUpdaters[fid];
if (updater)
{
updater->onUpdate (*this, field);
}
}
}
示例11: encodePrice
uint32_t MamaRecordedMessageCodec::encodePrice(char*& buffer, MamaMsgField& mmf)
{
// Creates format of [8 bytes value|4 bytes mamaPricePrecision|1 byte mamaPriceHints]
mmf.getPrice(*mTempMamaPrice);
double v = mTempMamaPrice->getValue();
mamaPricePrecision mpp = mTempMamaPrice->getPrecision();
mamaPriceHints mph = mTempMamaPrice->getHints();
printf("value: %d, value: %d, value: %d\n", sizeof(v), sizeof(mpp), sizeof(mph));
size_t s = sizeof(v) + sizeof(mpp) + sizeof(mph);
memcpy(buffer, &v, sizeof(v));
memcpy(buffer, &mpp, sizeof(mpp));
memcpy(buffer, &mph, sizeof(mph));
buffer += s;
//printf("Encoding MamaPrice Field [%d] = %g...\n", s, v);
return s;
}
示例12: encodeField
uint32_t MamaRecordedMessageCodec::encodeField(char*& buffer, MamaMsgField& mmf)
{
uint32_t r = 0;
mamaFieldType mft = mmf.getType();
// These modifications will be applied regardless of data type
mama_fid_t mff = mmf.getFid();
memcpy(buffer, &mff, 2);
buffer += 2;
memcpy(buffer, &mft, 4);
buffer += 4;
r += 6;
switch(mft)
{
case MAMA_FIELD_TYPE_BOOL:
r += encodeBool(buffer, mmf);
break;
case MAMA_FIELD_TYPE_CHAR:
r += encodeChar(buffer, mmf);
break;
case MAMA_FIELD_TYPE_I8:
r += encodeI8(buffer, mmf);
break;
case MAMA_FIELD_TYPE_U8:
r += encodeU8(buffer, mmf);
break;
case MAMA_FIELD_TYPE_I16:
r += encodeI16(buffer, mmf);
break;
case MAMA_FIELD_TYPE_U16:
r += encodeU16(buffer, mmf);
break;
case MAMA_FIELD_TYPE_I32:
r += encodeI32(buffer, mmf);
break;
case MAMA_FIELD_TYPE_U32:
r += encodeU32(buffer, mmf);
break;
case MAMA_FIELD_TYPE_I64:
r += encodeI64(buffer, mmf);
break;
case MAMA_FIELD_TYPE_U64:
r += encodeU64(buffer, mmf);
break;
case MAMA_FIELD_TYPE_F32:
r += encodeF32(buffer, mmf);
break;
case MAMA_FIELD_TYPE_F64:
r += encodeF64(buffer, mmf);
break;
case MAMA_FIELD_TYPE_TIME:
r += encodeTime(buffer, mmf);
break;
case MAMA_FIELD_TYPE_PRICE:
r += encodePrice(buffer, mmf);
break;
case MAMA_FIELD_TYPE_STRING:
r += encodeString(buffer, mmf);
break;
case MAMA_FIELD_TYPE_VECTOR_STRING:
r += encodeVectorString(buffer, mmf);
break;
case MAMA_FIELD_TYPE_VECTOR_I32:
r += encodeVectorI32(buffer, mmf);
break;
case MAMA_FIELD_TYPE_VECTOR_F64:
r += encodeVectorF64(buffer, mmf);
break;
case MAMA_FIELD_TYPE_MSG:
r += encodeMsgField(buffer, mmf);
break;
case MAMA_FIELD_TYPE_VECTOR_MSG:
r += encodeVectorMsg(buffer, mmf);
break;
default:
break;
}
return r;
}