File: SUniMap.h

package info (click to toggle)
yudit 3.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 18,472 kB
  • sloc: cpp: 76,344; perl: 5,630; makefile: 989; ansic: 823; sh: 441
file content (116 lines) | stat: -rw-r--r-- 3,087 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
112
113
114
115
116
/** 
 *  Yudit Unicode Editor Source File
 *
 *  GNU Copyright (C) 1997-2023  Gaspar Sinai <gaspar@yudit.org>  
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License, version 2,
 *  dated June 1991. See file COPYYING for details.
 *
 *  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., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
 
#ifndef SUniMap_h
#define SUniMap_h

#include "stoolkit/STypes.h"
#include "stoolkit/SObject.h"
#include "stoolkit/SString.h"
#include "stoolkit/SStringVector.h"

/**
 * A unicode Map. It maps SV_UCS2 to SV_UCS4. It is generally useful
 * When mapping UCS4 to Font encodings. 
 * This is mase upong the .my maps
 * @author: Gaspar Sinai <gaspar@yudit.org>
 * @version: 2000-05-12
 */
class SUniMap  : public SObject
{
public:
  SUniMap (void);
  SUniMap (const SString& name);
  SUniMap (const SUniMap &m);
  SUniMap& operator = (const SUniMap &m);   
  virtual ~SUniMap();
  virtual SObject* clone () const;
  
  SS_UCS4 decode (SS_UCS2 in);
  SS_UCS2 encode (SS_UCS4 in);
  unsigned int getDecoderMap (SStringVector* key, SStringVector* value,
        unsigned int size);

  /*
   * Convert whatever is in 'in' if possible. 
   * and remove it.
   */
  unsigned int  lift (const SV_UCS4& in, unsigned int ini, 
           bool decode, SV_UCS4* out=0);

  int getInWordSize(bool encode);
  int getOutWordSize(bool encode);

  bool isOK() const;

  static void setPath(const SStringVector &p);
  static void guessPath();
  static const SStringVector& getPath();

  /* State keeping coder. */
  void reset(bool encode);
  void reset();
  void undo (bool encode);

  const SV_UCS4& decode (const SString& in);
  const SString& encode (const SV_UCS4& in);

  const SString& encodeBuffer();
  const SV_UCS4& decodeBuffer();

  /* For maps with holes */
  unsigned int getDecodePosition (SS_UCS4 key);
  SS_UCS4 getDecodeKey (unsigned int position);
  SS_UCS4 getDecodeValue (unsigned int position);

  unsigned int getEncodePosition (SS_UCS4 key);
  SS_UCS4 getEncodeKey (unsigned int position);
  SS_UCS4 getEncodeValue (unsigned int position);

  /* Vector all maps available on this path */
  static SStringVector list ();
  const SString& remainder() const;

  bool isUMap() const;
  bool isClustered() const;

protected:
  void load (const SString& name);
  void derefer();
  void setModel(int din, int dout, int ein, int eout);
  int  indexOf (bool encode) const;
  bool ok;
  void* bumap;
  int   eindex;
  int   dindex;

  void* delegate;
  void* dmodel;
  void* emodel;

  void* dmodel4;
  void* emodel4;

  SV_UCS4 ucs4vIn;
  SV_UCS4 ucs4vOut;
  SString sstringIn;
  SString sstringOut;
};

#endif /* SUniMap_h */