~ubuntu-branches/ubuntu/oneiric/strigi/oneiric

« back to all changes in this revision

Viewing changes to src/streams/textutils.h

  • Committer: Package Import Robot
  • Author(s): Felix Geyer
  • Date: 2011-09-24 17:12:15 UTC
  • mfrom: (1.2.6 upstream)
  • mto: This revision was merged to the branch mainline in revision 44.
  • Revision ID: package-import@ubuntu.com-20110924171215-zmbi1f77jntvz65h
Tags: upstream-0.7.6
ImportĀ upstreamĀ versionĀ 0.7.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* This file is part of Strigi Desktop Search
2
 
 *
3
 
 * Copyright (C) 2006 Jos van den Oever <jos@vandenoever.info>
4
 
 *
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.
9
 
 *
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.
14
 
 *
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.
19
 
 */
20
 
#ifndef STRIGI_TEXTUTILS_H
21
 
#define STRIGI_TEXTUTILS_H
22
 
 
23
 
#include <string>
24
 
#include <strigi/strigiconfig.h>
25
 
 
26
 
#ifdef __MINGW32__
27
 
 #define STREAMS_INLINE_EXPORT
28
 
#else
29
 
 #define STREAMS_INLINE_EXPORT STREAMS_EXPORT
30
 
#endif
31
 
 
32
 
 
33
 
namespace Strigi {
34
 
 
35
 
STREAMS_EXPORT const char* checkUtf8(const char* p, int32_t length, char& nb);
36
 
 
37
 
STREAMS_EXPORT const char* checkUtf8(const std::string&, char& nb);
38
 
 
39
 
STREAMS_EXPORT bool checkUtf8(const char* p, int32_t length);
40
 
 
41
 
STREAMS_EXPORT bool checkUtf8(const std::string&);
42
 
 
43
 
STREAMS_EXPORT void convertNewLines(char* p);
44
 
 
45
 
#ifdef __BIG_ENDIAN__
46
 
inline STREAMS_INLINE_EXPORT int16_t  readBigEndianInt16(const char* c) {
47
 
    return *reinterpret_cast<const int16_t*>(c);
48
 
}
49
 
inline STREAMS_INLINE_EXPORT uint16_t readBigEndianUInt16(const char* c) {
50
 
    return *reinterpret_cast<const uint16_t*>(c);
51
 
}
52
 
inline STREAMS_INLINE_EXPORT int32_t  readBigEndianInt32(const char* c) {
53
 
    return *reinterpret_cast<const int32_t*>(c);
54
 
}
55
 
inline STREAMS_INLINE_EXPORT uint32_t readBigEndianUInt32(const char* c) {
56
 
    return *reinterpret_cast<const uint32_t*>(c);
57
 
}
58
 
inline STREAMS_INLINE_EXPORT int64_t  readBigEndianInt64(const char* c) {
59
 
    return *reinterpret_cast<const int64_t*>(c);
60
 
}
61
 
inline STREAMS_INLINE_EXPORT uint64_t readBigEndianUInt64(const char* c) {
62
 
    return *reinterpret_cast<const uint64_t*>(c);
63
 
}
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);
70
 
#else
71
 
inline STREAMS_INLINE_EXPORT int16_t  readLittleEndianInt16(const char* c) {
72
 
    return *reinterpret_cast<const int16_t*>(c);
73
 
}
74
 
inline STREAMS_INLINE_EXPORT uint16_t readLittleEndianUInt16(const char* c) {
75
 
    return *reinterpret_cast<const uint16_t*>(c);
76
 
}
77
 
inline STREAMS_INLINE_EXPORT int32_t  readLittleEndianInt32(const char* c) {
78
 
    return *reinterpret_cast<const int32_t*>(c);
79
 
}
80
 
inline STREAMS_INLINE_EXPORT uint32_t readLittleEndianUInt32(const char* c) {
81
 
    return *reinterpret_cast<const uint32_t*>(c);
82
 
}
83
 
inline STREAMS_INLINE_EXPORT int64_t  readLittleEndianInt64(const char* c) {
84
 
    return *reinterpret_cast<const int64_t*>(c);
85
 
}
86
 
inline STREAMS_INLINE_EXPORT uint64_t readLittleEndianUInt64(const char* c) {
87
 
    return *reinterpret_cast<const uint64_t*>(c);
88
 
}
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);
95
 
#endif
96
 
 
97
 
inline STREAMS_INLINE_EXPORT int16_t  readLittleEndianInt16(const unsigned char* c) {
98
 
    return readLittleEndianInt16(reinterpret_cast<const char*>(c));
99
 
}
100
 
inline STREAMS_INLINE_EXPORT uint16_t readLittleEndianUInt16(const unsigned char* c) {
101
 
    return readLittleEndianUInt16(reinterpret_cast<const char*>(c));
102
 
}
103
 
inline STREAMS_INLINE_EXPORT int32_t  readLittleEndianInt32(const unsigned char* c) {
104
 
    return readLittleEndianInt32(reinterpret_cast<const char*>(c));
105
 
}
106
 
inline STREAMS_INLINE_EXPORT uint32_t readLittleEndianUInt32(const unsigned char* c) {
107
 
    return readLittleEndianUInt32(reinterpret_cast<const char*>(c));
108
 
}
109
 
inline STREAMS_INLINE_EXPORT int64_t  readLittleEndianInt64(const unsigned char* c) {
110
 
    return readLittleEndianInt16(reinterpret_cast<const char*>(c));
111
 
}
112
 
inline STREAMS_INLINE_EXPORT uint64_t readLittleEndianUInt64(const unsigned char* c) {
113
 
    return readLittleEndianUInt64(reinterpret_cast<const char*>(c));
114
 
}
115
 
inline STREAMS_INLINE_EXPORT int16_t  readBigEndianInt16(const unsigned char* c) {
116
 
    return readBigEndianInt16(reinterpret_cast<const char*>(c));
117
 
}
118
 
inline STREAMS_INLINE_EXPORT uint16_t readBigEndianUInt16(const unsigned char* c) {
119
 
    return readBigEndianUInt16(reinterpret_cast<const char*>(c));
120
 
}
121
 
inline STREAMS_INLINE_EXPORT int32_t  readBigEndianInt32(const unsigned char* c) {
122
 
    return readBigEndianInt32(reinterpret_cast<const char*>(c));
123
 
}
124
 
inline STREAMS_INLINE_EXPORT uint32_t readBigEndianUInt32(const unsigned char* c) {
125
 
    return readBigEndianUInt32(reinterpret_cast<const char*>(c));
126
 
}
127
 
inline STREAMS_INLINE_EXPORT int64_t  readBigEndianInt64(const unsigned char* c) {
128
 
    return readBigEndianInt16(reinterpret_cast<const char*>(c));
129
 
}
130
 
inline STREAMS_INLINE_EXPORT uint64_t readBigEndianUInt64(const unsigned char* c) {
131
 
    return readBigEndianUInt64(reinterpret_cast<const char*>(c));
132
 
}
133
 
 
134
 
 
135
 
} // end namespace Strigi
136
 
 
137
 
#endif