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

Last change on this file since 4388 was 4209, checked in by nmedfort, 5 years ago

Minor revisions

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    };
21
22    Encoding(Type type, unsigned bits);
23    Encoding(Type type, unsigned bits, unsigned mask);
24    Type getType() const;
25    unsigned getBits() const;
26    unsigned getMask() const;
27private:
28    Type        mType;
29    unsigned    mBits;
30    unsigned    mMask;
31};
32
33inline Encoding::Encoding(Type type, unsigned bits)
34: mType(type)
35, mBits(bits)
36, mMask((static_cast<unsigned>(1) << bits) - static_cast<unsigned>(1))
37{
38
39}
40
41inline Encoding::Encoding(Type type, unsigned bits, unsigned mask)
42: mType(type)
43, mBits(bits)
44, mMask(mask)
45{
46
47}
48
49inline Encoding::Type Encoding::getType() const {
50    return mType;
51}
52
53inline unsigned Encoding::getBits() const {
54    return mBits;
55}
56
57inline unsigned Encoding::getMask() const {
58    return mMask;
59}
60
61#endif // UTF_ENCODING_H
Note: See TracBrowser for help on using the repository browser.