~zorba-coders/zorba/bugs-912586-912593-912722

« back to all changes in this revision

Viewing changes to src/store/naive/item.cpp

  • Committer: Cezar Andrei
  • Date: 2012-03-28 15:42:12 UTC
  • mfrom: (10606.1.129 zorba)
  • Revision ID: cezar.lp@cezarandrei.com-20120328154212-jh2heq49xcqjppce
Merge from trunck and resolve ChangeLog conflict.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
 
24
24
#include "store/api/item.h"
25
25
#include "store/api/iterator.h"
26
 
#include "store/naive/store_defs.h"
27
 
#include "store/naive/atomic_items.h"
28
 
#include "store/naive/node_items.h"
 
26
#include "store_defs.h"
 
27
#include "atomic_items.h"
 
28
#include "node_items.h"
29
29
 
30
30
#include "runtime/function_item/function_item.h"
31
31
 
52
52
 
53
53
#else
54
54
 
55
 
  if (isNode())
 
55
  switch (getKind())
 
56
  {
 
57
  case NODE:
56
58
  {
57
59
    SYNC_CODE(static_cast<const simplestore::XmlNode*>(this)->getRCLock()->acquire());
58
60
    ++(*theUnion.treeRCPtr);
59
61
    ++theRefCount;
60
62
    SYNC_CODE(static_cast<const simplestore::XmlNode*>(this)->getRCLock()->release());
 
63
    return;
61
64
  }
62
 
  else if (isAtomic() || isError())
 
65
  case ATOMIC:
 
66
  case ERROR_:
63
67
  {
64
68
    SYNC_CODE(static_cast<const simplestore::AtomicItem*>(this)->getRCLock()->acquire());
65
69
    ++theRefCount;
66
70
    SYNC_CODE(static_cast<const simplestore::AtomicItem*>(this)->getRCLock()->release());
 
71
    return;
67
72
  }
68
 
  else if (isList())
 
73
  case LIST:
69
74
  {
70
75
    SYNC_CODE(static_cast<const simplestore::ItemVector*>(this)->getRCLock()->acquire());
71
76
    ++theRefCount;
72
77
    SYNC_CODE(static_cast<const simplestore::ItemVector*>(this)->getRCLock()->release());
 
78
    return;
73
79
  }
74
 
  else if (isFunction())
 
80
  case FUNCTION:
75
81
  {
76
82
    SYNC_CODE(static_cast<const FunctionItem*>(this)->getRCLock()->acquire());
77
83
    ++theRefCount;
78
84
    SYNC_CODE(static_cast<const FunctionItem*>(this)->getRCLock()->release());
 
85
    return;
79
86
  }
80
 
  else
 
87
  case PUL:
81
88
  {
82
89
    ++theRefCount;
83
 
  }
84
 
 
 
90
    return;
 
91
  }
 
92
  default:
 
93
  {
 
94
    ZORBA_ASSERT(false);
 
95
  }  
 
96
  }
85
97
#endif
86
98
}
87
99
 
106
118
 
107
119
#else
108
120
 
109
 
  if (isNode())
 
121
  switch (getKind())
 
122
  {
 
123
  case NODE:
110
124
  {
111
125
    SYNC_CODE(static_cast<const simplestore::XmlNode*>(this)->getRCLock()->acquire());
112
126
 
119
133
    }
120
134
 
121
135
    SYNC_CODE(static_cast<const simplestore::XmlNode*>(this)->getRCLock()->release());
 
136
    return;
122
137
  }
123
 
  else if (isAtomic() || isError())
 
138
  case ATOMIC:
 
139
  case ERROR_:
124
140
  {
125
141
    SYNC_CODE(static_cast<const simplestore::AtomicItem*>(this)->getRCLock()->acquire());
126
142
 
132
148
    }
133
149
 
134
150
    SYNC_CODE(static_cast<const simplestore::AtomicItem*>(this)->getRCLock()->release());
 
151
    return;
135
152
  }
136
 
  else if (isList())
 
153
  case LIST:
137
154
  {
138
155
    SYNC_CODE(static_cast<const simplestore::ItemVector*>(this)->getRCLock()->acquire());
139
156
 
145
162
    }
146
163
 
147
164
    SYNC_CODE(static_cast<const simplestore::ItemVector*>(this)->getRCLock()->release());
 
165
    return;
148
166
  }
149
 
  else if (isFunction())
 
167
  case FUNCTION:
150
168
  {
151
169
    SYNC_CODE(static_cast<const FunctionItem*>(this)->getRCLock()->acquire());
152
170
 
158
176
    }
159
177
 
160
178
    SYNC_CODE(static_cast<const FunctionItem*>(this)->getRCLock()->release());
 
179
    return;
161
180
  }
162
 
  else // PUL
 
181
  case  PUL:
163
182
  {
164
183
    if (--theRefCount == 0)
165
184
      free();
 
185
 
 
186
    return;
 
187
  }
 
188
  default:
 
189
  {
 
190
    ZORBA_ASSERT(false);
 
191
  }
166
192
  }
167
193
 
168
194
#endif
169
195
}
170
196
 
171
197
 
 
198
Item::ItemKind Item::getKind() const
 
199
{
 
200
  //if (theUnion.treeRCPtr == 0)
 
201
  //  return UNKNOWN;
 
202
 
 
203
  if ((reinterpret_cast<uint64_t>(theUnion.treeRCPtr) & 0x1) == 0)
 
204
    return NODE;
 
205
 
 
206
  return static_cast<ItemKind>(theUnion.itemKind);
 
207
}
 
208
 
 
209
 
172
210
bool Item::isNode() const
173
211
{
174
212
  return ((reinterpret_cast<uint64_t>(theUnion.treeRCPtr) & 0x1) == 0 &&
178
216
 
179
217
bool Item::isAtomic() const
180
218
{
181
 
  return ((theUnion.itemKind & ATOMIC) == ATOMIC); 
 
219
  return (theUnion.itemKind == ATOMIC); 
182
220
}
183
221
 
184
222
 
185
223
bool Item::isList() const
186
224
{
187
 
  return ((theUnion.itemKind & LIST) == LIST); 
 
225
  return (theUnion.itemKind == LIST); 
188
226
}
189
227
 
190
228
 
191
229
bool Item::isPul() const
192
230
{
193
 
  return ((theUnion.itemKind & PUL) == PUL);
 
231
  return (theUnion.itemKind == PUL);
194
232
}
195
233
 
196
234
 
197
235
bool Item::isError() const
198
236
{
199
 
  return ((theUnion.itemKind & ERROR_) == ERROR_);
 
237
  return (theUnion.itemKind == ERROR_);
200
238
}
201
239
 
202
240
 
203
241
bool Item::isFunction() const
204
242
{
205
 
  return ((theUnion.itemKind & FUNCTION) == FUNCTION);
 
243
  return (theUnion.itemKind == FUNCTION);
206
244
}
207
245
 
208
246
 
212
250
}
213
251
 
214
252
 
 
253
store::SchemaTypeCode Item::getTypeCode() const
 
254
{
 
255
  throw ZORBA_EXCEPTION(
 
256
    zerr::ZSTR0050_FUNCTION_NOT_IMPLEMENTED_FOR_ITEMTYPE,
 
257
    ERROR_PARAMS( __FUNCTION__, typeid(*this).name() )
 
258
  );
 
259
}
 
260
 
 
261
 
215
262
Item* Item::getType() const
216
263
{
217
264
  throw ZORBA_EXCEPTION(
260
307
}
261
308
 
262
309
 
263
 
Item_t Item::getEBV() const
 
310
bool Item::getEBV() const
264
311
{
265
 
  throw ZORBA_EXCEPTION(
266
 
    zerr::ZSTR0040_TYPE_ERROR,
267
 
    ERROR_PARAMS(
268
 
      ZED( OperationNotDef_23 ), ZED( EffectiveBooleanValue ),
269
 
      getType()->getStringValue()
270
 
    )
271
 
  );
 
312
  throw ZORBA_EXCEPTION(zerr::ZSTR0040_TYPE_ERROR,
 
313
  ERROR_PARAMS(ZED(OperationNotDef_23),
 
314
               ZED(EffectiveBooleanValue),
 
315
               getType()->getStringValue()));
272
316
}
273
317
 
274
318
 
386
430
/**
387
431
 * Accessor for xs:base64Binary
388
432
 */
389
 
xs_base64Binary Item::getBase64BinaryValue() const
 
433
const char* Item::getBase64BinaryValue(size_t&) const
390
434
{
391
435
  throw ZORBA_EXCEPTION(
392
436
    zerr::ZSTR0040_TYPE_ERROR,
397
441
  );
398
442
}
399
443
 
 
444
 
 
445
/**
 
446
 * Checks whether a base64 item's content is already encoded
 
447
 *
 
448
 * @return true only if it is.
 
449
 */
 
450
bool Item::isEncoded() const
 
451
{
 
452
  throw ZORBA_EXCEPTION(
 
453
    zerr::ZSTR0040_TYPE_ERROR,
 
454
    ERROR_PARAMS(
 
455
      ZED( OperationNotDef_23 ), "Item::isEncoded()",
 
456
      getType()->getStringValue()
 
457
    )
 
458
  );
 
459
}
 
460
 
 
461
 
400
462
/**
401
463
 * Accessor for xs:boolean
402
464
 */
508
570
 * Accessor for xs:unsignedLong,  xs:unsignedInt,  xs:unsignedShort,
509
571
 *  xs:unsignedByte, xs:nonNegativeInteager, xs:positiveInteger
510
572
 */
511
 
xs_uinteger Item::getUnsignedIntegerValue() const
 
573
xs_nonNegativeInteger Item::getUnsignedIntegerValue() const
512
574
{
513
575
  throw ZORBA_EXCEPTION(
514
576
    zerr::ZSTR0040_TYPE_ERROR,