summaryrefslogtreecommitdiff
path: root/src/enchant++.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/enchant++.h')
-rw-r--r--src/enchant++.h86
1 files changed, 43 insertions, 43 deletions
diff --git a/src/enchant++.h b/src/enchant++.h
index 68ebaf9..458a707 100644
--- a/src/enchant++.h
+++ b/src/enchant++.h
@@ -35,7 +35,7 @@
#include <vector>
#include <exception>
-namespace enchant
+namespace enchant
{
void set_prefix_dir (const std::string prefix) {
enchant_set_prefix_dir (prefix.c_str ());
@@ -46,7 +46,7 @@ namespace enchant
class Exception : public std::exception
{
public:
- explicit Exception (const char * ex)
+ explicit Exception (const char * ex)
: std::exception (), m_ex ("") {
if (ex)
m_ex = ex;
@@ -54,7 +54,7 @@ namespace enchant
virtual ~Exception () noexcept {
}
-
+
virtual const char * what () const noexcept {
return m_ex.c_str();
}
@@ -66,17 +66,17 @@ namespace enchant
class Dict
{
friend class enchant::Broker;
-
+
public:
-
+
~Dict () {
enchant_broker_free_dict (m_broker, m_dict);
}
-
+
bool check (const std::string & utf8word) {
int val;
- val = enchant_dict_check (m_dict, utf8word.c_str(),
+ val = enchant_dict_check (m_dict, utf8word.c_str(),
utf8word.size());
if (val == 0)
return true;
@@ -89,70 +89,70 @@ namespace enchant
return false; // never reached
}
- void suggest (const std::string & utf8word,
+ void suggest (const std::string & utf8word,
std::vector<std::string> & out_suggestions) {
size_t n_suggs;
char ** suggs;
-
+
out_suggestions.clear ();
-
- suggs = enchant_dict_suggest (m_dict, utf8word.c_str(),
+
+ suggs = enchant_dict_suggest (m_dict, utf8word.c_str(),
utf8word.size(), &n_suggs);
-
+
if (suggs && n_suggs) {
out_suggestions.reserve(n_suggs);
for (size_t i = 0; i < n_suggs; i++) {
out_suggestions.push_back (suggs[i]);
}
-
+
enchant_dict_free_string_list (m_dict, suggs);
}
}
-
+
std::vector<std::string> suggest (const std::string & utf8word) {
std::vector<std::string> result;
suggest (utf8word, result);
return result;
}
-
+
void add (const std::string & utf8word) {
- enchant_dict_add (m_dict, utf8word.c_str(),
+ enchant_dict_add (m_dict, utf8word.c_str(),
utf8word.size());
}
-
+
void add_to_session (const std::string & utf8word) {
- enchant_dict_add_to_session (m_dict, utf8word.c_str(),
+ enchant_dict_add_to_session (m_dict, utf8word.c_str(),
utf8word.size());
}
-
+
void is_added (const std::string & utf8word) {
- enchant_dict_is_added (m_dict, utf8word.c_str(),
+ enchant_dict_is_added (m_dict, utf8word.c_str(),
utf8word.size());
}
-
+
void remove (const std::string & utf8word) {
- enchant_dict_remove (m_dict, utf8word.c_str(),
+ enchant_dict_remove (m_dict, utf8word.c_str(),
utf8word.size());
}
-
+
void remove_from_session (const std::string & utf8word) {
- enchant_dict_remove_from_session (m_dict, utf8word.c_str(),
+ enchant_dict_remove_from_session (m_dict, utf8word.c_str(),
utf8word.size());
}
void is_removed (const std::string & utf8word) {
- enchant_dict_is_removed (m_dict, utf8word.c_str(),
+ enchant_dict_is_removed (m_dict, utf8word.c_str(),
utf8word.size());
}
- void store_replacement (const std::string & utf8bad,
+ void store_replacement (const std::string & utf8bad,
const std::string & utf8good) {
- enchant_dict_store_replacement (m_dict,
+ enchant_dict_store_replacement (m_dict,
utf8bad.c_str(), utf8bad.size(),
utf8good.c_str(), utf8good.size());
}
-
+
const std::string & get_lang () const {
return m_lang;
}
@@ -172,7 +172,7 @@ namespace enchant
private:
// space reserved for API/ABI expansion
- void * _private[5];
+ void * _private[5];
static void s_describe_fn (const char * const lang,
const char * const provider_name,
@@ -180,7 +180,7 @@ namespace enchant
const char * const provider_file,
void * user_data) {
enchant::Dict * dict = static_cast<enchant::Dict *> (user_data);
-
+
dict->m_lang = lang;
dict->m_provider_name = provider_name;
dict->m_provider_desc = provider_desc;
@@ -196,7 +196,7 @@ namespace enchant
Dict ();
Dict (const Dict & rhs);
Dict& operator=(const Dict & rhs);
-
+
EnchantDict * m_dict;
EnchantBroker * m_broker;
@@ -205,12 +205,12 @@ namespace enchant
std::string m_provider_desc;
std::string m_provider_file;
}; // class enchant::Dict
-
+
class Broker
{
-
+
public:
-
+
Broker ()
: m_broker (enchant_broker_init ())
{
@@ -222,40 +222,40 @@ namespace enchant
Dict * request_dict (const std::string & lang) {
EnchantDict * dict = enchant_broker_request_dict (m_broker, lang.c_str());
-
+
if (!dict) {
throw enchant::Exception (enchant_broker_get_error (m_broker));
return 0; // never reached
}
-
+
return new Dict (dict, m_broker);
}
Dict * request_pwl_dict (const std::string & pwl) {
EnchantDict * dict = enchant_broker_request_pwl_dict (m_broker, pwl.c_str());
-
+
if (!dict) {
throw enchant::Exception (enchant_broker_get_error (m_broker));
return 0; // never reached
}
-
+
return new Dict (dict, m_broker);
}
-
+
bool dict_exists (const std::string & lang) {
if (enchant_broker_dict_exists (m_broker, lang.c_str()))
return true;
return false;
}
-
+
void set_ordering (const std::string & tag, const std::string & ordering) {
enchant_broker_set_ordering (m_broker, tag.c_str(), ordering.c_str());
}
-
+
void describe (EnchantBrokerDescribeFn fn, void * user_data = NULL) {
enchant_broker_describe (m_broker, fn, user_data);
}
-
+
void list_dicts (EnchantDictDescribeFn fn, void * user_data = NULL) {
enchant_broker_list_dicts (m_broker, fn, user_data);
}
@@ -265,7 +265,7 @@ namespace enchant
// not implemented
Broker (const Broker & rhs);
Broker& operator=(const Broker & rhs);
-
+
EnchantBroker * m_broker;
}; // class enchant::Broker
} // enchant namespace