Skip to content

Commit c42b381

Browse files
committed
Moving text_reader/text_writer into its own file in support
1 parent 4df3fec commit c42b381

File tree

4 files changed

+79
-37
lines changed

4 files changed

+79
-37
lines changed

lib/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ set(ELEMENTS_HEADERS
122122
include/elements/support/draw_utils.hpp
123123
include/elements/support/icon_ids.hpp
124124
include/elements/support/receiver.hpp
125+
include/elements/support/text_reader_writer.hpp
125126
include/elements/support/text_utils.hpp
126127
include/elements/support/theme.hpp
127128
include/elements/view.hpp

lib/include/elements/element/label.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
#define ELEMENTS_LABELS_APRIL_11_2016
88

99
#include <elements/element/element.hpp>
10-
#include <elements/element/text.hpp>
1110
#include <elements/element/proxy.hpp>
1211
#include <elements/element/traversal.hpp>
1312
#include <elements/support/theme.hpp>
1413
#include <elements/support/receiver.hpp>
14+
#include <elements/support/text_reader_writer.hpp>
1515
#include <artist/font.hpp>
1616
#include <infra/string_view.hpp>
1717
#include <string>

lib/include/elements/element/text.hpp

+1-36
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
#include <elements/element/element.hpp>
1010
#include <elements/support/theme.hpp>
1111
#include <elements/support/receiver.hpp>
12+
#include <elements/support/text_reader_writer.hpp>
1213
#include <artist/text_layout.hpp>
1314

14-
#include <infra/string_view.hpp>
1515
#include <string>
1616
#include <vector>
1717
#include <set>
@@ -21,41 +21,6 @@ namespace cycfi::elements
2121
using artist::font_descr;
2222
using artist::font;
2323

24-
////////////////////////////////////////////////////////////////////////////
25-
// text_reader and text_writer mixins
26-
////////////////////////////////////////////////////////////////////////////
27-
class text_reader_u8
28-
{
29-
public:
30-
31-
virtual ~text_reader_u8() = default;
32-
virtual std::string_view get_text() const = 0;
33-
};
34-
35-
class text_writer
36-
{
37-
public:
38-
39-
virtual ~text_writer() = default;
40-
virtual void set_text(string_view text) = 0;
41-
};
42-
43-
class text_reader_u32
44-
{
45-
public:
46-
47-
virtual ~text_reader_u32() = default;
48-
virtual std::u32string_view get_text() const = 0;
49-
};
50-
51-
class text_writer_u32
52-
{
53-
public:
54-
55-
virtual ~text_writer_u32() = default;
56-
virtual void set_text(std::u32string_view text) = 0;
57-
};
58-
5924
////////////////////////////////////////////////////////////////////////////
6025
// Static Text Box
6126
////////////////////////////////////////////////////////////////////////////
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
/*=============================================================================
2+
Copyright (c) 2016-2023 Joel de Guzman
3+
4+
Distributed under the MIT License [ https://opensource.org/licenses/MIT ]
5+
=============================================================================*/
6+
#if !defined(ELEMENTS_TEXT_READER_WRITER_APRIL_17_2016)
7+
#define ELEMENTS_TEXT_READER_WRITER_APRIL_17_2016
8+
9+
#include <infra/string_view.hpp>
10+
11+
namespace cycfi::elements
12+
{
13+
/**
14+
* @brief
15+
* This class represents a text reader for UTF-8 encoded text.
16+
*
17+
* It defines the interface for classes that are capable of reading
18+
* UTF-8 text. Derived classes must implement the `get_text()` function.
19+
*/
20+
class text_reader_u8
21+
{
22+
public:
23+
24+
virtual ~text_reader_u8() = default;
25+
virtual std::string_view get_text() const = 0;
26+
};
27+
28+
/**
29+
* @brief
30+
* This class defines an interface for writing text.
31+
*
32+
* It serves as a base class for writing or updating text. Derived
33+
* classes must implement the `set_text(string_view text)` function.
34+
*/
35+
class text_writer
36+
{
37+
public:
38+
39+
virtual ~text_writer() = default;
40+
virtual void set_text(string_view text) = 0;
41+
};
42+
43+
/**
44+
* @brief
45+
* This class provides an interface for reading UTF-32 encoded text.
46+
*
47+
* It serves as a base class for classes that are capable of reading
48+
* text encoded in UTF-32. Derived classes must implement the
49+
* `get_text()` function.
50+
*/
51+
class text_reader_u32
52+
{
53+
public:
54+
55+
virtual ~text_reader_u32() = default;
56+
virtual std::u32string_view get_text() const = 0;
57+
};
58+
59+
/**
60+
* @brief
61+
* This class serves as a base class for writing UTF-32 encoded text.
62+
*
63+
* Designed to be used as an interface for classes that need to write
64+
* UTF-32 encoded text. Derived classes must implement the
65+
* `set_text(std::u32string_view text)` function.
66+
*/
67+
class text_writer_u32
68+
{
69+
public:
70+
71+
virtual ~text_writer_u32() = default;
72+
virtual void set_text(std::u32string_view text) = 0;
73+
};
74+
}
75+
76+
#endif

0 commit comments

Comments
 (0)