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

Go to the SVN repository for this file.

1 /* $Id: asnwrite.cpp 33815 2007-05-04 17:18:18Z kazimird $
2 * ===========================================================================
3 *
4 * PUBLIC DOMAIN NOTICE
5 * National Center for Biotechnology Information
6 *
7 * This software/database is a "United States Government Work" under the
8 * terms of the United States Copyright Act. It was written as part of
9 * the author's official duties as a United States Government employee and
10 * thus cannot be copyrighted. This software/database is freely available
11 * to the public for use. The National Library of Medicine and the U.S.
12 * Government have not placed any restriction on its use or reproduction.
13 *
14 * Although all reasonable efforts have been taken to ensure the accuracy
15 * and reliability of the software and data, the NLM and the U.S.
16 * Government do not and cannot warrant the performance or results that
17 * may be obtained by using this software or data. The NLM and the U.S.
18 * Government disclaim all warranties, express or implied, including
19 * warranties of performance, merchantability or fitness for any particular
20 * purpose.
21 *
22 * Please cite the author in any work or product based on this material.
23 *
24 * ===========================================================================
25 *
26 * Author: Eugene Vasilchenko
27 *
28 * File Description:
29 * !!! PUT YOUR DESCRIPTION HERE !!!
30 */
31 
32 #include <ncbi_pch.hpp>
33 #include <corelib/ncbistd.hpp>
34 #include <ctools/asn/asnwrite.hpp>
35 
37 
38 
40  : m_Out(0), m_Mode(ASNIO_TEXT)
41 {
42 }
43 
45  : m_Out(0), m_Mode(mode)
46 {
47 }
48 
50 {
51  AsnIoClose(m_Out);
52 }
53 
54 
56 {
57  if ( !data || !buffer )
58  return -1;
59 
60  static_cast<CAsnWriteNode*>(data)->AppendPlainText(string(buffer, size));
61  return size;
62 }
63 
64 
65 AsnIoPtr CAsnWriteNode::GetOut(void)
66 {
67  AsnIoPtr out = m_Out;
68  if ( !out ) {
69  out = m_Out = AsnIoNew(m_Mode | ASNIO_OUT, 0, this,
70  0, reinterpret_cast<IoFuncType>(WriteAsn));
71  }
72  return out;
73 }
74 
76 {
77  AsnIoFlush(m_Out);
79  return out;
80 }
81 
static Int2 LIBCALLBACK WriteAsn(Pointer data, CharPtr buffer, Uint2 size)
Definition: asnwrite.cpp:55
~CAsnWriteNode(void)
Definition: asnwrite.cpp:49
CAsnWriteNode(void)
Definition: asnwrite.cpp:39
AsnIoPtr GetOut(void)
Definition: asnwrite.cpp:65
AsnIoPtr m_Out
Definition: asnwrite.hpp:59
virtual CNcbiOstream & PrintChildren(CNcbiOstream &out, TMode mode)
Definition: asnwrite.cpp:75
Include a standard set of the NCBI C++ Toolkit most basic headers.
std::ofstream out("events_result.xml")
main entry point for tests
#define CharPtr
Definition: ncbistd.hpp:125
#define LIBCALLBACK
Definition: ncbistd.hpp:302
#define Pointer
Definition: ncbistd.hpp:114
virtual CNcbiOstream & PrintChildren(CNcbiOstream &out, TMode mode)
Definition: node.cpp:362
int16_t Int2
2-byte (16-bit) signed integer
Definition: ncbitype.h:100
uint16_t Uint2
2-byte (16-bit) unsigned integer
Definition: ncbitype.h:101
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
IO_PREFIX::ostream CNcbiOstream
Portable alias for ostream.
Definition: ncbistre.hpp:149
mdb_mode_t mode
Definition: lmdb++.h:38
const struct ncbi::grid::netcache::search::fields::SIZE size
static pcre_uint8 * buffer
Definition: pcretest.c:1051
Modified on Sat Dec 02 09:20:32 2023 by modify_doxy.py rev. 669887