Пример #1
0
    // Implement the hook method.
    //
    // Once the read hook has been set, ReadClassMember() will be called
    // whenever the specified class member is encountered while
    // reading a hooked input stream.  Without the hook, the encountered
    // class member would have been automatically read.  With the hook, it is
    // now the responsibility of the ReadClassMember() method to remove the
    // class member from the input stream and process it as desired.  It can
    // either read it or skip it to remove it from the stream.  This is
    // easily done by calling DefaultRead() or DefaultSkip() from within
    // ReadClassMember().  Subsequent processing is up to the application.
    virtual void ReadClassMember(CObjectIStream& in,
                                 const CObjectInfoMI& passed_info)
    {
        // Perform any pre-read processing here.
        //NcbiCout << "In ReadClassMember() hook, before reading." << NcbiEndl;

        // You must call DefaultRead() (or perform an equivalent operation)
        // if you want the object to be read into memory.  You could also
        // call DefaultSkip() if you wanted to skip the hooked object while
        // reading everything else.
        DefaultRead(in, passed_info);

#if 0
// call DefaultRead to read member data, or DefaultSkip to skip it
        DefaultSkip(in, passed_info);

// get information about the member
        // typeinfo of the parent class
        CObjectTypeInfo oti = passed_info.GetClassType();
        // typeinfo and data of the parent class
        const CObjectInfo& oi = passed_info.GetClassObject();
        // typeinfo of the member
        CObjectTypeInfo omti = passed_info.GetMemberType();
        // typeinfo and data of the member
        CObjectInfo om = passed_info.GetMember();
        // index of the member in parent class
        TMemberIndex mi = passed_info.GetMemberIndex();
        // information about the member, including its name
        const CMemberInfo* minfo = passed_info.GetMemberInfo();
#endif

        // Perform any post-read processing here.  Once the object has been
        // read, its data can be used for processing.
        CNcbiOstrstream oss;
        oss << MSerial_AsnText << passed_info.GetClassObject();
        string s = CNcbiOstrstreamToString(oss);
        NcbiCout << s << NcbiEndl;
    }
Пример #2
0
void CReadClassMemberHook::ReadMissingClassMember(CObjectIStream& in,
                                                  const CObjectInfoMI& member)
{
    member.GetMemberInfo()->
        DefaultReadMissingMember(in, member.GetClassObject().GetObjectPtr());
}