~paul-lucas/zorba/bug-932374

« back to all changes in this revision

Viewing changes to src/api/item.cpp

  • Committer: Paul J. Lucas
  • Date: 2012-09-21 20:26:47 UTC
  • mfrom: (10819.2.235 zorba)
  • Revision ID: paul@lucasmail.org-20120921202647-fy9n4jduhrnljrnb
MergeĀ fromĀ trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
#include "store/api/iterator.h"
38
38
#include "store/api/collection.h"
39
39
 
 
40
#include <zorbatypes/numconversions.h>
40
41
 
41
42
namespace zorba {
42
43
 
182
183
  return Item();
183
184
}
184
185
 
 
186
#ifdef ZORBA_WITH_JSON
 
187
 
 
188
bool
 
189
Item::isJSONItem() const
 
190
{
 
191
  ITEM_TRY
 
192
    return m_item->isJSONItem();
 
193
  ITEM_CATCH
 
194
  return false;
 
195
}
 
196
 
 
197
#endif /* ZORBA_WITH_JSON */
185
198
 
186
199
Iterator_t Item::getAtomizationValue() const
187
200
{
460
473
  return -1;
461
474
}
462
475
 
 
476
#ifdef ZORBA_WITH_JSON
 
477
 
 
478
store::StoreConsts::JSONItemKind
 
479
Item::getJSONItemKind() const
 
480
{
 
481
  ITEM_TRY
 
482
    SYNC_CODE(AutoLock lock(GENV_STORE.getGlobalLock(), Lock::READ);)
 
483
 
 
484
    return m_item->getJSONItemKind();
 
485
  ITEM_CATCH
 
486
  return store::StoreConsts::jsonItem;
 
487
}
 
488
 
 
489
 
 
490
uint64_t
 
491
Item::getArraySize() const
 
492
{
 
493
  ITEM_TRY
 
494
    SYNC_CODE(AutoLock lock(GENV_STORE.getGlobalLock(), Lock::READ);)
 
495
 
 
496
    return to_xs_long(m_item->getArraySize());
 
497
  ITEM_CATCH
 
498
  return 0;
 
499
}
 
500
 
 
501
 
 
502
Item
 
503
Item::getArrayValue(uint32_t aIndex) const
 
504
{
 
505
  ITEM_TRY
 
506
    SYNC_CODE(AutoLock lock(GENV_STORE.getGlobalLock(), Lock::READ);)
 
507
    xs_integer lIndex(aIndex);
 
508
    return &*m_item->getArrayValue(lIndex);
 
509
  ITEM_CATCH
 
510
  return Item();
 
511
}
 
512
 
 
513
 
 
514
Iterator_t
 
515
Item::getObjectKeys() const
 
516
{
 
517
  ITEM_TRY
 
518
    SYNC_CODE(AutoLock lock(GENV_STORE.getGlobalLock(), Lock::READ);)
 
519
 
 
520
    return new StoreIteratorImpl(m_item->getObjectKeys(), nullptr);
 
521
 
 
522
  ITEM_CATCH
 
523
  return NULL;
 
524
}
 
525
 
 
526
 
 
527
Item
 
528
Item::getObjectValue(String aName) const
 
529
{
 
530
  ITEM_TRY
 
531
    SYNC_CODE(AutoLock lock(GENV_STORE.getGlobalLock(), Lock::READ);)
 
532
    zstring& lName = Unmarshaller::getInternalString(aName);
 
533
    
 
534
    store::Item_t lStringItem;
 
535
    GENV_ITEMFACTORY->createString(lStringItem, lName);
 
536
  
 
537
    return m_item->getObjectValue(lStringItem).getp();
 
538
 
 
539
  ITEM_CATCH
 
540
  return Item();
 
541
}
 
542
 
 
543
#endif /* ZORBA_WITH_JSON */
 
544
 
463
545
bool
464
546
Item::isStreamable() const
465
547
{
471
553
  return false;
472
554
}
473
555
 
 
556
bool
 
557
Item::isSeekable() const
 
558
{
 
559
  ITEM_TRY
 
560
    SYNC_CODE(AutoLock lock(GENV_STORE.getGlobalLock(), Lock::READ);)
 
561
 
 
562
    return m_item->isSeekable();
 
563
  ITEM_CATCH
 
564
  return false;
 
565
}
 
566
 
474
567
std::istream&
475
568
Item::getStream()
476
569
{