C++ (Cpp) data Examples

C++ (Cpp) data - 30 examples found. These are the top rated real world C++ (Cpp) examples of data extracted from open source projects. You can rate examples to help us improve the quality of examples.
Example #1
0
/*
 * SAGA API functions
 */
void file_cpi_impl::sync_get_size (saga::off_t& size_out)
{
    {
        instance_data data(this);
        saga::url file_url(data->location_);
        this->check_if_open ("file_cpi_impl::sync_get_size", file_url);
        if (!::detail::file_islocal(file_url))
        {
            SAGA_OSSTREAM strm;
            strm << "file_cpi_impl::sync_get_size: "
                 "cannot handle remote current file: " << file_url.get_url();
            SAGA_ADAPTOR_THROW(SAGA_OSSTREAM_GETSTRING(strm), saga::adaptors::AdaptorDeclined);
        }
        if (!file_.is_open())
        {
            SAGA_OSSTREAM strm;
            strm << "file_cpi_impl::sync_get_size: "
                 "cannot handle remote file: " << file_url.get_url();
            SAGA_ADAPTOR_THROW(SAGA_OSSTREAM_GETSTRING(strm), saga::adaptors::AdaptorDeclined);
        }
    }

    // position to the end of the file
    {
        mutex_type::scoped_lock lock(mtx_);
        if (file_.eof())
            file_.clear(std::ios::eofbit);
        file_.seekg (0, std::ios::end);
        size_out = file_.tellg ();      // figure out the file size
    }

    // reposition file pointer
    instance_data data (this);
    file_.seekg (data->pointer_, std::ios::beg);
}
Example #2
0
void WorldSession::HandleRaidReadyCheckOpcode(WorldPacket& recvData)
{
    TC_LOG_DEBUG("network", "WORLD: Received MSG_RAID_READY_CHECK");

    Group* group = GetPlayer()->GetGroup();
    if (!group)
        return;

    if (recvData.empty())                                   // request
    {
        /** error handling **/
        if (!group->IsLeader(GetPlayer()->GetGUID()) && !group->IsAssistant(GetPlayer()->GetGUID()))
            return;
        /********************/

        // everything's fine, do it
        WorldPacket data(MSG_RAID_READY_CHECK, 8);
        data << GetPlayer()->GetGUID();
        group->BroadcastPacket(&data, false, -1);

        group->OfflineReadyCheck();
    }
    else                                                    // answer
    {
        uint8 state;
        recvData >> state;

        // everything's fine, do it
        WorldPacket data(MSG_RAID_READY_CHECK_CONFIRM, 9);
        data << uint64(GetPlayer()->GetGUID());
        data << uint8(state);
        group->BroadcastReadyCheck(&data);
    }
}
Example #3
0
/// Only _static_ data send in this packet !!!
void WorldSession::HandleGameObjectQueryOpcode(WorldPacket& recv_data)
{
    uint32 entryID;
    recv_data >> entryID;
    ObjectGuid guid;
    recv_data >> guid;

    const GameObjectInfo* info = ObjectMgr::GetGameObjectInfo(entryID);
    if (info)
    {
        std::string Name;
        std::string IconName;
        std::string CastBarCaption;

        Name = info->name;
        IconName = info->IconName;
        CastBarCaption = info->castBarCaption;

        int loc_idx = GetSessionDbLocaleIndex();
        if (loc_idx >= 0)
        {
            GameObjectLocale const* gl = sObjectMgr.GetGameObjectLocale(entryID);
            if (gl)
            {
                if (gl->Name.size() > size_t(loc_idx) && !gl->Name[loc_idx].empty())
                    Name = gl->Name[loc_idx];
                if (gl->CastBarCaption.size() > size_t(loc_idx) && !gl->CastBarCaption[loc_idx].empty())
                    CastBarCaption = gl->CastBarCaption[loc_idx];
            }
        }
        DETAIL_LOG("WORLD: CMSG_GAMEOBJECT_QUERY '%s' - Entry: %u. ", info->name, entryID);
        WorldPacket data(SMSG_GAMEOBJECT_QUERY_RESPONSE, 150);
        data << uint32(entryID);
        data << uint32(info->type);
        data << uint32(info->displayId);
        data << Name;
        data << uint8(0) << uint8(0) << uint8(0);           // name2, name3, name4
        data << IconName;                                   // 2.0.3, string. Icon name to use instead of default icon for go's (ex: "Attack" makes sword)
        data << CastBarCaption;                             // 2.0.3, string. Text will appear in Cast Bar when using GO (ex: "Collecting")
        data << info->unk1;                                 // 2.0.3, string
        data.append(info->raw.data, 24);
        data << float(info->size);                          // go size
        for (uint32 i = 0; i < 6; ++i)
            data << uint32(info->questItems[i]);            // itemId[6], quest drop
        SendPacket(&data);
        DEBUG_LOG("WORLD: Sent SMSG_GAMEOBJECT_QUERY_RESPONSE");
    }
    else
    {
        DEBUG_LOG("WORLD: CMSG_GAMEOBJECT_QUERY - Guid: %s Entry: %u Missing gameobject info!",
                  guid.GetString().c_str(), entryID);
        WorldPacket data(SMSG_GAMEOBJECT_QUERY_RESPONSE, 4);
        data << uint32(entryID | 0x80000000);
        SendPacket(&data);
        DEBUG_LOG("WORLD: Sent SMSG_GAMEOBJECT_QUERY_RESPONSE");
    }
}
Example #4
0
/** Transposes the matrix.
 * @return a reference to the matrix object now containing the transposed matrix
 */
Matrix &
Matrix::transpose()
{
#ifdef HAVE_OPENCV
    if (m_num_cols == m_num_rows)
    {
        CvMat cvmat = cvMat(m_num_rows, m_num_cols, CV_32FC1, m_data);
        cvTranspose(&cvmat, &cvmat);

        return *this;
    }
#endif
    if (m_num_cols == m_num_rows) // Perform a in-place transpose
    {
        for (unsigned int row = 0; row < m_num_rows - 1; ++row)
        {
            for (unsigned int col = row + 1; col < m_num_cols; ++col)
            {
                float &a = data(row, col);
                float &b = data(col, row);
                float t = a;
                a = b;
                b = t;
            }
        }
    }
    else // Could not find a in-place transpose, so we use a temporary data array
    {
        float *new_data = (float*) malloc(sizeof(float) * m_num_elements);
        float *cur = new_data;

        for (unsigned int col = 0; col < m_num_cols; ++col)
        {
            for (unsigned int row = 0; row < m_num_rows; ++row)
            {
                *cur++ = data(row, col);
            }
        }

        unsigned int cols = m_num_cols;
        m_num_cols = m_num_rows;
        m_num_rows = cols;

        if (m_own_memory)
        {
            free(m_data);
            m_data = new_data;
        }
        else
        {
            for (unsigned int i = 0; i < m_num_elements; ++i) m_data[i] = new_data[i];
            free(new_data);
        }
    }

    return *this;
}
Example #5
0
bool Q3CString::setExpand(uint index, char c)
{
    uint oldlen = length();
    if (index >= oldlen) {
        resize(index+1);
        if (index > oldlen)
            memset(data() + oldlen, ' ', index - oldlen);
    }
    *(data() + index) = c;
    return true;
}
Example #6
0
/// Only _static_ data send in this packet !!!
void WorldSession::HandleCreatureQueryOpcode(WorldPacket& recv_data)
{
    uint32 entry;
    recv_data >> entry;
    ObjectGuid guid;
    recv_data >> guid;

    CreatureInfo const* ci = ObjectMgr::GetCreatureTemplate(entry);
    if (ci)
    {
        int loc_idx = GetSessionDbLocaleIndex();

        char const* name = ci->Name;
        char const* subName = ci->SubName;
        sObjectMgr.GetCreatureLocaleStrings(entry, loc_idx, &name, &subName);

        DETAIL_LOG("WORLD: CMSG_CREATURE_QUERY '%s' - Entry: %u.", ci->Name, entry);
        // guess size
        WorldPacket data(SMSG_CREATURE_QUERY_RESPONSE, 100);
        data << uint32(entry);                              // creature entry
        data << name;
        data << uint8(0) << uint8(0) << uint8(0);           // name2, name3, name4, always empty
        data << subName;
        data << ci->IconName;                               // "Directions" for guard, string for Icons 2.3.0
        data << uint32(ci->CreatureTypeFlags);              // flags
        data << uint32(ci->CreatureType);                   // CreatureType.dbc
        data << uint32(ci->Family);                         // CreatureFamily.dbc
        data << uint32(ci->Rank);                           // Creature Rank (elite, boss, etc)
        data << uint32(ci->KillCredit[0]);                  // new in 3.1, kill credit
        data << uint32(ci->KillCredit[1]);                  // new in 3.1, kill credit

        for (int i = 0; i < MAX_CREATURE_MODEL; ++i)
            data << uint32(ci->ModelId[i]);

        data << float(ci->HealthMultiplier);                // health multiplier
        data << float(ci->PowerMultiplier);                 // power multiplier
        data << uint8(ci->RacialLeader);
        for (uint32 i = 0; i < 6; ++i)
            data << uint32(ci->QuestItems[i]);              // itemId[6], quest drop
        data << uint32(ci->MovementTemplateId);             // CreatureMovementInfo.dbc
        SendPacket(&data);
        DEBUG_LOG("WORLD: Sent SMSG_CREATURE_QUERY_RESPONSE");
    }
    else
    {
        DEBUG_LOG("WORLD: CMSG_CREATURE_QUERY - Guid: %s Entry: %u NO CREATURE INFO!",
                  guid.GetString().c_str(), entry);
        WorldPacket data(SMSG_CREATURE_QUERY_RESPONSE, 4);
        data << uint32(entry | 0x80000000);
        SendPacket(&data);
        DEBUG_LOG("WORLD: Sent SMSG_CREATURE_QUERY_RESPONSE");
    }
}