source: icGREP/icgrep-devel/icgrep/utf_encoding.h @ 5106

Last change on this file since 5106 was 5046, checked in by xuedongx, 3 years ago

fix index

File size: 1.1 KB
Line 
1/*
2 *  Copyright (c) 2014 International Characters.
3 *  This software is licensed to the public under the Open Software License 3.0.
4 *  icgrep is a trademark of International Characters.
5 */
6
7#ifndef UTF_ENCODING_H
8#define UTF_ENCODING_H
9
10#include <stdint.h>
11#include <string>
12#include <vector>
13
14class Encoding{
15public:
16
17    enum class Type {
18        ASCII
19        , UTF_8
20        , UTF_16
21    };
22
23    Encoding(Type type, unsigned bits);
24    Encoding(Type type, unsigned bits, unsigned mask);
25    Type getType() const;
26    unsigned getBits() const;
27    unsigned getMask() const;
28private:
29    Type        mType;
30    unsigned    mBits;
31    unsigned    mMask;
32};
33
34inline Encoding::Encoding(Type type, unsigned bits)
35: mType(type)
36, mBits(bits)
37, mMask((static_cast<unsigned>(1) << bits) - static_cast<unsigned>(1))
38{
39
40}
41
42inline Encoding::Encoding(Type type, unsigned bits, unsigned mask)
43: mType(type)
44, mBits(bits)
45, mMask(mask)
46{
47
48}
49
50inline Encoding::Type Encoding::getType() const {
51    return mType;
52}
53
54inline unsigned Encoding::getBits() const {
55    return mBits;
56}
57
58inline unsigned Encoding::getMask() const {
59    return mMask;
60}
61
62#endif // UTF_ENCODING_H
Note: See TracBrowser for help on using the repository browser.