예제 #1
0
Item ItemFactoryImpl::createQName(
    const String& aNamespace,
    const String& aPrefix,
    const String& aLocalname)
{
  zstring const &lNamespace = Unmarshaller::getInternalString( aNamespace );
  zstring const &lPrefix = Unmarshaller::getInternalString( aPrefix );
  zstring const &lLocalname = Unmarshaller::getInternalString( aLocalname );

  if (!GenericCast::instance()->castableToNCName(lLocalname.c_str()))
  {
    RAISE_ERROR_NO_LOC(err::FORG0001,
    ERROR_PARAMS(ZED(FORG0001_LocalNotNCName_2), lLocalname));
  }

  if (lPrefix.size() && !GenericCast::instance()->castableToNCName(lPrefix.c_str()))
  {
    RAISE_ERROR_NO_LOC(err::FORG0001,
    ERROR_PARAMS(ZED(FORG0001_PrefixNotNCName_2), lPrefix));
  }

  store::Item_t lItem;
  theItemFactory->createQName(lItem, lNamespace, lPrefix, lLocalname);
  return &*lItem;
}
예제 #2
0
store::IndexCondition_t IndexImpl::createCondition(store::IndexCondition::Kind k)
{
  if (!isSorted() &&
      (k == store::IndexCondition::BOX_VALUE || 
       k == store::IndexCondition::BOX_GENERAL))
  {
    RAISE_ERROR_NO_LOC(zerr::ZSTR0007_INDEX_UNSUPPORTED_PROBE_CONDITION,
    ERROR_PARAMS(IndexConditionImpl::getKindString(k), getName()->getStringValue()));
  }

  if (isGeneral())
  {
    return new GeneralIndexCondition(this, k);
  }
  else if (k == store::IndexCondition::POINT_VALUE)
  {
    return new IndexPointCondition(this, k);
  }
  else if (k == store::IndexCondition::BOX_VALUE)
  {
    return new IndexBoxValueCondition(this, k);
  }
  else
  {
    RAISE_ERROR_NO_LOC(zerr::ZSTR0007_INDEX_UNSUPPORTED_PROBE_CONDITION,
    ERROR_PARAMS(IndexConditionImpl::getKindString(k), getName()->getStringValue()));

    ZORBA_ASSERT(false);
  }
}
예제 #3
0
void SimpleLazyTempSeq::getItem(xs_integer position, store::Item_t& result)
{
  xs_long pos;
  try 
  {
    pos = to_xs_long(position);
  }
  catch (std::range_error const&)
  {
    RAISE_ERROR_NO_LOC(zerr::ZSTR0060_RANGE_EXCEPTION,
    ERROR_PARAMS(position,ZED(ZSTR0060_ForSequence)));
  }

  ZORBA_ASSERT(pos > thePurgedUpTo);

  std::vector<store::Item*>::size_type numItemsToBuffer = pos - thePurgedUpTo;

  while (!theMatFinished && theItems.size() <  numItemsToBuffer) 
  {
    matNextItem();
  }

  if (theItems.size() >= numItemsToBuffer)
  {
    std::vector<store::Item*>::size_type sPos = static_cast<std::vector<store::Item*>::size_type>(pos - thePurgedUpTo - 1);
    result = theItems[sPos];
  }
  else 
  {
    result = NULL;
  }
}
예제 #4
0
Item ItemFactoryImpl::createNCName(const String& aValue)
{
  zstring lString = Unmarshaller::getInternalString(aValue);

  if (!GenericCast::instance()->castableToNCName(lString.c_str()))
  {
    RAISE_ERROR_NO_LOC(err::FORG0001,
    ERROR_PARAMS(ZED(FORG0001_NameNotNCName_2), lString));
  }

  store::Item_t lItem;
  theItemFactory->createNCName(lItem, lString);
  return &*lItem;
}
예제 #5
0
Item
ItemFactoryImpl::createQName(const String& aQNameString)
{
  const zstring& lQNameString = Unmarshaller::getInternalString( aQNameString );
  store::Item_t lItem;

  size_t lOpen  = lQNameString.find("{");
  size_t lClose = lQNameString.find("}");

  if (lOpen == 0 && lClose != std::string::npos)
  {
    zstring const &lNamespace = lQNameString.substr(1, lClose - 1);
    zstring const &lLocalname = lQNameString.substr(lClose+1);
    theItemFactory->createQName(lItem, lNamespace, zstring(), lLocalname);

    if (!GenericCast::instance()->castableToNCName(lLocalname.c_str()))
    {
      RAISE_ERROR_NO_LOC(err::FORG0001,
      ERROR_PARAMS(ZED(FORG0001_LocalNotNCName_2), lLocalname));
    }
  }
  return &*lItem;
}
예제 #6
0
/*******************************************************************************
  This method checks if the i-th item in the result sequences of the input
  iterator is in the queue or not. In general, the item may be missing from
  the queue because:
  (a) it has either been purged, or
  (b) it has not been computed yet, or
  (c) the result sequence contains less than i items.
 
  Case (a) should never arise: it is the user of the lazy temp sequence that
  decided when and how many items to purge, so he shouldn't come back to ask
  for an item that has been purged.

  In case (c), the method will compute and buffer any input items that have not
  been computed already and then return false.

  In case (b), the method will compute and buffer all the items starting after
  the last computed item and up to the i-th item; then it will return true.

  If the i-th item is already in the queue, the method will simply return true. 
********************************************************************************/
inline bool SimpleLazyTempSeq::containsItem(xs_integer position) 
{
  xs_long pos;
  try 
  {
    pos = to_xs_long(position);
  }
  catch (std::range_error const&)
  {
    RAISE_ERROR_NO_LOC(zerr::ZSTR0060_RANGE_EXCEPTION,
    ERROR_PARAMS(position,ZED(ZSTR0060_ForSequence)));
  }

  ZORBA_ASSERT(pos > thePurgedUpTo);

  std::vector<store::Item*>::size_type numItemsToBuffer = pos - thePurgedUpTo;

  while (!theMatFinished && theItems.size() <  numItemsToBuffer) 
  {
    matNextItem();
  }

  return theItems.size() >= numItemsToBuffer;
}