当前位置: 首页>>代码示例>>C++>>正文


C++ PyRep类代码示例

本文整理汇总了C++中PyRep的典型用法代码示例。如果您正苦于以下问题:C++ PyRep类的具体用法?C++ PyRep怎么用?C++ PyRep使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了PyRep类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: FindKeyword

PyList* CRowSet::_GetColumnList() const
{
	PyRep* r = FindKeyword( "columns" );
	assert( r );

	return r->AsList();
}
开发者ID:AlTahir,项目名称:Apocrypha_combo,代码行数:7,代码来源:PyDatabase.cpp

示例2: UnmarshalLogText

void UnmarshalLogText( const Seperator& cmd )
{
    const char* cmdName = cmd.arg( 0 ).c_str();

    if( 1 == cmd.argCount() )
    {
        sLog.Error( cmdName, "Usage: %s marshal-binary [marshal-binary] ...", cmdName );
        return;
    }

    for( size_t i = 1; i < cmd.argCount(); ++i )
    {
        const std::string& marshalBinaryStr = cmd.arg( i );

        Buffer marshalBinary;
        if( !PyDecodeEscape( marshalBinaryStr.c_str(), marshalBinary ) )
        {
            sLog.Error( cmdName, "Failed to decode string into binary." );
            continue;
        }

        PyRep* r = InflateUnmarshal( marshalBinary );
        if( NULL == r )
            sLog.Error( cmdName, "Failed to unmarshal binary." );
        else
        {
            sLog.Success( cmdName, "Result:" );
            r->Dump( stdout, "    " );

            PyDecRef( r );
        }
    }
}
开发者ID:AlTahir,项目名称:Apocrypha_combo,代码行数:33,代码来源:Commands.cpp

示例3: _GetValueTuple

PyTuple* ClientSession::_GetValueTuple( const char* name ) const
{
    PyRep* v = mSession->GetItemString( name );
    if( v == NULL )
        return NULL;
    return v->AsTuple();
}
开发者ID:AlTahir,项目名称:Apocrypha_combo,代码行数:7,代码来源:ClientSession.cpp

示例4: EncodeChanges

void ClientSession::EncodeChanges( PyDict* into )
{
    PyDict::const_iterator cur, end;
    cur = mSession->begin();
    end = mSession->end();
    for(; cur != end; cur++)
    {
        PyString* str = cur->first->AsString();
        PyTuple* value = cur->second->AsTuple();

        PyRep* last = value->GetItem( 0 );
        PyRep* current = value->GetItem( 1 );

        if( last->hash() != current->hash() )
        {
            // Duplicate tuple
            PyTuple* t = new PyTuple( 2 );
            t->SetItem( 0, last ); PyIncRef( last );
            t->SetItem( 1, current ); PyIncRef( current );
            into->SetItem( str, t ); PyIncRef( str );

            // Update our tuple
            value->SetItem( 0, current ); PyIncRef( current );
        }
    }

	mDirty = false;
}
开发者ID:AlTahir,项目名称:Apocrypha_combo,代码行数:28,代码来源:ClientSession.cpp

示例5: _GetCurrent

int64 ClientSession::GetCurrentLong( const char* name ) const
{
    PyRep* v = _GetCurrent( name );
    if( v == NULL )
        return 0;

    if( !v->IsLong() )
        return 0;

    return v->AsLong()->value();
}
开发者ID:AlTahir,项目名称:Apocrypha_combo,代码行数:11,代码来源:ClientSession.cpp

示例6: PopPacket

PyPacket* EVEClientSession::PopPacket()
{
    PyRep* r = mNet->PopRep();
    if( r == NULL )
        return NULL;

    if(is_log_enabled(NET__PRES_REP)) {
        _log(NET__PRES_REP, "%s: Raw Rep Dump:", GetAddress().c_str());
        r->Dump(NET__PRES_REP, "    ");
    }

    assert( mPacketHandler );
    return ( this->*mPacketHandler )( r );
}
开发者ID:Almamu,项目名称:evemu_crucible,代码行数:14,代码来源:EVESession.cpp

示例7: TestMarshal

void TestMarshal( const Seperator& cmd )
{
    const char* cmdName = cmd.arg( 0 ).c_str();

    DBRowDescriptor *header = new DBRowDescriptor;
    // Fill header:
    header->AddColumn( "historyDate", DBTYPE_FILETIME );
    header->AddColumn( "lowPrice", DBTYPE_CY );
    header->AddColumn( "highPrice", DBTYPE_CY );
    header->AddColumn( "avgPrice", DBTYPE_CY );
    header->AddColumn( "volume", DBTYPE_I8 );
    header->AddColumn( "orders", DBTYPE_I4 );

    CRowSet* rs = new CRowSet( &header );

    PyPackedRow* row = rs->NewRow();
    row->SetField( "historyDate", new PyLong( Win32TimeNow() ) );
    row->SetField( "lowPrice", new PyLong( 18000 ) );
    row->SetField( "highPrice", new PyLong( 19000 ) );
    row->SetField( "avgPrice", new PyLong( 18400 ) );
    row->SetField( "volume", new PyLong( 5463586 ) );
    row->SetField( "orders", new PyInt( 254 ) );

    sLog.Log( cmdName, "Marshaling..." );

    Buffer marshaled;
    bool res = MarshalDeflate( rs, marshaled );
    PyDecRef( rs );

    if( !res )
    {
        sLog.Error( cmdName, "Failed to marshal Python object." );
        return;
    }

    sLog.Log( cmdName, "Unmarshaling..." );

    PyRep* rep = InflateUnmarshal( marshaled );
    if( NULL == rep )
    {
        sLog.Error( cmdName, "Failed to unmarshal Python object." );
        return;
    }

    sLog.Success( cmdName, "Final:" );
    rep->Dump( stdout, "    " );

    PyDecRef( rep );
}
开发者ID:AlTahir,项目名称:Apocrypha_combo,代码行数:49,代码来源:Commands.cpp

示例8: tcp_callback

void tcp_callback (struct tcp_stream *a_tcp, void ** this_time_not_needed) {
    char buf[1024];
    strcpy (buf, adres (a_tcp->addr)); // we put conn params into buf

    if (a_tcp->nids_state == NIDS_JUST_EST) {

        //see if this is a stream we care about...
        if(a_tcp->addr.source != 26000 && a_tcp->addr.dest != 26000 &&
                a_tcp->addr.source != 26001 && a_tcp->addr.dest != 26001)
            return;

        a_tcp->client.collect++; // we want data received by a client
        a_tcp->server.collect++; // and by a server, too
        _log(COLLECT__TCP, "%s established", buf);
        return;
    }
    if (a_tcp->nids_state == NIDS_CLOSE) {
        // connection has been closed normally
        _log(COLLECT__TCP, "%s closing", buf);
        return;
    }
    if (a_tcp->nids_state == NIDS_RESET) {
        // connection has been closed by RST
        _log(COLLECT__TCP, "%s reset", buf);
        return;
    }

    if (a_tcp->nids_state == NIDS_DATA) {
        // new data has arrived; gotta determine in what direction
        // and if it's urgent or not

        struct half_stream *hlf;
        StreamPacketizer *sp;

        if (a_tcp->client.count_new) {
            // new data for client
            hlf = &a_tcp->client; // from now on, we will deal with hlf var,
            // which will point to client side of conn
            sp = &clientPacketizer;
            strcat (buf, "(<-)"); // symbolic direction of data
        } else {
            sp = &serverPacketizer;
            hlf = &a_tcp->server; // analogical
            strcat (buf, "(->)");
        }

        _log(COLLECT__TCP, "Data %s (len %d)", buf, hlf->count_new); // we print the connection parameters
        // (saddr, daddr, sport, dport) accompanied
        // by data flow direction (-> or <-)

        sp->InputBytes((const byte *) hlf->data, hlf->count_new);

        StreamPacketizer::Packet *p;
        while((p = sp->PopPacket()) != NULL) {
            //const PacketHeader *head = (const PacketHeader *) p->data;

            uint32 body_len = p->length;
            const byte *body = p->data;

            _log(COLLECT__RAW_HEX, "Raw Hex Dump of len %d:", body_len);
            _hex(COLLECT__RAW_HEX, body, body_len);

            PyRep *rep = InflateAndUnmarshal(body, body_len);
            if(rep == NULL) {
                printf("Failed to inflate or unmarshal!");
                delete p;
                continue;
            }

            if(is_log_enabled(COLLECT__PYREP_DUMP)) {
                //decode substreams to facilitate dumping better:
                SubStreamDecoder v;
                rep->visit(&v);
                //TODO: make dump use logsys.
                _log(COLLECT__PYREP_DUMP, "Unmarshaled PyRep:");
                PyLookupDump dumper(&CollectDispatcher->lookResolver, COLLECT__PYREP_DUMP);
                rep->visit(&dumper);
            }

            PyPacket *packet = new PyPacket;
            if(!packet->Decode(rep)) {
                _log(COLLECT__ERROR, "Failed to decode packet rep");
            } else {
                if(is_log_enabled(COLLECT__PACKET_DUMP)) {
                    //decode substreams to facilitate dumping better:
                    SubStreamDecoder v;
                    packet->payload->visit(&v);

                    //TODO: make dump use logsys.
                    _log(COLLECT__PACKET_DUMP, "Decoded message:");
                    PyLookupDump dumper(&CollectDispatcher->lookResolver, COLLECT__PACKET_DUMP);
                    packet->Dump(COLLECT__PACKET_DUMP, &dumper);


                    printf("\n\n");
                }
                fflush(stdout);

                CollectDispatcher->DispatchPacket(&packet);
            }
//.........这里部分代码省略.........
开发者ID:valador,项目名称:Evemu,代码行数:101,代码来源:EVEnids.cpp

示例9: Decode

bool PyAddress::Decode(PyRep *&in_object) {
    PyRep *base = in_object;
    in_object = NULL;

    if(!base->IsObject()) {
        codelog(NET__PACKET_ERROR, "Invalid element type, expected object");
        PyDecRef(base);
        return false;
    }

    PyObject *obj = (PyObject *) base;
    //do we care about the object type? should be "macho.MachoAddress"

    if(!obj->arguments()->IsTuple()) {
        codelog(NET__PACKET_ERROR, "Invalid argument type, expected tuple");
        PyDecRef(base);
        return false;
    }

    PyTuple *args = (PyTuple *) obj->arguments();
    if(args->items.size() < 3) {
        codelog(NET__PACKET_ERROR, "Not enough elements in address tuple: %lu", args->items.size());
        args->Dump(NET__PACKET_ERROR, "  ");
        PyDecRef(base);
        return false;
    }

    //decode the address type.
    if(!args->items[0]->IsInt()) {
        codelog(NET__PACKET_ERROR, "Wrong type on address type element (0)");
        args->items[0]->Dump(NET__PACKET_ERROR, "  ");
        PyDecRef(base);
        return false;
    }
    PyInt *typei = (PyInt *) args->items[0];
    switch(typei->value()) {
    case Any: {
        if(args->items.size() != 3) {
            codelog(NET__PACKET_ERROR, "Invalid number of elements in Any address tuple: %lu", args->items.size());
            PyDecRef(base);
            return false;
        }
        type = Any;

        if(!_DecodeService(args->items[1])
        || !_DecodeCallID(args->items[2])) {
            PyDecRef(base);
            return false;
        }

        break;
    }
    case Node: {
        if(args->items.size() != 4) {
            codelog(NET__PACKET_ERROR, "Invalid number of elements in Node address tuple: %lu", args->items.size());
            PyDecRef(base);
            return false;
        }
        type = Node;

        if(!_DecodeTypeID(args->items[1])
        || !_DecodeService(args->items[2])
        || !_DecodeCallID(args->items[3])) {
            PyDecRef(base);
            return false;
        }
        break;
    }
    case Client: {
        if(args->items.size() != 4) {
            codelog(NET__PACKET_ERROR, "Invalid number of elements in Client address tuple: %lu", args->items.size());
            PyDecRef(base);
            return false;
        }
        type = Client;

        if(!_DecodeTypeID(args->items[1])
        || !_DecodeCallID(args->items[2])
        || !_DecodeService(args->items[3])) {
            PyDecRef(base);
            return false;
        }

        break;
    }
    case Broadcast: {
        if(args->items.size() != 4) {
            codelog(NET__PACKET_ERROR, "Invalid number of elements in Broadcast address tuple: %lu", args->items.size());
            PyDecRef(base);
            return false;
        }
        type = Broadcast;

        if(!args->items[1]->IsString()) {
            codelog(NET__PACKET_ERROR, "Invalid type %s for brodcastID", args->items[1]->TypeString());
            PyDecRef(base);
            return false;
        } else if(!args->items[3]->IsString()) {
            codelog(NET__PACKET_ERROR, "Invalid type %s for idtype", args->items[3]->TypeString());
            PyDecRef(base);
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:


注:本文中的PyRep类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。