Coverage Report

Created: 2023-12-08 06:59

/src/aspell/lib/speller-c.cpp
Line
Count
Source (jump to first uncovered line)
1
/* Automatically generated file.  Do not edit directly. */
2
3
/* This file is part of The New Aspell
4
 * Copyright (C) 2001-2002 by Kevin Atkinson under the GNU LGPL
5
 * license version 2.0 or 2.1.  You should have received a copy of the
6
 * LGPL license along with this library if you did not you can find it
7
 * at http://www.gnu.org/.                                              */
8
9
#include "convert.hpp"
10
#include "error.hpp"
11
#include "mutable_string.hpp"
12
#include "posib_err.hpp"
13
#include "speller.hpp"
14
#include "word_list.hpp"
15
16
namespace acommon {
17
18
class CanHaveError;
19
class Config;
20
struct Error;
21
class Speller;
22
class WordList;
23
24
extern "C" CanHaveError * new_aspell_speller(Config * config)
25
790
{
26
790
  PosibErr<Speller *> ret = new_speller(config);
27
790
  if (ret.has_err()) {
28
94
    return new CanHaveError(ret.release_err());
29
696
  } else {
30
696
    return ret;
31
696
  }
32
790
}
33
34
extern "C" Speller * to_aspell_speller(CanHaveError * obj)
35
696
{
36
696
  return static_cast<Speller *>(obj);
37
696
}
38
39
extern "C" void delete_aspell_speller(Speller * ths)
40
696
{
41
696
  delete ths;
42
696
}
43
44
extern "C" unsigned int aspell_speller_error_number(const Speller * ths)
45
0
{
46
0
  return ths->err_ == 0 ? 0 : 1;
47
0
}
48
49
extern "C" const char * aspell_speller_error_message(const Speller * ths)
50
0
{
51
0
  return ths->err_ ? ths->err_->mesg : "";
52
0
}
53
54
extern "C" const Error * aspell_speller_error(const Speller * ths)
55
0
{
56
0
  return ths->err_;
57
0
}
58
59
extern "C" Config * aspell_speller_config(Speller * ths)
60
0
{
61
0
  return ths->config();
62
0
}
63
64
extern "C" int aspell_speller_check(Speller * ths, const char * word, int word_size)
65
0
{
66
0
  ths->temp_str_0.clear();
67
0
  PosibErr<int> word_fixed_size = get_correct_size("aspell_speller_check", ths->to_internal_->in_type_width(), word_size);
68
0
  if (word_fixed_size.get_err()) {
69
0
    return 0;
70
0
  } else {
71
0
    word_size = word_fixed_size;
72
0
  }
73
0
  ths->to_internal_->convert(word, word_size, ths->temp_str_0);
74
0
  unsigned int s0 = ths->temp_str_0.size();
75
0
  PosibErr<bool> ret = ths->check(MutableString(ths->temp_str_0.mstr(), s0));
76
0
  ths->err_.reset(ret.release_err());
77
0
  if (ths->err_ != 0) return -1;
78
0
  return ret.data;
79
0
}
80
81
extern "C" int aspell_speller_check_wide(Speller * ths, const void * word, int word_size, int word_type_width)
82
0
{
83
0
  ths->temp_str_0.clear();
84
0
  word_size = get_correct_size("aspell_speller_check_wide", ths->to_internal_->in_type_width(), word_size, word_type_width);
85
0
  ths->to_internal_->convert(word, word_size, ths->temp_str_0);
86
0
  unsigned int s0 = ths->temp_str_0.size();
87
0
  PosibErr<bool> ret = ths->check(MutableString(ths->temp_str_0.mstr(), s0));
88
0
  ths->err_.reset(ret.release_err());
89
0
  if (ths->err_ != 0) return -1;
90
0
  return ret.data;
91
0
}
92
93
extern "C" int aspell_speller_add_to_personal(Speller * ths, const char * word, int word_size)
94
0
{
95
0
  ths->temp_str_0.clear();
96
0
  PosibErr<int> word_fixed_size = get_correct_size("aspell_speller_add_to_personal", ths->to_internal_->in_type_width(), word_size);
97
0
  ths->err_.reset(word_fixed_size.release_err());
98
0
  if (ths->err_ != 0) return 0;
99
0
  ths->to_internal_->convert(word, word_size, ths->temp_str_0);
100
0
  unsigned int s0 = ths->temp_str_0.size();
101
0
  PosibErr<void> ret = ths->add_to_personal(MutableString(ths->temp_str_0.mstr(), s0));
102
0
  ths->err_.reset(ret.release_err());
103
0
  if (ths->err_ != 0) return 0;
104
0
  return 1;
105
0
}
106
107
extern "C" int aspell_speller_add_to_personal_wide(Speller * ths, const void * word, int word_size, int word_type_width)
108
0
{
109
0
  ths->temp_str_0.clear();
110
0
  word_size = get_correct_size("aspell_speller_add_to_personal_wide", ths->to_internal_->in_type_width(), word_size, word_type_width);
111
0
  ths->to_internal_->convert(word, word_size, ths->temp_str_0);
112
0
  unsigned int s0 = ths->temp_str_0.size();
113
0
  PosibErr<void> ret = ths->add_to_personal(MutableString(ths->temp_str_0.mstr(), s0));
114
0
  ths->err_.reset(ret.release_err());
115
0
  if (ths->err_ != 0) return 0;
116
0
  return 1;
117
0
}
118
119
extern "C" int aspell_speller_add_to_session(Speller * ths, const char * word, int word_size)
120
0
{
121
0
  ths->temp_str_0.clear();
122
0
  PosibErr<int> word_fixed_size = get_correct_size("aspell_speller_add_to_session", ths->to_internal_->in_type_width(), word_size);
123
0
  ths->err_.reset(word_fixed_size.release_err());
124
0
  if (ths->err_ != 0) return 0;
125
0
  ths->to_internal_->convert(word, word_size, ths->temp_str_0);
126
0
  unsigned int s0 = ths->temp_str_0.size();
127
0
  PosibErr<void> ret = ths->add_to_session(MutableString(ths->temp_str_0.mstr(), s0));
128
0
  ths->err_.reset(ret.release_err());
129
0
  if (ths->err_ != 0) return 0;
130
0
  return 1;
131
0
}
132
133
extern "C" int aspell_speller_add_to_session_wide(Speller * ths, const void * word, int word_size, int word_type_width)
134
0
{
135
0
  ths->temp_str_0.clear();
136
0
  word_size = get_correct_size("aspell_speller_add_to_session_wide", ths->to_internal_->in_type_width(), word_size, word_type_width);
137
0
  ths->to_internal_->convert(word, word_size, ths->temp_str_0);
138
0
  unsigned int s0 = ths->temp_str_0.size();
139
0
  PosibErr<void> ret = ths->add_to_session(MutableString(ths->temp_str_0.mstr(), s0));
140
0
  ths->err_.reset(ret.release_err());
141
0
  if (ths->err_ != 0) return 0;
142
0
  return 1;
143
0
}
144
145
extern "C" const WordList * aspell_speller_personal_word_list(Speller * ths)
146
0
{
147
0
  PosibErr<const WordList *> ret = ths->personal_word_list();
148
0
  ths->err_.reset(ret.release_err());
149
0
  if (ths->err_ != 0) return 0;
150
0
  if (ret.data)
151
0
    const_cast<WordList *>(ret.data)->from_internal_ = ths->from_internal_;
152
0
  return ret.data;
153
0
}
154
155
extern "C" const WordList * aspell_speller_session_word_list(Speller * ths)
156
0
{
157
0
  PosibErr<const WordList *> ret = ths->session_word_list();
158
0
  ths->err_.reset(ret.release_err());
159
0
  if (ths->err_ != 0) return 0;
160
0
  if (ret.data)
161
0
    const_cast<WordList *>(ret.data)->from_internal_ = ths->from_internal_;
162
0
  return ret.data;
163
0
}
164
165
extern "C" const WordList * aspell_speller_main_word_list(Speller * ths)
166
0
{
167
0
  PosibErr<const WordList *> ret = ths->main_word_list();
168
0
  ths->err_.reset(ret.release_err());
169
0
  if (ths->err_ != 0) return 0;
170
0
  if (ret.data)
171
0
    const_cast<WordList *>(ret.data)->from_internal_ = ths->from_internal_;
172
0
  return ret.data;
173
0
}
174
175
extern "C" int aspell_speller_save_all_word_lists(Speller * ths)
176
0
{
177
0
  PosibErr<void> ret = ths->save_all_word_lists();
178
0
  ths->err_.reset(ret.release_err());
179
0
  if (ths->err_ != 0) return 0;
180
0
  return 1;
181
0
}
182
183
extern "C" int aspell_speller_clear_session(Speller * ths)
184
0
{
185
0
  PosibErr<void> ret = ths->clear_session();
186
0
  ths->err_.reset(ret.release_err());
187
0
  if (ths->err_ != 0) return 0;
188
0
  return 1;
189
0
}
190
191
extern "C" const WordList * aspell_speller_suggest(Speller * ths, const char * word, int word_size)
192
10.5k
{
193
10.5k
  ths->temp_str_0.clear();
194
10.5k
  PosibErr<int> word_fixed_size = get_correct_size("aspell_speller_suggest", ths->to_internal_->in_type_width(), word_size);
195
10.5k
  if (word_fixed_size.get_err()) {
196
0
    word = NULL; word_size = 0;
197
10.5k
  } else {
198
10.5k
    word_size = word_fixed_size;
199
10.5k
  }
200
10.5k
  ths->to_internal_->convert(word, word_size, ths->temp_str_0);
201
10.5k
  unsigned int s0 = ths->temp_str_0.size();
202
10.5k
  PosibErr<const WordList *> ret = ths->suggest(MutableString(ths->temp_str_0.mstr(), s0));
203
10.5k
  ths->err_.reset(ret.release_err());
204
10.5k
  if (ths->err_ != 0) return 0;
205
10.5k
  if (ret.data)
206
10.5k
    const_cast<WordList *>(ret.data)->from_internal_ = ths->from_internal_;
207
10.5k
  return ret.data;
208
10.5k
}
209
210
extern "C" const WordList * aspell_speller_suggest_wide(Speller * ths, const void * word, int word_size, int word_type_width)
211
0
{
212
0
  ths->temp_str_0.clear();
213
0
  word_size = get_correct_size("aspell_speller_suggest_wide", ths->to_internal_->in_type_width(), word_size, word_type_width);
214
0
  ths->to_internal_->convert(word, word_size, ths->temp_str_0);
215
0
  unsigned int s0 = ths->temp_str_0.size();
216
0
  PosibErr<const WordList *> ret = ths->suggest(MutableString(ths->temp_str_0.mstr(), s0));
217
0
  ths->err_.reset(ret.release_err());
218
0
  if (ths->err_ != 0) return 0;
219
0
  if (ret.data)
220
0
    const_cast<WordList *>(ret.data)->from_internal_ = ths->from_internal_;
221
0
  return ret.data;
222
0
}
223
224
extern "C" int aspell_speller_store_replacement(Speller * ths, const char * mis, int mis_size, const char * cor, int cor_size)
225
0
{
226
0
  ths->temp_str_0.clear();
227
0
  PosibErr<int> mis_fixed_size = get_correct_size("aspell_speller_store_replacement", ths->to_internal_->in_type_width(), mis_size);
228
0
  ths->err_.reset(mis_fixed_size.release_err());
229
0
  if (ths->err_ != 0) return -1;
230
0
  ths->to_internal_->convert(mis, mis_size, ths->temp_str_0);
231
0
  unsigned int s0 = ths->temp_str_0.size();
232
0
  ths->temp_str_1.clear();
233
0
  PosibErr<int> cor_fixed_size = get_correct_size("aspell_speller_store_replacement", ths->to_internal_->in_type_width(), cor_size);
234
0
  ths->err_.reset(cor_fixed_size.release_err());
235
0
  if (ths->err_ != 0) return -1;
236
0
  ths->to_internal_->convert(cor, cor_size, ths->temp_str_1);
237
0
  unsigned int s1 = ths->temp_str_1.size();
238
0
  PosibErr<bool> ret = ths->store_replacement(MutableString(ths->temp_str_0.mstr(), s0), MutableString(ths->temp_str_1.mstr(), s1));
239
0
  ths->err_.reset(ret.release_err());
240
0
  if (ths->err_ != 0) return -1;
241
0
  return ret.data;
242
0
}
243
244
extern "C" int aspell_speller_store_replacement_wide(Speller * ths, const void * mis, int mis_size, int mis_type_width, const void * cor, int cor_size, int cor_type_width)
245
0
{
246
0
  ths->temp_str_0.clear();
247
0
  mis_size = get_correct_size("aspell_speller_store_replacement_wide", ths->to_internal_->in_type_width(), mis_size, mis_type_width);
248
0
  ths->to_internal_->convert(mis, mis_size, ths->temp_str_0);
249
0
  unsigned int s0 = ths->temp_str_0.size();
250
0
  ths->temp_str_1.clear();
251
0
  cor_size = get_correct_size("aspell_speller_store_replacement_wide", ths->to_internal_->in_type_width(), cor_size, cor_type_width);
252
0
  ths->to_internal_->convert(cor, cor_size, ths->temp_str_1);
253
0
  unsigned int s1 = ths->temp_str_1.size();
254
0
  PosibErr<bool> ret = ths->store_replacement(MutableString(ths->temp_str_0.mstr(), s0), MutableString(ths->temp_str_1.mstr(), s1));
255
0
  ths->err_.reset(ret.release_err());
256
0
  if (ths->err_ != 0) return -1;
257
0
  return ret.data;
258
0
}
259
260
261
262
}
263