Elm
2
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
utf8.h
1
/*
2
* utf8 module interface
3
*
4
* This file is part of OTAWA
5
* Copyright (c) 2016, IRIT UPS.
6
*
7
* OTAWA is free software; you can redistribute it and/or modify
8
* it under the terms of the GNU General Public License as published by
9
* the Free Software Foundation; either version 2 of the License, or
10
* (at your option) any later version.
11
*
12
* OTAWA is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
16
*
17
* You should have received a copy of the GNU General Public License
18
* along with OTAWA; if not, write to the Free Software
19
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20
*/
21
#ifndef ELM_STRING_UTF8
22
#define ELM_STRING_UTF8
23
24
#include <elm/types.h>
25
#include <elm/PreIterator.h>
26
#include <elm/string.h>
27
#include <elm/util/MessageException.h>
28
29
namespace
elm
{
namespace
utf8 {
30
31
typedef
t::uint32
char_t
;
32
33
class
Exception
:
public
MessageException
{
34
public
:
35
inline
Exception
(
string
m):
MessageException
(m) { }
36
};
37
38
39
class
Iter
:
public
PreIterator
<Iter, char_t> {
40
public
:
41
inline
Iter
(
const
char
*
str
,
elm::t::size
size
)
42
: p(
str
), q(p +
size
), c(0) { parse(); }
43
inline
Iter
(
cstring
str
)
44
: p(
str
.chars()), q(p +
str
.length()), c(0) { parse(); }
45
inline
Iter
(
string
str
)
46
: p(
str
.toCString().chars()), q(p +
str
.length()), c(0) { parse(); }
47
48
inline
bool
ended
(
void
)
const
{
return
!c; }
49
inline
const
char_t
&
item
(
void
)
const
{
return
c; }
50
inline
void
next
(
void
) {
return
parse(); }
51
52
private
:
53
void
parse(
void
);
54
const
char
*p, *q;
55
char_t
c;
56
};
57
58
} }
// elm::utf8
59
60
#endif // ELM_STRING_UTF8
elm::MessageException
Definition:
MessageException.h:30
elm::utf8::Iter
Definition:
utf8.h:39
elm::utf8::Iter::Iter
Iter(string str)
Definition:
utf8.h:45
elm::CString
Definition:
CString.h:17
elm::utf8::Exception
Definition:
utf8.h:33
elm::utf8::Iter::Iter
Iter(const char *str, elm::t::size size)
Definition:
utf8.h:41
elm::utf8::Iter::item
const char_t & item(void) const
Definition:
utf8.h:49
elm::utf8::Iter::Iter
Iter(cstring str)
Definition:
utf8.h:43
elm
Definition:
adapter.h:26
elm::t::size
uint64 size
Definition:
arch.h:35
elm::t::uint32
unsigned int uint32
Definition:
arch.h:31
elm::utf8::Iter::next
void next(void)
Definition:
utf8.h:50
elm::utf8::Exception::Exception
Exception(string m)
Definition:
utf8.h:35
elm::utf8::Iter::ended
bool ended(void) const
Definition:
utf8.h:48
elm::str
string str(const char *s)
Definition:
String.h:150
elm::PreIterator
Definition:
iter.h:28
elm::utf8::char_t
t::uint32 char_t
Definition:
utf8.h:31
include
elm
string
utf8.h
Generated on Fri Jul 23 2021 11:32:45 for Elm by
1.8.17