1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef CSV_BSTREAM_HXX
21 #define CSV_BSTREAM_HXX
24 #include <cosv/string.hxx>
43 virtual ~bistream() {}
46 /// @return Number of actually read bytes.
51 /** @return True, if already one try to read had failed.
52 There is no guarantee, that it returns true, if end of data
54 Though it will return false, if there is still somemething
60 virtual uintt
do_read(
62 uintt i_nNrofBytes
) = 0;
63 virtual bool inq_eod() const = 0;
71 virtual ~bostream() {}
74 /// @return Number of actually written bytes.
78 /// @return Number of actually written bytes.
80 const char * i_pSrc
);
81 /// @return Number of actually written bytes.
83 const String
& i_pSrc
);
85 virtual uintt
do_write(
87 uintt i_nNrofBytes
) = 0;
91 class bstream
: public bistream
,
96 intt i_nDistanceFromBegin
,
97 seek_dir i_eStartPoint
= ::csv::beg
);
98 uintt
position() const;
101 virtual uintt
do_seek(
103 seek_dir i_eStartPoint
= ::csv::beg
) = 0;
104 virtual uintt
inq_position() const = 0;
110 bistream::read( void * o_pDest
,
112 { return do_read(o_pDest
, i_nNrofBytes
); }
114 bistream::eod() const
115 { return inq_eod(); }
118 bostream::write( const void * i_pSrc
,
120 { return do_write( i_pSrc
, i_nNrofBytes
); }
122 bostream::write( const char * i_sSrc
)
123 { return write( i_sSrc
, strlen(i_sSrc
) ); }
125 bostream::write( const String
& i_sSrc
)
126 { return write( i_sSrc
.c_str(), i_sSrc
.length() ); }
129 bstream::seek( intt i_nDistance
,
130 seek_dir i_eStartPoint
)
131 { return do_seek( i_nDistance
, i_eStartPoint
); }
133 bstream::position() const
134 { return inq_position(); }
143 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */