aboutsummaryrefslogtreecommitdiff
path: root/src/unstable/text.h
blob: c57dcfb8db9ce50a8cb1e3dc9c0fa57721e859e4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/*
 * Copyright (C) 2007-2019 Xagasoft, All rights reserved.
 *
 * This file is part of the libbu++ library and is released under the
 * terms of the license contained in the file LICENSE.
 */

#ifndef BU_TEXT_H
#define BU_TEXT_H

#include "bu/config.h"

namespace Bu
{
    class TextBuilder;

    /**
     * Represents a string of text. Human readable language. This should be
     * used any time you're dealing with actual text and not just binary
     * data. If you neeed to transport raw binary data then consider using
     * Blob and BlobBuilder.
     *
     * Text objects should be considered immutable.  If you need to construct
     * a Text object dynamically take a look at TextBuilder, and for
     * serialization take a look at TextStream.
     *
     * A Text object is a sequence of Unicode code points. A code point is not
     * one to one with a character. A single character can be represented with
     * multilpe code points. In addition, a code point can also represent
     * formatting or display inforamtion.
     *
     */
    class Text
    {
    public:
        class iterator;
        class const_iterator;
        typedef uint32_t CodePoint;

    public:
        Text();
        Text( const Text &rSrc );
        Text( const TextBuilder &rSrc );
        virtual ~Text();

        bool isEmpty() const;
        bool isBmpOnly() const;
        int32_t getSize() const;
        int32_t getSizeInBytes() const;
        CodePoint operator[]( int32_t iIndex ) const;

        CodePoint *getData() const;
//        Text transform( (CodePoint *)(*pCallback)( CodePoint * ) );

    private:
        CodePoint *pData;
        bool bIsBmpOnly;
        int32_t iSize;
    };
    typedef Text::CodePoint CodePoint;
}

#endif