• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // © 2017 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
3 /*
4 *******************************************************************************
5 *
6 *   Copyright (C) 2003, International Business Machines
7 *   Corporation and others.  All Rights Reserved.
8 *
9 *******************************************************************************
10 *
11 * File line.h
12 *
13 * Modification History:
14 *
15 *   Date        Name        Description
16 *   03/18/2003  weiv        Creation.
17 *******************************************************************************
18 */
19 
20 //
21 //   class Line
22 //
23 //      Each line from the source file (containing a name, presumably) gets
24 //      one of these structs.
25 //
26 
27 #ifndef COLPROBE_LINE_H
28 #define COLPROBE_LINE_H
29 #include "unicode/utypes.h"
30 #include "unicode/ucol.h"
31 #include "unicode/ustring.h"
32 #include "unicode/unistr.h"
33 #include "unicode/uchar.h"
34 #include "unicode/uniset.h"
35 #include "colprobe.h"
36 
37 #include <stdlib.h>
38 #include <string.h>
39 
40 static const int MAX_EXPANSION_PREFIXES = 10;
41 
42 class  Line {
43 public:
44   static void copyArray(Line *dest, const Line *src, int32_t size);
45   Line();
46   Line(const Line &other);
47   Line(const UChar* name, int32_t len);
48   Line(const UnicodeString &string);
49   Line(const UChar name);
50   Line(const char *buff, int32_t buffLen, UErrorCode &status);
51   ~Line();
52   Line & operator=(const Line &other);
53   UBool operator==(const Line &other) const;
54   UBool operator!=(const Line &other) const;
55   void setToConcat(const Line *first, const Line *second);
56   void setName(const UChar* name, int32_t len);
57   UnicodeString toString(UBool pretty = FALSE);
58   UnicodeString toBundleString();
59   UnicodeString toHTMLString();
60   int32_t write(char *buff, int32_t buffLen, UErrorCode &status);
61   void initFromString(const char *buff, int32_t buffLen, UErrorCode &status);
62 
63 
64   UnicodeString strengthIndent(UColAttributeValue strength, int indentSize, UnicodeString &result);
65   UnicodeString strengthToString(UColAttributeValue strength, UBool pretty, UBool html = FALSE);
66   UnicodeString stringToName(UChar *string, int32_t len);
67   void setTo(const UnicodeString &string);
68   void setTo(const UChar32 n);
69   UBool equals(const Line &other) const;
70   Line *nextInteresting();
71   void append(const UChar n);
72   void append(const UChar* n, int32_t length);
73   void append(const Line &l);
74   void clear();
75   void swapCase();
76   void swapCase(UChar *string, int32_t &sLen);
77   UnicodeString dumpSortkey();
78   void init();
79 
80 
81 public:
82     UChar     name[25];
83     int32_t   len;
84     UChar     expansionString[25];
85     int32_t   expLen;
86 
87     UColAttributeValue strength;
88     UColAttributeValue strengthFromEmpty;
89     UColAttributeValue cumulativeStrength;
90     UColAttributeValue expStrength;
91 
92     Line *previous;
93     Line *next;
94 
95     // In case this element is a contraction
96     // we keep a pointer at which lines were components
97     Line *left;
98     Line *right;
99 
100     UBool   isContraction;
101     UBool   isExpansion;
102     UBool   isRemoved;
103     UBool   isReset;
104 
105     int32_t expIndex;
106     uint8_t firstCC;
107     uint8_t lastCC;
108 
109     uint8_t   *sortKey;
110 public:
111   static UnicodeSet *needsQuoting;
112 };
113 
114 
115 #endif //COLPROBE_LINE_H
116