ooRexx  4.2.0-source
About: ooRexx (Open Object Rexx) is a free implementation of Object Rexx. Object Rexx is an enhancement of the classic Rexx interpreter; a full-featured programming language with a human-oriented syntax.
  Fossies Dox: ooRexx-4.2.0-source.tar.gz  ("inofficial" and yet experimental doxygen-generated source code documentation)  

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);
105  RexxObject *bracketEqual(RexxObject **, size_t);
106 
107  RexxObject *hasIndex(RexxObject **, size_t);
108  RexxObject *remove(RexxObject **, size_t);
113 
114 
115  RexxString *tail(RexxArray *, size_t);
116  RexxObject *newRexx(RexxObject **, 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
RexxStem::realCompoundVariableValue
RexxObject * realCompoundVariableValue(RexxCompoundTail *resolved_tail)
Definition: StemClass.cpp:803
RexxArray
Definition: ArrayClass.hpp:100
RexxCompoundElement
Definition: RexxCompoundElement.hpp:50
RexxStem::request
RexxObject * request(RexxString *)
Definition: StemClass.cpp:477
RexxStem::items
size_t items()
Definition: StemClass.cpp:921
RexxStem::handleNovalue
RexxObject * handleNovalue(RexxActivation *context, RexxString *name, RexxObject *defaultValue, RexxCompoundElement *variable)
Definition: StemClass.cpp:830
RexxStem::allIndexes
RexxArray * allIndexes()
Definition: StemClass.cpp:970
RexxStem::doubleValue
bool doubleValue(double &result)
Definition: StemClass.cpp:451
RexxCompoundTable.hpp
RexxStem::numberValue
bool numberValue(wholenumber_t &result, size_t precision)
Definition: StemClass.cpp:419
RexxStem::hasIndex
RexxObject * hasIndex(RexxObject **, size_t)
Definition: StemClass.cpp:234
type
int type
Definition: cmdparse.cpp:1965
SortData::columnLength
stringsize_t columnLength
Definition: StemClass.hpp:66
RexxStem::bracket
RexxObject * bracket(RexxObject **, size_t)
Definition: StemClass.cpp:206
RexxStem::dropped
bool dropped
Definition: StemClass.hpp:161
RexxStem::merge
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:1278
RexxStem::dropCompoundVariable
void dropCompoundVariable(RexxCompoundTail *name)
Definition: StemClass.cpp:600
RexxStem::dropValue
void dropValue()
Definition: StemClass.cpp:163
RexxStem::integerValue
RexxInteger * integerValue(size_t)
Definition: StemClass.cpp:468
RexxStem::newRexx
RexxObject * newRexx(RexxObject **, size_t)
Definition: StemClass.cpp:505
RexxStem::index
RexxObject * index(RexxObject *)
Definition: StemClass.cpp:337
RexxStem::setCompoundVariable
void setCompoundVariable(RexxCompoundTail *name, RexxObject *value)
Definition: StemClass.cpp:640
RexxStem::mergeSort
void mergeSort(SortData *sd, int(*comparator)(SortData *, RexxString *, RexxString *), RexxString **strings, RexxString **working, size_t left, size_t right)
Definition: StemClass.cpp:1241
RexxStem::exposeCompoundVariable
RexxCompoundElement * exposeCompoundVariable(RexxCompoundTail *name)
Definition: StemClass.cpp:552
RexxStem::getCompoundVariable
RexxCompoundElement * getCompoundVariable(RexxCompoundTail *name)
Definition: StemClass.cpp:540
RexxStem::value
RexxObject * value
Definition: StemClass.hpp:160
RexxStem::tail
RexxString * tail(RexxArray *, size_t)
RexxStem::bracketEqual
RexxObject * bracketEqual(RexxObject **, size_t)
Definition: StemClass.cpp:359
RexxSupplier
Definition: SupplierClass.hpp:47
RexxStem::liveGeneral
void liveGeneral(int reason)
Definition: StemClass.cpp:127
RexxEnvelope
Definition: RexxEnvelope.hpp:53
RexxStem::getCompoundVariableValue
RexxObject * getCompoundVariableValue(RexxCompoundTail *resolved_tail)
Definition: StemClass.cpp:730
RexxStem::unknown
RexxObject * unknown(RexxString *, RexxArray *)
Definition: StemClass.cpp:185
RexxStem::first
RexxCompoundElement * first()
Definition: StemClass.hpp:140
SortData::startColumn
stringsize_t startColumn
Definition: StemClass.hpp:65
RexxStem::makeArray
RexxArray * makeArray()
Definition: StemClass.cpp:402
ExpressionStem.hpp
RexxStem
Definition: StemClass.hpp:70
RexxStem::stemName
RexxString * stemName
Definition: StemClass.hpp:158
RexxStem::dropElement
void dropElement(const char *tail)
Definition: StemClass.cpp:1146
RexxStem::hasItem
RexxObject * hasItem(RexxObject *)
Definition: StemClass.cpp:299
RexxStem::copyFrom
void copyFrom(RexxCompoundTable &_tails)
Definition: StemClass.cpp:109
OREF_NULL
#define OREF_NULL
Definition: RexxCore.h:60
SortData
Definition: StemClass.hpp:62
RexxStem::classInstance
static RexxClass * classInstance
Definition: StemClass.hpp:154
RexxStem::createCompoundName
RexxString * createCompoundName(RexxCompoundTail *tailPart)
Definition: StemClass.cpp:1178
RexxStem::numberString
RexxNumberString * numberString()
Definition: StemClass.cpp:459
RexxStem::init
void init()
Definition: StemClass.hpp:142
RexxDirectory
Definition: DirectoryClass.hpp:49
RexxClass
Definition: ClassClass.hpp:49
RexxStem::createInstance
static void createInstance()
Definition: StemClass.cpp:63
RexxCompoundTable::init
void init(RexxStem *parent)
Definition: RexxCompoundTable.cpp:49
RexxStem::sort
bool sort(RexxString *prefix, int order, int type, size_t start, size_t end, size_t firstcol, size_t lastcol)
Definition: StemClass.cpp:1416
RexxStem::copy
RexxObject * copy()
Definition: StemClass.cpp:91
RexxStem::tails
RexxCompoundTable tails
Definition: StemClass.hpp:159
RexxStem::setElement
void setElement(const char *tail, RexxObject *value)
Definition: StemClass.cpp:1051
RexxStem::allItems
RexxArray * allItems()
Definition: StemClass.cpp:872
RexxStem::supplier
RexxSupplier * supplier()
Definition: StemClass.cpp:982
RexxStem::remove
RexxObject * remove(RexxObject **, size_t)
Definition: StemClass.cpp:265
RexxStem::getName
RexxString * getName()
Definition: StemClass.hpp:139
RexxCompoundTable::first
RexxCompoundElement * first()
Definition: RexxCompoundTable.cpp:268
RexxStem::findCompoundVariable
RexxCompoundElement * findCompoundVariable(RexxCompoundTail *name)
Definition: StemClass.cpp:583
RexxStem::getStemValue
RexxObject * getStemValue()
Definition: StemClass.cpp:179
RexxActivation
Definition: RexxActivation.hpp:156
RexxStem::compoundVariableExists
bool compoundVariableExists(RexxCompoundTail *resolved_tail)
Definition: StemClass.hpp:138
RexxStem::RexxStem
RexxStem(RexxString *)
Definition: StemClass.cpp:69
RexxNumberString
Definition: NumberStringClass.hpp:93
wholenumber_t
ssize_t wholenumber_t
Definition: rexx.h:229
RexxCompoundElement.hpp
stringsize_t
size_t stringsize_t
Definition: rexx.h:228
RexxStem::empty
RexxObject * empty()
Definition: StemClass.cpp:946
RexxStem::getCompoundVariableRealValue
RexxObject * getCompoundVariableRealValue(RexxCompoundTail *resolved_tail)
Definition: StemClass.cpp:780
RexxStem::RexxStem
RexxStem(RESTORETYPE restoreType)
Definition: StemClass.hpp:76
RexxCompoundTable
Definition: RexxCompoundTable.hpp:66
RexxNativeActivation
Definition: RexxNativeActivation.hpp:62
RexxStem::isEmpty
RexxObject * isEmpty()
Definition: StemClass.cpp:958
RexxStem::tailArray
RexxArray * tailArray()
Definition: StemClass.cpp:652
RexxStem::find
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:1371
RexxObject::start
RexxMessage * start(RexxObject **, size_t)
Definition: ObjectClass.cpp:1761
RexxStem::unsignedNumberValue
bool unsignedNumberValue(stringsize_t &result, size_t precision)
Definition: StemClass.cpp:435
RexxStem::itemsRexx
RexxObject * itemsRexx()
Definition: StemClass.cpp:353
RexxStem::live
void live(size_t)
Definition: StemClass.cpp:116
RexxStem::setValue
void setValue(RexxObject *value)
Definition: StemClass.cpp:153
RexxStem::expose
void expose(RexxCompoundElement *variable)
Definition: StemClass.cpp:854
RexxStem::getElement
RexxObject * getElement(size_t tail)
Definition: StemClass.cpp:1082
RexxStem::stringValue
RexxString * stringValue()
Definition: StemClass.cpp:410
RexxStem::findByValue
RexxCompoundElement * findByValue(RexxObject *target)
Definition: StemClass.cpp:899
RESTORETYPE
RESTORETYPE
Definition: ObjectClass.hpp:80
RexxCompoundTail
Definition: RexxCompoundTail.hpp:52
RexxStem::removeItem
RexxObject * removeItem(RexxObject *)
Definition: StemClass.cpp:314
RexxInteger
Definition: IntegerClass.hpp:56
RexxStem::nextVariable
RexxCompoundElement * nextVariable(RexxNativeActivation *activation)
Definition: StemClass.cpp:611
RexxStem::flatten
void flatten(RexxEnvelope *)
Definition: StemClass.cpp:138
RexxStem::toDirectory
RexxDirectory * toDirectory()
Definition: StemClass.cpp:1025
RexxStem::evaluateCompoundVariableValue
RexxObject * evaluateCompoundVariableValue(RexxActivation *context, RexxString *stemVariableName, RexxCompoundTail *resolved_tail)
Definition: StemClass.cpp:678
RexxObject
Definition: ObjectClass.hpp:311
RexxStem::arraycopy
void arraycopy(RexxString **source, size_t start, RexxString **target, size_t index, size_t count)
Definition: StemClass.cpp:1346
RexxString
Definition: StringClass.hpp:119