1
/* This file is part of Strigi Desktop Search
3
* Copyright (C) 2006 Jos van den Oever <jos@vandenoever.info>
5
* This library is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU Library General Public
7
* License as published by the Free Software Foundation; either
8
* version 2 of the License, or (at your option) any later version.
10
* This library is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
* Library General Public License for more details.
15
* You should have received a copy of the GNU Library General Public License
16
* along with this library; see the file COPYING.LIB. If not, write to
17
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18
* Boston, MA 02110-1301, USA.
20
#ifndef STRIGI_TEXTUTILS_H
21
#define STRIGI_TEXTUTILS_H
24
#include <strigi/strigiconfig.h>
27
#define STREAMS_INLINE_EXPORT
29
#define STREAMS_INLINE_EXPORT STREAMS_EXPORT
35
STREAMS_EXPORT const char* checkUtf8(const char* p, int32_t length, char& nb);
37
STREAMS_EXPORT const char* checkUtf8(const std::string&, char& nb);
39
STREAMS_EXPORT bool checkUtf8(const char* p, int32_t length);
41
STREAMS_EXPORT bool checkUtf8(const std::string&);
43
STREAMS_EXPORT void convertNewLines(char* p);
46
inline STREAMS_INLINE_EXPORT int16_t readBigEndianInt16(const char* c) {
47
return *reinterpret_cast<const int16_t*>(c);
49
inline STREAMS_INLINE_EXPORT uint16_t readBigEndianUInt16(const char* c) {
50
return *reinterpret_cast<const uint16_t*>(c);
52
inline STREAMS_INLINE_EXPORT int32_t readBigEndianInt32(const char* c) {
53
return *reinterpret_cast<const int32_t*>(c);
55
inline STREAMS_INLINE_EXPORT uint32_t readBigEndianUInt32(const char* c) {
56
return *reinterpret_cast<const uint32_t*>(c);
58
inline STREAMS_INLINE_EXPORT int64_t readBigEndianInt64(const char* c) {
59
return *reinterpret_cast<const int64_t*>(c);
61
inline STREAMS_INLINE_EXPORT uint64_t readBigEndianUInt64(const char* c) {
62
return *reinterpret_cast<const uint64_t*>(c);
64
STREAMS_EXPORT int16_t readLittleEndianInt16(const char* c);
65
STREAMS_EXPORT uint16_t readLittleEndianUInt16(const char* c);
66
STREAMS_EXPORT int32_t readLittleEndianInt32(const char* c);
67
STREAMS_EXPORT uint32_t readLittleEndianUInt32(const char* c);
68
STREAMS_EXPORT int64_t readLittleEndianInt64(const char* c);
69
STREAMS_EXPORT uint64_t readLittleEndianUInt64(const char* c);
71
inline STREAMS_INLINE_EXPORT int16_t readLittleEndianInt16(const char* c) {
72
return *reinterpret_cast<const int16_t*>(c);
74
inline STREAMS_INLINE_EXPORT uint16_t readLittleEndianUInt16(const char* c) {
75
return *reinterpret_cast<const uint16_t*>(c);
77
inline STREAMS_INLINE_EXPORT int32_t readLittleEndianInt32(const char* c) {
78
return *reinterpret_cast<const int32_t*>(c);
80
inline STREAMS_INLINE_EXPORT uint32_t readLittleEndianUInt32(const char* c) {
81
return *reinterpret_cast<const uint32_t*>(c);
83
inline STREAMS_INLINE_EXPORT int64_t readLittleEndianInt64(const char* c) {
84
return *reinterpret_cast<const int64_t*>(c);
86
inline STREAMS_INLINE_EXPORT uint64_t readLittleEndianUInt64(const char* c) {
87
return *reinterpret_cast<const uint64_t*>(c);
89
STREAMS_EXPORT int16_t readBigEndianInt16(const char* c);
90
STREAMS_EXPORT uint16_t readBigEndianUInt16(const char* c);
91
STREAMS_EXPORT int32_t readBigEndianInt32(const char* c);
92
STREAMS_EXPORT uint32_t readBigEndianUInt32(const char* c);
93
STREAMS_EXPORT int64_t readBigEndianInt64(const char* c);
94
STREAMS_EXPORT uint64_t readBigEndianUInt64(const char* c);
97
inline STREAMS_INLINE_EXPORT int16_t readLittleEndianInt16(const unsigned char* c) {
98
return readLittleEndianInt16(reinterpret_cast<const char*>(c));
100
inline STREAMS_INLINE_EXPORT uint16_t readLittleEndianUInt16(const unsigned char* c) {
101
return readLittleEndianUInt16(reinterpret_cast<const char*>(c));
103
inline STREAMS_INLINE_EXPORT int32_t readLittleEndianInt32(const unsigned char* c) {
104
return readLittleEndianInt32(reinterpret_cast<const char*>(c));
106
inline STREAMS_INLINE_EXPORT uint32_t readLittleEndianUInt32(const unsigned char* c) {
107
return readLittleEndianUInt32(reinterpret_cast<const char*>(c));
109
inline STREAMS_INLINE_EXPORT int64_t readLittleEndianInt64(const unsigned char* c) {
110
return readLittleEndianInt16(reinterpret_cast<const char*>(c));
112
inline STREAMS_INLINE_EXPORT uint64_t readLittleEndianUInt64(const unsigned char* c) {
113
return readLittleEndianUInt64(reinterpret_cast<const char*>(c));
115
inline STREAMS_INLINE_EXPORT int16_t readBigEndianInt16(const unsigned char* c) {
116
return readBigEndianInt16(reinterpret_cast<const char*>(c));
118
inline STREAMS_INLINE_EXPORT uint16_t readBigEndianUInt16(const unsigned char* c) {
119
return readBigEndianUInt16(reinterpret_cast<const char*>(c));
121
inline STREAMS_INLINE_EXPORT int32_t readBigEndianInt32(const unsigned char* c) {
122
return readBigEndianInt32(reinterpret_cast<const char*>(c));
124
inline STREAMS_INLINE_EXPORT uint32_t readBigEndianUInt32(const unsigned char* c) {
125
return readBigEndianUInt32(reinterpret_cast<const char*>(c));
127
inline STREAMS_INLINE_EXPORT int64_t readBigEndianInt64(const unsigned char* c) {
128
return readBigEndianInt16(reinterpret_cast<const char*>(c));
130
inline STREAMS_INLINE_EXPORT uint64_t readBigEndianUInt64(const unsigned char* c) {
131
return readBigEndianUInt64(reinterpret_cast<const char*>(c));
135
} // end namespace Strigi