File: plaintextdictbuilder.h

package info (click to toggle)
dictconv 0.2-7
  • links: PTS
  • area: main
  • in suites: bullseye, buster, jessie, jessie-kfreebsd, lenny, sid, squeeze, stretch, wheezy
  • size: 1,536 kB
  • ctags: 434
  • sloc: sh: 8,876; cpp: 1,979; makefile: 10
file content (111 lines) | stat: -rw-r--r-- 4,527 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
/***************************************************************************
 *   Copyright (C) 2007 by Raul Fernandes                                  *
 *   rgfbr@yahoo.com.br                                                    *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.          *
 ***************************************************************************/

#ifndef _PLAINTEXTDICTBUILDER_H_
#define _PLAINTEXTDICTBUILDER_H_

#include "dictbuilder.h"

#include <fstream>
#include <map>


/**
@author Raul Fernandes
*/
class PlainTextDictBuilder : public DictBuilder
{
public:
  PlainTextDictBuilder( std::string filename );

  ~PlainTextDictBuilder();

    bool addHeadword( std::string word, std::string def, std::vector<std::string> alternates = std::vector<std::string>() );
    bool finish();

    //void setFilename( const std::string filename ) { m_filename = filename; };
    std::string filename() { return m_filename; };
    void setTitle( const std::string title ) { m_title = title; };
    std::string title() { return m_title; };
    void setAuthor( const std::string author ) { m_author = author; };
    std::string author() { return m_author; };
    void setLicense( const std::string license ) { m_license = license; };
    std::string license() { return m_license; };
    void setOrigLang( const std::string origLang ) { m_origLang = origLang; };
    std::string origLang() { return m_origLang; };
    void setDestLang( const std::string destLang ) { m_destLang = destLang; };
    std::string destLang() { return m_destLang; };
    void setDescription( const std::string description ) { m_description = description; };
    std::string description() { return m_description; };
    void setComments( const std::string comments ) { m_comments = comments; };
    std::string comments() { return m_comments; };
    void setEmail( const std::string email ) { m_email = email; };
    std::string email() { return m_email; };
    void setWebsite( const std::string website ) { m_website = website; };
    std::string website() { return m_website; };
    void setVersion( const std::string version ) { m_version = version; };
    std::string version() { return m_version; };
    void setCreationDate( const std::string creationDate ) { m_creationDate = creationDate; };
    std::string creationDate() { return m_creationDate; };
    void setLastUpdate( const std::string lastUpdate ) { m_lastUpdate = lastUpdate; };
    std::string lastUpdate() { return m_lastUpdate; };
    void setMisc( const std::string misc ) { m_misc = misc; };
    std::string misc() { return m_misc; };
    unsigned int headwords() { return m_entriescount; };
    unsigned int words() { return m_wordcount; };

protected:

  typedef unsigned int uint32;
  typedef std::map<std::string, std::string> dictionary;

  std::ofstream file;
  std::string m_filename;

  // Header
  std::string m_title;
  std::string m_author;
  std::string m_license;
  std::string m_origLang;
  std::string m_destLang;
  uint32 m_entriescount;
  std::string m_description;
  std::string m_comments;
  std::string m_email;
  std::string m_website;
  std::string m_version;
  std::string m_creationDate;
  std::string m_lastUpdate;
  std::string m_misc;

  uint m_size;
  bool m_isOk;

  uint32 m_wordcount;
  uint32 m_headerOffset;
  uint32 m_idxOffset;
  uint32 m_defOffset;

  std::string m_definition;

  dictionary dic;
};

#endif // _PLAINTEXTDICTBUILDER_H_