Mercurial > octave
annotate libinterp/corefcn/oct-prcstrm.h @ 26703:29ea2369971d
Add basic backend for encodings in file streams (bug #55452).
* oct-stream.h (base_stream): Store encoding in class.
* oct-stream.cc (do_scanf_conv): Convert strings from encoding.
(do_printf_string): Convert strings to encoding.
(base_stream::printf): Convert format string to encoding.
* oct-stdstrm.h (octave_stdiostream, octave_tstdiostream, octave_zstdiostream,
create): Pass encoding through to base_stream.
* oct-prcstrm.[cc,h] (octave_iprocstream, octave_oprocstream, create): Pass
encoding through to octave_stdiostream.
* oct-strstrm.[cc,h] (octave_istrstream, octave_ostrstream, create): Pass
encoding through to base_stream.
author | Markus Mützel <markus.muetzel@gmx.de> |
---|---|
date | Sat, 09 Feb 2019 16:43:11 +0100 |
parents | 00f796120a6d |
children | b442ec6dda5c |
rev | line source |
---|---|
2081 | 1 /* |
2 | |
26376
00f796120a6d
maint: Update copyright dates in all source files.
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
3 Copyright (C) 1996-2019 John W. Eaton |
2081 | 4 |
5 This file is part of Octave. | |
6 | |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
7 Octave is free software: you can redistribute it and/or modify it |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
8 under the terms of the GNU General Public License as published by |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
9 the Free Software Foundation, either version 3 of the License, or |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
10 (at your option) any later version. |
2081 | 11 |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
12 Octave is distributed in the hope that it will be useful, but |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
13 WITHOUT ANY WARRANTY; without even the implied warranty of |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
15 GNU General Public License for more details. |
2081 | 16 |
17 You should have received a copy of the GNU General Public License | |
7016 | 18 along with Octave; see the file COPYING. If not, see |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
19 <https://www.gnu.org/licenses/>. |
2081 | 20 |
21 */ | |
22 | |
20791
f7084eae3318
maint: Use Octave coding conventions for #if statements.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
23 #if ! defined (octave_oct_prcstrm_h) |
17822
ebb3ef964372
maint: Use common #define syntax "octave_filename_h" in h_files.
Rik <rik@octave.org>
parents:
17787
diff
changeset
|
24 #define octave_oct_prcstrm_h 1 |
2081 | 25 |
21244
1473547f50f5
include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
26 #include "octave-config.h" |
1473547f50f5
include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
27 |
2081 | 28 #include "oct-stdstrm.h" |
29 | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
30 // FIXME: why don't these classes use iprocstream and oprocstream, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
31 // which in turn use the octave_procbuf class? |
3652 | 32 |
2081 | 33 class |
4327 | 34 octave_iprocstream : public octave_stdiostream |
2081 | 35 { |
36 public: | |
37 | |
3523 | 38 octave_iprocstream (const std::string& n, |
10313 | 39 std::ios::openmode arg_md = std::ios::in, |
21739
c4ab2e54f100
use namespace for oct_mach_info class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
40 octave::mach_info::float_format flt_fmt |
26703
29ea2369971d
Add basic backend for encodings in file streams (bug #55452).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26376
diff
changeset
|
41 = octave::mach_info::native_float_format (), |
29ea2369971d
Add basic backend for encodings in file streams (bug #55452).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26376
diff
changeset
|
42 const std::string& encoding = "utf-8"); |
2081 | 43 |
22869
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
44 // No copying! |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
45 |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
46 octave_iprocstream (const octave_iprocstream&) = delete; |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
47 |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
48 octave_iprocstream& operator = (const octave_iprocstream&) = delete; |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
49 |
23059
b98ebcd7f11c
move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
50 static octave::stream |
3544 | 51 create (const std::string& n, std::ios::openmode arg_md = std::ios::in, |
21739
c4ab2e54f100
use namespace for oct_mach_info class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
52 octave::mach_info::float_format flt_fmt |
26703
29ea2369971d
Add basic backend for encodings in file streams (bug #55452).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26376
diff
changeset
|
53 = octave::mach_info::native_float_format (), |
29ea2369971d
Add basic backend for encodings in file streams (bug #55452).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26376
diff
changeset
|
54 const std::string& encoding = "utf-8"); |
3340 | 55 |
56 protected: | |
57 | |
2081 | 58 ~octave_iprocstream (void); |
59 }; | |
60 | |
61 class | |
4327 | 62 octave_oprocstream : public octave_stdiostream |
2081 | 63 { |
64 public: | |
65 | |
3523 | 66 octave_oprocstream (const std::string& n, |
10313 | 67 std::ios::openmode arg_md = std::ios::out, |
21739
c4ab2e54f100
use namespace for oct_mach_info class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
68 octave::mach_info::float_format flt_fmt |
26703
29ea2369971d
Add basic backend for encodings in file streams (bug #55452).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26376
diff
changeset
|
69 = octave::mach_info::native_float_format (), |
29ea2369971d
Add basic backend for encodings in file streams (bug #55452).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26376
diff
changeset
|
70 const std::string& encoding = "utf-8"); |
2081 | 71 |
22869
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
72 // No copying! |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
73 |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
74 octave_oprocstream (const octave_oprocstream&) = delete; |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
75 |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
76 octave_oprocstream& operator = (const octave_oprocstream&) = delete; |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
77 |
23059
b98ebcd7f11c
move some octave stream classes into octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
78 static octave::stream |
3544 | 79 create (const std::string& n, std::ios::openmode arg_md = std::ios::out, |
21739
c4ab2e54f100
use namespace for oct_mach_info class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
80 octave::mach_info::float_format flt_fmt |
26703
29ea2369971d
Add basic backend for encodings in file streams (bug #55452).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26376
diff
changeset
|
81 = octave::mach_info::native_float_format (), |
29ea2369971d
Add basic backend for encodings in file streams (bug #55452).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26376
diff
changeset
|
82 const std::string& encoding = "utf-8"); |
3340 | 83 |
84 protected: | |
85 | |
2081 | 86 ~octave_oprocstream (void); |
87 }; | |
88 | |
89 #endif |