1 /***************************************************************************
2                           Locations.h - Handle position specific info
3                              -------------------
4     begin                : Thu Mar  1 13:15:18 IST 2001
5     copyright            : (C) 2001 by Arie Tal
6     email                : tal_arie@yahoo.com
7  ***************************************************************************/
8 
9 /***************************************************************************
10  *                                                                         *
11  *   This program is free software; you can redistribute it and/or modify  *
12  *   it under the terms of the GNU General Public License as published by  *
13  *   the Free Software Foundation; either version 2 of the License, or     *
14  *   (at your option) any later version.                                   *
15  *                                                                         *
16  ***************************************************************************/
17 
18 #ifndef __Locations_h__
19 #define __Locations_h__
20 
21 #include "Array.h"
22 #include "aString.h"
23 #include "Screen.h"
24 #define SPLIT_VALUE    32766
25 
26 #define MAX_BUFF_LEN 16384
27 
28 enum hebStringMode { StrHebrew, StrEnglish } ;
29 
30 #define HEBREW 0x01
31 #define ENGLISH 0x02
32 #define INVALID_HEBREW_WORD 0x04
33 #define INVALID_ENGLISH_WORD 0x08
34 #define INVALID_LAXET_COMMAND 0x10
35 #define VALID_LAXET_COMMAND 0x20
36 
37 class Location {
38   int offset ;
39   unsigned char code ;
40 public:
41   int operator=(int x) { return offset = x ; }
42   Location& operator=(Location& l) { offset = l.offset ; code = l.code ;
43                                      return *this ; }
44   int operator==(int x) {return offset == x ; }
45   int operator==(Location& l) {return (offset == l.offset) &&
46                                  (code == l.code) ; }
47   operator int() { return offset ; }
Location()48   Location() { offset = 0 ; code = 0 ; }
49   Location(int x, char c=0) { offset = x ; c=0 ; }
Location(Location & l)50   Location(Location &l) { offset = l.offset ; code = l.code ; }
setCode(char x)51   void setCode(char x) { code = x ; }
setOffset(int x)52   void setOffset(int x) { offset = x ; }
getCode()53   char getCode() { return code ; }
54 } ;
55 
56 // typedef int Location  ;
57 
58 class Locations {
59 private:
60     Array<Location> _locs ;
61     static Location *workArea ;
62     Location result ;
63     int _last ;
64     int _minVal ;
65 public:
Locations()66    Locations() : _last(0), _minVal(0) {}
Locations(int last)67    Locations(int last) : _last(last), _minVal(0) {}
Locations(Locations & l)68    Locations(Locations &l) : _locs(l._locs) , _last(l._last), _minVal(l._minVal) {}
~Locations()69    ~Locations() { _locs.clear() ; }
70 
71    void addLeft(char *buf, hebStringMode lang=StrEnglish, char code=0) ;
72    void addLeft(aString str, hebStringMode lang=StrEnglish, char code=0) ;
73    void addLeft(Locations &l) ;
74    void addLeft(Locations *l) ;
75 
76    void addRight(char *buf, hebStringMode lang=StrEnglish, char code=0) ;
77    void addRight(aString str, hebStringMode lang=StrEnglish, char code=0) ;
78    void addRight(Locations &l) ;
79    void addRight(Locations *l) ;
80 
81    void addSplitsLeft(int num, hebStringMode lang=StrHebrew) ;
82    void addSplitsRight(int num, hebStringMode lang=StrHebrew) ;
init(int last)83    void init(int last) { _locs.clear() ; _last = last ; }
last()84    int last() { return _last; }
85    Location operator[](int n) ;
getMinVal()86    int getMinVal() { return _minVal ; }
setMinVal(int m)87    int setMinVal(int m) { return _minVal = m ; } // PORT: return
getMaxVal()88    int getMaxVal() { return _last + _minVal ; }
89    void print() ;
90    void clearCodes() ;
91 } ;
92 
93 #endif
94