| 1 | #cxx . . $ `<file>/melder/abcio.h`/ifndef _abcio_h_ |
| 2 | #define _abcio_h_cxx . . $ `melder/abcio.h:2:9`! |
| 3 | /* abcio.h |
| 4 | * |
| 5 | * Copyright (C) 1992-2011,2015,2017-2020,2022,2024 Paul Boersma |
| 6 | * |
| 7 | * This code is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by |
| 9 | * the Free Software Foundation; either version 2 of the License, or (at |
| 10 | * your option) any later version. |
| 11 | * |
| 12 | * This code is distributed in the hope that it will be useful, but |
| 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 15 | * See the GNU General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License |
| 18 | * along with this work. If not, see <http://www.gnu.org/licenses/>. |
| 19 | */ |
| 20 | |
| 21 | /* Numeric text input and output. */ |
| 22 | |
| 23 | int texgeti8cxx . . $ texgeti8(2ccfb320b77fcecd). (MelderReadTextcxx . . $ MelderReadText# text); |
| 24 | int16cxx . . $ int16# texgeti16cxx . . $ texgeti16(df2c8a7d80e92f0e). (MelderReadTextcxx . . $ MelderReadText# text); |
| 25 | int32cxx . . $ int32# texgeti32cxx . . $ texgeti32(2ccfb320b77fcecd). (MelderReadTextcxx . . $ MelderReadText# text); |
| 26 | integercxx . . $ integer# texgetintegercxx . . $ texgetinteger(c4cc05fb41712971). (MelderReadTextcxx . . $ MelderReadText# text); |
| 27 | #define texgetinteger16BEcxx . . $ `melder/abcio.h:27:9`! texgetinteger |
| 28 | #define texgetinteger32BEcxx . . $ `melder/abcio.h:28:9`! texgetinteger |
| 29 | unsigned int texgetu8cxx . . $ texgetu8(275f9a74c1f6a9e1). (MelderReadTextcxx . . $ MelderReadText# text); |
| 30 | uint16cxx . . $ uint16# texgetu16cxx . . $ texgetu16(704c7e169c71fecc). (MelderReadTextcxx . . $ MelderReadText# text); |
| 31 | uint32cxx . . $ uint32# texgetu32cxx . . $ texgetu32(275f9a74c1f6a9e1). (MelderReadTextcxx . . $ MelderReadText# text); |
| 32 | double texgetr32cxx . . $ texgetr32(8233d77bc64f583c). (MelderReadTextcxx . . $ MelderReadText# text); |
| 33 | double texgetr64cxx . . $ texgetr64(8233d77bc64f583c). (MelderReadTextcxx . . $ MelderReadText# text); |
| 34 | double texgetr80cxx . . $ texgetr80(8233d77bc64f583c). (MelderReadTextcxx . . $ MelderReadText# text); |
| 35 | dcomplexcxx . . $ dcomplex# texgetc64cxx . . $ texgetc64(973f5e238341d394). (MelderReadTextcxx . . $ MelderReadText# text); |
| 36 | dcomplexcxx . . $ dcomplex# texgetc128cxx . . $ texgetc128(973f5e238341d394). (MelderReadTextcxx . . $ MelderReadText# text); |
| 37 | int texgete8cxx . . $ texgete8(5d13c7fbeaf5c6ca). (MelderReadTextcxx . . $ MelderReadText# text, enum_generic_getValuecxx . . $ enum_generic_getValue# getValue); |
| 38 | int texgete16cxx . . $ texgete16(5d13c7fbeaf5c6ca). (MelderReadTextcxx . . $ MelderReadText# text, enum_generic_getValuecxx . . $ enum_generic_getValue# getValue); |
| 39 | bool texgetebcxx . . $ texgeteb(38d4372a0347f2a3). (MelderReadTextcxx . . $ MelderReadText# text); |
| 40 | bool texgeteqcxx . . $ texgeteq(38d4372a0347f2a3). (MelderReadTextcxx . . $ MelderReadText# text); |
| 41 | bool texgetexcxx . . $ texgetex(38d4372a0347f2a3). (MelderReadTextcxx . . $ MelderReadText# text); |
| 42 | autostring32cxx . . $ autostring32# texgetw16cxx . . $ texgetw16(6d8daa32ac6455b9). (MelderReadTextcxx . . $ MelderReadText# text); |
| 43 | autostring32cxx . . $ autostring32# texgetw32cxx . . $ texgetw32(6d8daa32ac6455b9). (MelderReadTextcxx . . $ MelderReadText# text); |
| 44 | |
| 45 | void texindentcxx . . $ texindent(1145552d769d7b5d). (MelderFilecxx . . $ MelderFile# file); |
| 46 | void texexdentcxx . . $ texexdent(1145552d769d7b5d). (MelderFilecxx . . $ MelderFile# file); |
| 47 | void texresetindentcxx . . $ texresetindent(1145552d769d7b5d). (MelderFilecxx . . $ MelderFile# file); |
| 48 | |
| 49 | #define texput_UP_TO_NINE_NULLABLE_STRINGScxx . . $ `melder/abcio.h:49:9`! \ |
| 50 | conststring32 s1 = nullptr, conststring32 s2 = nullptr, conststring32 s3 = nullptr, \ |
| 51 | conststring32 s4 = nullptr, conststring32 s5 = nullptr, conststring32 s6 = nullptr, \ |
| 52 | conststring32 s7 = nullptr, conststring32 s8 = nullptr, conststring32 s9 = nullptr |
| 53 | void texputintrocxx . . $ texputintro(ca2e4f9dca357a80). (MelderFilecxx . . $ MelderFile# file, texput_UP_TO_NINE_NULLABLE_STRINGScxx . . $ `melder/abcio.h:49:9`!); |
| 54 | void texputi8cxx . . $ texputi8(79cf16150f57996b). (MelderFilecxx . . $ MelderFile# file, int i, texput_UP_TO_NINE_NULLABLE_STRINGScxx . . $ `melder/abcio.h:49:9`!); |
| 55 | void texputi16cxx . . $ texputi16(79cf16150f57996b). (MelderFilecxx . . $ MelderFile# file, int i, texput_UP_TO_NINE_NULLABLE_STRINGScxx . . $ `melder/abcio.h:49:9`!); |
| 56 | void texputi32cxx . . $ texputi32(7d66e869d177be0). (MelderFilecxx . . $ MelderFile# file, long i, texput_UP_TO_NINE_NULLABLE_STRINGScxx . . $ `melder/abcio.h:49:9`!); |
| 57 | void texputintegercxx . . $ texputinteger(7d66e869d177be0). (MelderFilecxx . . $ MelderFile# file, integercxx . . $ integer# i, texput_UP_TO_NINE_NULLABLE_STRINGScxx . . $ `melder/abcio.h:49:9`!); |
| 58 | #define texputinteger16BEcxx . . $ `melder/abcio.h:58:9`! texputinteger |
| 59 | #define texputinteger32BEcxx . . $ `melder/abcio.h:59:9`! texputinteger |
| 60 | void texputu8cxx . . $ texputu8(16a828011950446e). (MelderFilecxx . . $ MelderFile# file, unsigned int u, texput_UP_TO_NINE_NULLABLE_STRINGScxx . . $ `melder/abcio.h:49:9`!); |
| 61 | void texputu16cxx . . $ texputu16(16a828011950446e). (MelderFilecxx . . $ MelderFile# file, unsigned int u, texput_UP_TO_NINE_NULLABLE_STRINGScxx . . $ `melder/abcio.h:49:9`!); |
| 62 | void texputu32cxx . . $ texputu32(4e03ad187d1582a7). (MelderFilecxx . . $ MelderFile# file, unsigned long u, texput_UP_TO_NINE_NULLABLE_STRINGScxx . . $ `melder/abcio.h:49:9`!); |
| 63 | void texputr32cxx . . $ texputr32(e74c4a2aaf5f7438). (MelderFilecxx . . $ MelderFile# file, double x, texput_UP_TO_NINE_NULLABLE_STRINGScxx . . $ `melder/abcio.h:49:9`!); |
| 64 | void texputr64cxx . . $ texputr64(e74c4a2aaf5f7438). (MelderFilecxx . . $ MelderFile# file, double x, texput_UP_TO_NINE_NULLABLE_STRINGScxx . . $ `melder/abcio.h:49:9`!); |
| 65 | void texputc64cxx . . $ texputc64(345afc904cfef26b). (MelderFilecxx . . $ MelderFile# file, dcomplexcxx . . $ dcomplex# z, texput_UP_TO_NINE_NULLABLE_STRINGScxx . . $ `melder/abcio.h:49:9`!); |
| 66 | void texputc128cxx . . $ texputc128(345afc904cfef26b). (MelderFilecxx . . $ MelderFile# file, dcomplexcxx . . $ dcomplex# z, texput_UP_TO_NINE_NULLABLE_STRINGScxx . . $ `melder/abcio.h:49:9`!); |
| 67 | void texpute8cxx . . $ texpute8(ec74f58c867c0215). (MelderFilecxx . . $ MelderFile# file, int i, conststring32cxx . . $ conststring32# (*getText) (int), texput_UP_TO_NINE_NULLABLE_STRINGScxx . . $ `melder/abcio.h:49:9`!); |
| 68 | void texpute16cxx . . $ texpute16(ec74f58c867c0215). (MelderFilecxx . . $ MelderFile# file, int i, conststring32cxx . . $ conststring32# (*getText) (int), texput_UP_TO_NINE_NULLABLE_STRINGScxx . . $ `melder/abcio.h:49:9`!); |
| 69 | void texputebcxx . . $ texputeb(df7eef0320334cb9). (MelderFilecxx . . $ MelderFile# file, bool i, texput_UP_TO_NINE_NULLABLE_STRINGScxx . . $ `melder/abcio.h:49:9`!); |
| 70 | void texputeqcxx . . $ texputeq(df7eef0320334cb9). (MelderFilecxx . . $ MelderFile# file, bool i, texput_UP_TO_NINE_NULLABLE_STRINGScxx . . $ `melder/abcio.h:49:9`!); |
| 71 | void texputexcxx . . $ texputex(df7eef0320334cb9). (MelderFilecxx . . $ MelderFile# file, bool i, texput_UP_TO_NINE_NULLABLE_STRINGScxx . . $ `melder/abcio.h:49:9`!); |
| 72 | void texputs8cxx . . $ texputs8(65c6b20d12993863). (MelderFilecxx . . $ MelderFile# file, conststring8cxx . . $ conststring8# s, texput_UP_TO_NINE_NULLABLE_STRINGScxx . . $ `melder/abcio.h:49:9`!); |
| 73 | void texputs16cxx . . $ texputs16(65c6b20d12993863). (MelderFilecxx . . $ MelderFile# file, conststring8cxx . . $ conststring8# s, texput_UP_TO_NINE_NULLABLE_STRINGScxx . . $ `melder/abcio.h:49:9`!); |
| 74 | void texputs32cxx . . $ texputs32(65c6b20d12993863). (MelderFilecxx . . $ MelderFile# file, conststring8cxx . . $ conststring8# s, texput_UP_TO_NINE_NULLABLE_STRINGScxx . . $ `melder/abcio.h:49:9`!); |
| 75 | void texputw16cxx . . $ texputw16(44d267b8842e4934). (MelderFilecxx . . $ MelderFile# file, conststring32cxx . . $ conststring32# s, texput_UP_TO_NINE_NULLABLE_STRINGScxx . . $ `melder/abcio.h:49:9`!); |
| 76 | void texputw32cxx . . $ texputw32(44d267b8842e4934). (MelderFilecxx . . $ MelderFile# file, conststring32cxx . . $ conststring32# s, texput_UP_TO_NINE_NULLABLE_STRINGScxx . . $ `melder/abcio.h:49:9`!); |
| 77 | #undef texput_UP_TO_NINE_NULLABLE_STRINGScxx . . $ `melder/abcio.h:49:9`! |
| 78 | |
| 79 | /* Portable device-independent binary input and output. */ |
| 80 | /* Works on all machines with 8-bit bytes and chars, and 2's complement integers. */ |
| 81 | /* Works independent of byte order or floating-point implementations. */ |
| 82 | /* |
| 83 | The 42 routines are analogous to fgetc and fputc, who read or write one character: |
| 84 | int fgetc (FILE *f); int fputc (int c, FILE *f); // 0..255 |
| 85 | */ |
| 86 | uint32cxx . . $ uint32# bingetu8cxx . . $ bingetu8(9eef1996c458a0e7). (FILE *f); void binputu8cxx . . $ binputu8(60af6e60da050086). (uint32cxx . . $ uint32# i, FILE *f); // 0..255 |
| 87 | uint16cxx . . $ uint16# bingetu16cxx . . $ bingetu16(38a7f6633dfbdb53). (FILE *f); void binputu16cxx . . $ binputu16(d4e8792de0db7e67). (uint16cxx . . $ uint16# i, FILE *f); // 0..65535 |
| 88 | uint32cxx . . $ uint32# bingetu32cxx . . $ bingetu32(9eef1996c458a0e7). (FILE *f); void binputu32cxx . . $ binputu32(60af6e60da050086). (uint32cxx . . $ uint32# i, FILE *f); // 0..4294967295 |
| 89 | |
| 90 | int32cxx . . $ int32# bingeti8cxx . . $ bingeti8(89bc1efcdac0ca22). (FILE *f); void binputi8cxx . . $ binputi8(44487f0f82292376). (int32cxx . . $ int32# i, FILE *f); /* -128..127 */ |
| 91 | int16cxx . . $ int16# bingeti16cxx . . $ bingeti16(2dcfca5714bad490). (FILE *f); void binputi16cxx . . $ binputi16(e1ff1cfdb53a1865). (int16cxx . . $ int16# i, FILE *f); // -32768..32767 |
| 92 | int32cxx . . $ int32# bingeti24cxx . . $ bingeti24(89bc1efcdac0ca22). (FILE *f); void binputi24cxx . . $ binputi24(44487f0f82292376). (int32cxx . . $ int32# i, FILE *f); // -8388608..8388607 |
| 93 | int32cxx . . $ int32# bingeti32cxx . . $ bingeti32(89bc1efcdac0ca22). (FILE *f); void binputi32cxx . . $ binputi32(44487f0f82292376). (int32cxx . . $ int32# i, FILE *f); // -2147483648..2147483647 |
| 94 | integercxx . . $ integer# bingetinteger32BEcxx . . $ bingetinteger32BE(1dcafcd8ef4c6e6c). (FILE *f); void binputinteger32BEcxx . . $ binputinteger32BE(791c91cccf3dbd31). (integercxx . . $ integer# i, FILE *f); |
| 95 | integercxx . . $ integer# bingetinteger16BEcxx . . $ bingetinteger16BE(1dcafcd8ef4c6e6c). (FILE *f); void binputinteger16BEcxx . . $ binputinteger16BE(791c91cccf3dbd31). (integercxx . . $ integer# i, FILE *f); |
| 96 | /* |
| 97 | Read or write signed or unsigned integers from or to 2 or 4 bytes in the stream 'f', |
| 98 | in big-endian byte order (most significant byte first). |
| 99 | This is the native integer format on Macintosh and Silicon Graphics Iris. |
| 100 | */ |
| 101 | |
| 102 | int16cxx . . $ int16# bingeti16LEcxx . . $ bingeti16LE(2dcfca5714bad490). (FILE *f); void binputi16LEcxx . . $ binputi16LE(e1ff1cfdb53a1865). (int16cxx . . $ int16# i, FILE *f); // -32768..32767 |
| 103 | int32cxx . . $ int32# bingeti24LEcxx . . $ bingeti24LE(89bc1efcdac0ca22). (FILE *f); void binputi24LEcxx . . $ binputi24LE(44487f0f82292376). (int32cxx . . $ int32# i, FILE *f); // -8388608..8388607 |
| 104 | int32cxx . . $ int32# bingeti32LEcxx . . $ bingeti32LE(89bc1efcdac0ca22). (FILE *f); void binputi32LEcxx . . $ binputi32LE(44487f0f82292376). (int32cxx . . $ int32# i, FILE *f); // -2147483648..2147483647 |
| 105 | uint16cxx . . $ uint16# bingetu16LEcxx . . $ bingetu16LE(38a7f6633dfbdb53). (FILE *f); void binputu16LEcxx . . $ binputu16LE(d4e8792de0db7e67). (uint16cxx . . $ uint16# i, FILE *f); // 0..65535 |
| 106 | uint32cxx . . $ uint32# bingetu32LEcxx . . $ bingetu32LE(9eef1996c458a0e7). (FILE *f); void binputu32LEcxx . . $ binputu32LE(60af6e60da050086). (uint32cxx . . $ uint32# i, FILE *f); // 0..4294967295 |
| 107 | /* |
| 108 | Read or write signed or unsigned integers from or to 2 or 4 bytes in the stream 'f', |
| 109 | in little-endian byte order (least significant byte first). |
| 110 | This is the native integer format on Vax and IBM PC. |
| 111 | */ |
| 112 | |
| 113 | int bingete8cxx . . $ bingete8(fe4021e40d52d7a9). (FILE *f, int min, int max, conststring32cxx . . $ conststring32# type); |
| 114 | int bingete16cxx . . $ bingete16(fe4021e40d52d7a9). (FILE *f, int min, int max, conststring32cxx . . $ conststring32# type); |
| 115 | bool bingetbool8cxx . . $ bingetbool8(dc9e5a301483124c). (FILE *f); |
| 116 | #define bingetebcxx . . $ `melder/abcio.h:116:9`! bingetbool8 |
| 117 | #define bingeteqcxx . . $ `melder/abcio.h:117:9`! bingetbool8 |
| 118 | #define bingetexcxx . . $ `melder/abcio.h:118:9`! bingetbool8 |
| 119 | |
| 120 | void binpute8cxx . . $ binpute8(44487f0f82292376). (int value, FILE *f); |
| 121 | void binpute16cxx . . $ binpute16(44487f0f82292376). (int value, FILE *f); |
| 122 | void binputbool8cxx . . $ binputbool8(d129c1ec250bee9e). (bool value, FILE *f); |
| 123 | #define binputebcxx . . $ `melder/abcio.h:123:9`! binputbool8 |
| 124 | #define binputeqcxx . . $ `melder/abcio.h:124:9`! binputbool8 |
| 125 | #define binputexcxx . . $ `melder/abcio.h:125:9`! binputbool8 |
| 126 | |
| 127 | double bingetr32cxx . . $ bingetr32(aa8fd5995df79f3e). (FILE *f); void binputr32cxx . . $ binputr32(e2d746ffb56c4827). (double x, FILE *f); |
| 128 | /* |
| 129 | Read or write a real number from or to 4 bytes in the stream `f`, |
| 130 | in IEEE single-precision binary real format, with the most significant bit first. |
| 131 | NaN's (Not-a-Numbers) and infinities get the value HUGE, which equals infinity on IEEE machines. |
| 132 | Absolute values of normalized numbers (23 bits precision): 1.2e-38 .. 3.4e38. |
| 133 | Denormalized: from 1.4e-45. |
| 134 | This is the native format of a `float` on Macintosh and Silicon Graphics Iris. |
| 135 | */ |
| 136 | double bingetr32LEcxx . . $ bingetr32LE(aa8fd5995df79f3e). (FILE *f); void binputr32LEcxx . . $ binputr32LE(e2d746ffb56c4827). (double x, FILE *f); // least significant bit first |
| 137 | |
| 138 | double bingetr64cxx . . $ bingetr64(aa8fd5995df79f3e). (FILE *f); void binputr64cxx . . $ binputr64(e2d746ffb56c4827). (double x, FILE *f); |
| 139 | /* |
| 140 | Read or write a real number from or to 8 bytes in the stream `f`, |
| 141 | in IEEE double-precision binary real format, with the most significant bit first. |
| 142 | NaN's (Not-a-Numbers) and infinities get the value HUGE, which equals infinity on IEEE machines. |
| 143 | Absolute values of normalized numbers (52 bits precision): 2.2e-308 .. 1.8e308. |
| 144 | Denormalized: from 4.9e-324. |
| 145 | This is the native format of a `double` on Silicon Graphics Iris and PowerMac. |
| 146 | */ |
| 147 | double bingetr64LEcxx . . $ bingetr64LE(aa8fd5995df79f3e). (FILE *f); void binputr64LEcxx . . $ binputr64LE(e2d746ffb56c4827). (double x, FILE *f); // least significant bit first |
| 148 | |
| 149 | double bingetr80cxx . . $ bingetr80(aa8fd5995df79f3e). (FILE *f); void binputr80cxx . . $ binputr80(e2d746ffb56c4827). (double x, FILE *f); |
| 150 | /* |
| 151 | Read or write a real number from or to 10 bytes in the stream `f`, |
| 152 | in IEEE extended-precision binary real format, with the most significant bit first, |
| 153 | as implemented in Motorola's MC68881 floating-point coprocessor. |
| 154 | NaN's (Not-a-Numbers) and infinities get the value HUGE, which equals infinity on IEEE machines. |
| 155 | Absolute values of normalized numbers (63 bits precision): 8e-4933 .. 6e4931. |
| 156 | Denormalized: from 9e-4952. |
| 157 | This format is used to encode the sampling rate in AIFF (Audio Interchange File Format) files, |
| 158 | and is the native format of a `double` on 68k Macintosh. |
| 159 | */ |
| 160 | |
| 161 | dcomplexcxx . . $ dcomplex# bingetc64cxx . . $ bingetc64(24e0806e0c5ce92). (FILE *f); |
| 162 | dcomplexcxx . . $ dcomplex# bingetc128cxx . . $ bingetc128(24e0806e0c5ce92). (FILE *f); |
| 163 | void binputc64cxx . . $ binputc64(61b44fec29a2c39b). (dcomplexcxx . . $ dcomplex# z, FILE *f); |
| 164 | void binputc128cxx . . $ binputc128(61b44fec29a2c39b). (dcomplexcxx . . $ dcomplex# z, FILE *f); |
| 165 | |
| 166 | autostring8cxx . . $ autostring8# bingets8cxx . . $ bingets8(5a336ef3276fb3b5). (FILE *f); void binputs8cxx . . $ binputs8(949c37aeb559641). (const char *s, FILE *f); // 0..255 characters |
| 167 | autostring8cxx . . $ autostring8# bingets16cxx . . $ bingets16(5a336ef3276fb3b5). (FILE *f); void binputs16cxx . . $ binputs16(949c37aeb559641). (const char *s, FILE *f); // 0..65535 characters |
| 168 | autostring8cxx . . $ autostring8# bingets32cxx . . $ bingets32(5a336ef3276fb3b5). (FILE *f); void binputs32cxx . . $ binputs32(949c37aeb559641). (const char *s, FILE *f); // 0..4294967295 characters |
| 169 | /* |
| 170 | Read or write a string from or to `Melder_length(s)` UTF-16LE or ASCII characters |
| 171 | plus 1, 2, or 4 bytes in the stream `f`, in a Pascal-style format: |
| 172 | first the length, then the characters, without a trailing null byte. |
| 173 | bingetsxxx returns a new 'malloc'ed null-terminated C string (for the caller to `free` it). |
| 174 | Fail if out of memory. |
| 175 | binputsxxx expects a null-terminated C string whose `Melder_length` fits in 1, 2, or 4 bytes. |
| 176 | */ |
| 177 | autostring32cxx . . $ autostring32# bingetw8cxx . . $ bingetw8(6856a237bc2beebc). (FILE *f); void binputw8cxx . . $ binputw8(43ad66ee48fe33fd). (conststring32cxx . . $ conststring32# s, FILE *f); |
| 178 | autostring32cxx . . $ autostring32# bingetw16cxx . . $ bingetw16(6856a237bc2beebc). (FILE *f); void binputw16cxx . . $ binputw16(43ad66ee48fe33fd). (conststring32cxx . . $ conststring32# s, FILE *f); |
| 179 | autostring32cxx . . $ autostring32# bingetw32cxx . . $ bingetw32(6856a237bc2beebc). (FILE *f); void binputw32cxx . . $ binputw32(43ad66ee48fe33fd). (conststring32cxx . . $ conststring32# s, FILE *f); |
| 180 | |
| 181 | /* End of file abcio.h */ |
| 182 | #endif |