1 #ifndef _BYTESTREAMBUF_HPP_
2 #define _BYTESTREAMBUF_HPP_
3 
4 /* $Id: bytestreambuf.hpp 535289 2017-05-08 13:38:35Z ivanov $
5 * ===========================================================================
6 *
7 *                            PUBLIC DOMAIN NOTICE
8 *               National Center for Biotechnology Information
9 *
10 *  This software/database is a "United States Government Work" under the
11 *  terms of the United States Copyright Act.  It was written as part of
12 *  the author's official duties as a United States Government employee and
13 *  thus cannot be copyrighted.  This software/database is freely available
14 *  to the public for use. The National Library of Medicine and the U.S.
15 *  Government have not placed any restriction on its use or reproduction.
16 *
17 *  Although all reasonable efforts have been taken to ensure the accuracy
18 *  and reliability of the software and data, the NLM and the U.S.
19 *  Government do not and cannot warrant the performance or results that
20 *  may be obtained by using this software or data. The NLM and the U.S.
21 *  Government disclaim all warranties, express or implied, including
22 *  warranties of performance, merchantability or fitness for any particular
23 *  purpose.
24 *
25 *  Please cite the author in any work or product based on this material.
26 *
27 * ===========================================================================
28 *
29 * File Name:  $Id: bytestreambuf.hpp 535289 2017-05-08 13:38:35Z ivanov $
30 *
31 * Author:  Michael Kholodov
32 *
33 * File Description:  streambuf implementation for BLOBs
34 */
35 
36 #include <dbapi/dbapi.hpp>
37 
38 BEGIN_NCBI_SCOPE
39 
40 class CDB_SendDataCmd;
41 class CResultSet;
42 
43 class CByteStreamBuf : public streambuf
44 {
45 public:
46     CByteStreamBuf(streamsize bufsize, TBlobOStreamFlags flags = 0,
47                    CDB_Connection* conn = NULL);
48     virtual ~CByteStreamBuf();
49 
50     void SetCmd(CDB_SendDataCmd* cmd);
51     void SetRs(CResultSet* rs);
52 
53 protected:
54     virtual streambuf* setbuf(CT_CHAR_TYPE* p, streamsize n);
55     virtual CT_INT_TYPE underflow();
56     virtual streamsize showmanyc();
57 
58     virtual CT_INT_TYPE overflow(CT_INT_TYPE c);
59     virtual int sync();
60 
61 
62 private:
63 
64     CT_CHAR_TYPE* getGBuf();
65     CT_CHAR_TYPE* getPBuf();
66 
67     CT_CHAR_TYPE* m_buf;
68     size_t m_size;
69     //streamsize m_len;
70     CResultSet* m_rs;
71     CDB_SendDataCmd* m_cmd;
72     //int m_column;
73     unique_ptr<CAutoTrans> m_AutoTrans;
74 };
75 
76 END_NCBI_SCOPE
77 //=================================================================
78 #endif // _BYTESTREAMBUF_HPP_
79