StemClass.hpp
Go to the documentation of this file.
1 /*----------------------------------------------------------------------------*/
2 /* */
3 /* Copyright (c) 1995, 2004 IBM Corporation. All rights reserved. */
4 /* Copyright (c) 2005-2009 Rexx Language Association. All rights reserved. */
5 /* */
6 /* This program and the accompanying materials are made available under */
7 /* the terms of the Common Public License v1.0 which accompanies this */
8 /* distribution. A copy is also available at the following address: */
9 /* http://www.oorexx.org/license.html */
10 /* */
11 /* Redistribution and use in source and binary forms, with or */
12 /* without modification, are permitted provided that the following */
13 /* conditions are met: */
14 /* */
15 /* Redistributions of source code must retain the above copyright */
16 /* notice, this list of conditions and the following disclaimer. */
17 /* Redistributions in binary form must reproduce the above copyright */
18 /* notice, this list of conditions and the following disclaimer in */
19 /* the documentation and/or other materials provided with the distribution. */
20 /* */
21 /* Neither the name of Rexx Language Association nor the names */
22 /* of its contributors may be used to endorse or promote products */
23 /* derived from this software without specific prior written permission. */
24 /* */
25 /* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
26 /* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
27 /* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
28 /* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT */
29 /* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
30 /* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED */
31 /* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, */
32 /* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY */
33 /* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING */
34 /* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS */
35 /* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
36 /* */
37 /*----------------------------------------------------------------------------*/
38 /******************************************************************************/
39 /* REXX Kernel StemClass.hpp */
40 /* */
41 /* Primitive Stem Class Definitions */
42 /* */
43 /******************************************************************************/
44 #ifndef Included_RexxStem
45 #define Included_RexxStem
46 
47 #include "RexxCompoundElement.hpp"
48 #include "RexxCompoundTable.hpp"
49 #include "ExpressionStem.hpp"
50 
51 #define SORT_CASESENSITIVE 0
52 #define SORT_CASEIGNORE 1
53 
54 #define SORT_ASCENDING 0
55 #define SORT_DECENDING 1
56 
57 class RexxSupplier;
58 class RexxDirectory;
59 class RexxCompoundTail;
61 
62  class SortData
63  {
64  public:
67  };
68 
69 
70  class RexxStem : public RexxObject {
71  friend class RexxCompoundTable;
72  public:
73  void *operator new (size_t);
74  inline void *operator new(size_t size, void *ptr) {return ptr;};
76  inline RexxStem(RESTORETYPE restoreType) { ; };
77  void live(size_t);
78  void liveGeneral(int reason);
79  void flatten(RexxEnvelope*);
80  RexxObject * copy();
81 
82  void copyFrom(RexxCompoundTable &_tails);
83  bool numberValue(wholenumber_t &result, size_t precision);
84  bool numberValue(wholenumber_t &result);
85  bool unsignedNumberValue(stringsize_t &result, size_t precision);
86  bool unsignedNumberValue(stringsize_t &result);
87  bool doubleValue(double &result);
89  RexxInteger *integerValue(size_t);
97  RexxObject *empty();
99  size_t items();
100 
101  void dropValue();
104  RexxObject *bracket (RexxObject **, size_t, size_t);
105  RexxObject *bracketEqual(RexxObject **, size_t, size_t);
106 
107  RexxObject *hasIndex(RexxObject **, size_t, size_t);
108  RexxObject *remove(RexxObject **, size_t, size_t);
113 
114 
115  RexxString *tail(RexxArray *, size_t);
116  RexxObject *newRexx(RexxObject **, size_t, size_t);
117  RexxObject *evaluateCompoundVariableValue(RexxActivation *context, RexxString *stemVariableName, RexxCompoundTail *resolved_tail);
127  void setValue(RexxObject *value);
128  RexxArray *tailArray();
130  RexxObject *handleNovalue(RexxActivation *context, RexxString *name, RexxObject *defaultValue, RexxCompoundElement *variable);
131  void expose(RexxCompoundElement *variable);
132  bool sort(RexxString *prefix, int order, int type, size_t start, size_t end, size_t firstcol, size_t lastcol);
133  void mergeSort(SortData *sd, int (*comparator)(SortData *, RexxString *, RexxString *), RexxString **strings, RexxString **working, size_t left, size_t right);
134  void merge(SortData *sd, int (*comparator)(SortData *, RexxString *, RexxString *), RexxString **strings, RexxString **working, size_t left, size_t mid, size_t right);
135  size_t find(SortData *sd, int (*comparator)(SortData *, RexxString *, RexxString *), RexxString **strings, RexxString *val, int bnd, size_t left, size_t right);
136  void arraycopy(RexxString **source, size_t start, RexxString **target, size_t index, size_t count);
137 
138  inline bool compoundVariableExists(RexxCompoundTail *resolved_tail) { return realCompoundVariableValue(resolved_tail) != OREF_NULL; }
139  inline RexxString *getName() { return stemName; }
140  inline RexxCompoundElement *first() { return tails.first(); }
142  inline void init() { tails.init(this); }
143 
144  void setElement(const char *tail, RexxObject *value);
145  void setElement(size_t tail, RexxObject *value);
146  void dropElement(const char *tail);
147  void dropElement(size_t tail);
149  RexxObject *getElement(size_t tail);
150  RexxObject *getElement(const char *tail);
152 
153  static void createInstance();
155 
156  protected:
157 
158  RexxString *stemName; // the name of the stem
159  RexxCompoundTable tails; /* the table of compound tails */
160  RexxObject *value; /* value of the stem */
161  bool dropped; /* stem has no explicit value */
162 
163  };
164  #endif
RESTORETYPE
Definition: ObjectClass.hpp:82
#define OREF_NULL
Definition: RexxCore.h:61
void init(RexxStem *parent)
RexxCompoundElement * first()
RexxMessage * start(RexxObject **, size_t, size_t)
bool numberValue(wholenumber_t &result, size_t precision)
Definition: StemClass.cpp:451
RexxString * createCompoundName(RexxCompoundTail *tailPart)
Definition: StemClass.cpp:1219
RexxObject * itemsRexx()
Definition: StemClass.cpp:384
RexxCompoundElement * getCompoundVariable(RexxCompoundTail *name)
Definition: StemClass.cpp:581
RexxObject * getCompoundVariableValue(RexxCompoundTail *resolved_tail)
Definition: StemClass.cpp:771
size_t items()
Definition: StemClass.cpp:962
RexxObject * remove(RexxObject **, size_t, size_t)
Definition: StemClass.cpp:296
void mergeSort(SortData *sd, int(*comparator)(SortData *, RexxString *, RexxString *), RexxString **strings, RexxString **working, size_t left, size_t right)
Definition: StemClass.cpp:1282
RexxCompoundElement * exposeCompoundVariable(RexxCompoundTail *name)
Definition: StemClass.cpp:593
void dropValue()
Definition: StemClass.cpp:163
RexxCompoundTable tails
Definition: StemClass.hpp:159
RexxObject * newRexx(RexxObject **, size_t, size_t)
Definition: StemClass.cpp:538
RexxObject * getCompoundVariableRealValue(RexxCompoundTail *resolved_tail)
Definition: StemClass.cpp:821
static RexxClass * classInstance
Definition: StemClass.hpp:154
void flatten(RexxEnvelope *)
Definition: StemClass.cpp:138
void init()
Definition: StemClass.hpp:142
RexxArray * makeArray()
Definition: StemClass.cpp:434
RexxCompoundElement * first()
Definition: StemClass.hpp:140
void setElement(const char *tail, RexxObject *value)
Definition: StemClass.cpp:1092
RexxInteger * integerValue(size_t)
Definition: StemClass.cpp:500
void copyFrom(RexxCompoundTable &_tails)
Definition: StemClass.cpp:109
bool sort(RexxString *prefix, int order, int type, size_t start, size_t end, size_t firstcol, size_t lastcol)
Definition: StemClass.cpp:1457
RexxNumberString * numberString()
Definition: StemClass.cpp:491
RexxString * tail(RexxArray *, size_t)
void dropCompoundVariable(RexxCompoundTail *name)
Definition: StemClass.cpp:641
RexxObject * copy()
Definition: StemClass.cpp:91
void setCompoundVariable(RexxCompoundTail *name, RexxObject *value)
Definition: StemClass.cpp:681
void live(size_t)
Definition: StemClass.cpp:116
RexxObject * getStemValue()
Definition: StemClass.cpp:179
RexxObject * isEmpty()
Definition: StemClass.cpp:999
static void createInstance()
Definition: StemClass.cpp:63
RexxObject * index(RexxObject *)
Definition: StemClass.cpp:368
RexxArray * allItems()
Definition: StemClass.cpp:913
RexxString * stringValue()
Definition: StemClass.cpp:442
bool unsignedNumberValue(stringsize_t &result, size_t precision)
Definition: StemClass.cpp:467
RexxSupplier * supplier()
Definition: StemClass.cpp:1023
void merge(SortData *sd, int(*comparator)(SortData *, RexxString *, RexxString *), RexxString **strings, RexxString **working, size_t left, size_t mid, size_t right)
Definition: StemClass.cpp:1319
RexxCompoundElement * nextVariable(RexxNativeActivation *activation)
Definition: StemClass.cpp:652
RexxStem(RexxString *)
Definition: StemClass.cpp:69
RexxObject * handleNovalue(RexxActivation *context, RexxString *name, RexxObject *defaultValue, RexxCompoundElement *variable)
Definition: StemClass.cpp:871
RexxArray * tailArray()
Definition: StemClass.cpp:693
RexxObject * bracketEqual(RexxObject **, size_t, size_t)
Definition: StemClass.cpp:390
size_t find(SortData *sd, int(*comparator)(SortData *, RexxString *, RexxString *), RexxString **strings, RexxString *val, int bnd, size_t left, size_t right)
Definition: StemClass.cpp:1412
RexxCompoundElement * findCompoundVariable(RexxCompoundTail *name)
Definition: StemClass.cpp:624
RexxObject * empty()
Definition: StemClass.cpp:987
void expose(RexxCompoundElement *variable)
Definition: StemClass.cpp:895
RexxObject * evaluateCompoundVariableValue(RexxActivation *context, RexxString *stemVariableName, RexxCompoundTail *resolved_tail)
Definition: StemClass.cpp:719
void dropElement(const char *tail)
Definition: StemClass.cpp:1187
RexxString * stemName
Definition: StemClass.hpp:158
RexxCompoundElement * findByValue(RexxObject *target)
Definition: StemClass.cpp:940
RexxObject * bracket(RexxObject **, size_t, size_t)
Definition: StemClass.cpp:236
bool dropped
Definition: StemClass.hpp:161
RexxObject * getElement(size_t tail)
Definition: StemClass.cpp:1123
RexxStem(RESTORETYPE restoreType)
Definition: StemClass.hpp:76
RexxDirectory * toDirectory()
Definition: StemClass.cpp:1066
RexxObject * realCompoundVariableValue(RexxCompoundTail *resolved_tail)
Definition: StemClass.cpp:844
RexxObject * removeItem(RexxObject *)
Definition: StemClass.cpp:345
RexxObject * request(RexxString *)
Definition: StemClass.cpp:509
void liveGeneral(int reason)
Definition: StemClass.cpp:127
RexxObject * hasIndex(RexxObject **, size_t, size_t)
Definition: StemClass.cpp:265
void setValue(RexxObject *value)
Definition: StemClass.cpp:153
RexxObject * hasItem(RexxObject *)
Definition: StemClass.cpp:330
bool compoundVariableExists(RexxCompoundTail *resolved_tail)
Definition: StemClass.hpp:138
RexxObject * value
Definition: StemClass.hpp:160
RexxArray * allIndexes()
Definition: StemClass.cpp:1011
RexxString * getName()
Definition: StemClass.hpp:139
void arraycopy(RexxString **source, size_t start, RexxString **target, size_t index, size_t count)
Definition: StemClass.cpp:1387
RexxObject * unknown(RexxString *, RexxArray *, RexxDirectory *)
Definition: StemClass.cpp:185
bool doubleValue(double &result)
Definition: StemClass.cpp:483
stringsize_t startColumn
Definition: StemClass.hpp:65
stringsize_t columnLength
Definition: StemClass.hpp:66
int type
Definition: cmdparse.cpp:1888
ssize_t wholenumber_t
Definition: rexx.h:230
size_t stringsize_t
Definition: rexx.h:228