NCBI C++ ToolKit
hooks_write_member.cpp
Go to the documentation of this file.

Go to the SVN repository for this file.

00001 #include <ncbi_pch.hpp>
00002 #include <objects/biblio/Auth_list.hpp>
00003 #include <objects/biblio/Cit_art.hpp>
00004 #include <serial/objectio.hpp>
00005 #include <serial/objistr.hpp>
00006 #include <serial/objostr.hpp>
00007 #include <serial/serial.hpp>
00008 
00009 USING_NCBI_SCOPE;
00010 USING_SCOPE(ncbi::objects);
00011 
00012 class CDemoHook : public CWriteClassMemberHook
00013 {
00014 public:
00015     virtual void WriteClassMember(CObjectOStream& out,
00016                                   const CConstObjectInfoMI& passed_info)
00017     {
00018         DefaultWrite(out, passed_info);
00019     }
00020 };
00021 
00022 int main(int argc, char** argv)
00023 {
00024     auto_ptr<CObjectIStream> in(CObjectIStream::Open(eSerial_AsnText, "if"));
00025     auto_ptr<CObjectOStream> out(CObjectOStream::Open(eSerial_AsnText, "of"));
00026 
00027     CObjectTypeInfo(CType<CAuth_list>())
00028         .FindMember("names")
00029         .SetLocalWriteHook(*out, new CDemoHook);
00030 
00031     CCit_art article;
00032     *in >> article;
00033     *out << article;
00034 
00035     return 0;
00036 }
Modified on Tue Jul 22 17:51:34 2014 by modify_doxy.py rev. 426318