Ejemplo n.º 1
0
 bool MutableMessage::addScalarField(const char *field, const uint8_t &value) {
     auto e = createScalarField(m_field_allocator, field, value);
     auto result = m_keys.insert(std::make_pair(e->identifier(), m_payload.size()));
     if (tf::likely(result.second)) {
         m_payload.emplace_back(e);
     } else {
         destroyField(m_field_allocator, e);
     }
     return result.second;
 }
Ejemplo n.º 2
0
 bool MutableMessage::addDateTimeField(const char *field, const uint64_t seconds, const uint64_t microseconds) {
     DateTimeField *e = createDateTimeField(m_field_allocator, field, seconds, microseconds);
     auto result = m_keys.insert(std::make_pair(e->identifier(), m_payload.size()));
     if (result.second) {
         m_payload.emplace_back(e);
     } else {
         destroyField(m_field_allocator, e);
     }
     return result.second;
 }
Ejemplo n.º 3
0
 bool MutableMessage::addDateTimeField(const char *field, const std::chrono::time_point<std::chrono::system_clock> &time) {
     DateTimeField *e = createDateTimeField(m_field_allocator, field, time);
     auto result = m_keys.insert(std::make_pair(e->identifier(), m_payload.size()));
     if (result.second) {
         m_payload.emplace_back(e);
     } else {
         destroyField(m_field_allocator, e);
     }
     return result.second;
 }
Ejemplo n.º 4
0
 bool MutableMessage::addMessageField(const char *field, Message *msg) {
     MessageField *e = createMessageField(m_field_allocator, field, msg);
     auto result = m_keys.insert(std::make_pair(e->identifier(), m_payload.size()));
     if (result.second) {
         m_payload.emplace_back(e);
     } else {
         destroyField(m_field_allocator, e);
     }
     return result.second;
 }
Ejemplo n.º 5
0
 bool MutableMessage::addDataField(const char *field, const char *value) {
     DataField *e = createDataField(m_field_allocator, strlen(value) + 1, field, value);
     auto result = m_keys.insert(std::make_pair(e->identifier(), m_payload.size()));
     if (result.second) {
         m_payload.emplace_back(e);
     } else {
         destroyField(m_field_allocator, e);
     }
     return result.second;
 }
Ejemplo n.º 6
0
 bool MutableMessage::removeField(const char* field) {
     if (field != nullptr) {
         auto index = m_keys.find(field);
         if (index != m_keys.end()) {
             m_keys.erase(field);
             auto it = m_payload.begin();
             std::advance(it, index->second);
             destroyField(m_field_allocator, *it);
             m_payload.erase(it);
             return true;
         }
     }
     return false;
 }
Ejemplo n.º 7
0
void destroyGameScene(GameScene &scene)
{
    destroyField(scene.field);
}