-
Notifications
You must be signed in to change notification settings - Fork 1
/
dsl.hh
108 lines (81 loc) · 2.2 KB
/
dsl.hh
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
#ifndef __DSL_HH_INCLUDED__
#define __DSL_HH_INCLUDED__
#include <stdint.h>
#include <string>
#include <map>
#include <QVector>
#include "wstring.hh"
#include "dsl_details.hh"
#include "dictzip.h"
using gd::wstring;
using std::string;
using std::map;
using namespace Dsl::Details;
struct InsidedCard
{
uint32_t offset;
uint32_t size;
QVector< wstring > headwords;
InsidedCard( uint32_t _offset, uint32_t _size, QVector< wstring > const & words ) :
offset( _offset ), size( _size ), headwords( words )
{}
InsidedCard( InsidedCard const & e ) :
offset( e.offset ), size( e.size ), headwords( e.headwords )
{}
InsidedCard() {}
};
struct DslCard
{
uint32_t offset;
uint32_t size;
QVector< wstring > headwords;
DslCard( uint32_t _offset, uint32_t _size, QVector< wstring > const & words ) :
offset( _offset ), size( _size ), headwords( words )
{}
DslCard( DslCard const & e ) :
offset( e.offset ), size( e.size ), headwords( e.headwords )
{}
DslCard() {}
};
struct DictParameters
{
wstring name;
wstring langFrom;
wstring langTo;
DslEncoding encoding;
bool langFromRTL;
bool langToRTL;
};
class DslDictionary
{
int optionalPartNom;
QVector< DslCard > allCards;
DictParameters params;
map< string, string > abrv;
dictData * dz;
public:
DslDictionary() :
optionalPartNom( 0 ),
dz( 0 )
{};
~DslDictionary();
string getId();
QVector< DslCard > const & getCards() const
{ return allCards; }
DictParameters const & getParams() const
{ return params; }
int setFiles( string const & dsl_name, string const & abr_name );
int getArticle( DslCard const & card, string & article );
QString getDescription( string const & dsl_name );
protected:
void loadArticle( DslCard const & card,
wstring const & requestedHeadwordFolded,
wstring & tildeValue,
wstring & displayedHeadword,
unsigned & headwordIndex,
wstring & articleText );
string dslToHtml( wstring const & str, wstring const & headword );
string processNodeChildren( ArticleDom::Node const & node );
string nodeToHtml( ArticleDom::Node const & node );
};
#endif // __DSL_HH_INCLUDED__