Aegisub/aegisub/libaegisub/include/libaegisub/thesaurus.h
Thomas Goyne 96cf5ea7ed Kill the #ifndef AGI_PRE guards
They don't actually improve compilation performance and make it more
annoying to modify what things are in the precompiled header.
2012-12-02 06:33:29 -08:00

54 lines
1.8 KiB
C++

// Copyright (c) 2012, Thomas Goyne <plorkyeran@aegisub.org>
//
// Permission to use, copy, modify, and distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
/// @file thesaurus.h
/// @brief MyThes-compatible thesaurus implementation
/// @ingroup libaegisub thesaurus
#include <libaegisub/scoped_ptr.h>
#include <iosfwd>
#include <map>
#include <string>
#include <vector>
namespace agi {
namespace charset { class IconvWrapper; }
class Thesaurus {
/// Map of word -> byte position in the data file
std::map<std::string, int> offsets;
/// Read handle to the data file
scoped_ptr<std::ifstream> dat;
/// Converter from the data file's charset to UTF-8
scoped_ptr<charset::IconvWrapper> conv;
public:
/// A pair of a word and synonyms for that word
typedef std::pair<std::string, std::vector<std::string> > Entry;
/// Constructor
/// @param dat_path Path to data file
/// @param idx_path Path to index file
Thesaurus(std::string const& dat_path, std::string const& idx_path);
~Thesaurus();
/// Look up synonyms for a word
/// @param word Word to look up
/// @param[out] out Vector to fill with word/synonym lists
void Lookup(std::string const& word, std::vector<Entry> *out);
};
}