Debian Codegraph @

native/common/include/jp_encoding.h

raw symbols SCIP
1 /*****************************************************************************
2 Licensed under the Apache License, Version 2.0 (the "License");
3 you may not use this file except in compliance with the License.
4 You may obtain a copy of the License at
5
6 http://www.apache.org/licenses/LICENSE-2.0
7
8 Unless required by applicable law or agreed to in writing, software
9 distributed under the License is distributed on an "AS IS" BASIS,
10 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 See the License for the specific language governing permissions and
12 limitations under the License.
13
14 See NOTICE file for details.
15 *****************************************************************************/
16 #ifndef _JP_ENCODING_H_
17 #define _JP_ENCODING_H_
18
19 #include <iostream>
20 #include <string>
21 #include <sstream>
22
23 class JPEncoding
24 {
25 public:
26
27 JPEncoding()
28 = default;
29 virtual ~JPEncoding();
30
31 /** Store a code point in an outgoing buffer. */
32 virtual void encode(std::ostream& out, unsigned int codePoint) const = 0;
33
34 /** Retrieve a coding point from an incoming buffer. */
35 virtual unsigned int fetch(std::istream& is) const = 0;
36 } ;
37
38 class JPEncodingUTF8 : public JPEncoding
39 {
40 public:
41 /** Store a code point in an outgoing buffer. */
42 void encode(std::ostream& out, unsigned int codePoint) const override;
43
44 /** Retrieve a coding point from an incoming buffer. */
45 unsigned int fetch(std::istream& is) const override;
46 } ;
47
48 class JPEncodingJavaUTF8 : public JPEncoding
49 {
50 public:
51 /** Store a code point in an outgoing buffer. */
52 void encode(std::ostream& out, unsigned int codePoint) const override;
53
54 /** Retrieve a coding point from an incoming buffer.
55 * returns the next coding point or -1 on invalid coding.
56 */
57 unsigned int fetch(std::istream& is) const override;
58 } ;
59
60 std::string transcribe(const char* in, size_t len,
61 const JPEncoding& sourceEncoding,
62 const JPEncoding& targetEncoding);
63
64 #endif // _JP_ENCODING_H_