Пример #1
0
void CContainerTypeInfo::Assign(TObjectPtr dst, TConstObjectPtr src,
                                ESerialRecursionMode how) const
{
    if (how == eShallowChildless) {
        SetDefault(dst); // clear destination container
        return;
    }
    CIterator idst;
    CConstIterator isrc;
    bool old_element = InitIterator(idst,dst);
    if ( InitIterator(isrc, src) ) {
        TTypeInfo elementType = GetElementType();
        do {
            TConstObjectPtr elementPtr = GetElementPtr(isrc);
            if (old_element) {
                elementType->Assign(GetElementPtr(idst), elementPtr, how);
                old_element = NextElement(idst);
            } else {
                AddElement(dst, elementPtr, how);
            }
        } while ( NextElement(isrc) );
    }
    if (old_element) {
        EraseAllElements(idst);
    }
}
Пример #2
0
bool CContainerTypeInfo::Equals(TConstObjectPtr object1, TConstObjectPtr object2,
                                ESerialRecursionMode how) const
{
    if (how == eShallowChildless) {
        return true;
    }
    TTypeInfo elementType = GetElementType();
    CConstIterator i1, i2;
    if ( InitIterator(i1, object1) ) {
        if ( !InitIterator(i2, object2) )
            return false;
        if ( !elementType->Equals(GetElementPtr(i1),
                                  GetElementPtr(i2), how) )
            return false;
        while ( NextElement(i1) ) {
            if ( !NextElement(i2) )
                return false;
            if ( !elementType->Equals(GetElementPtr(i1),
                                      GetElementPtr(i2), how) )
                return false;
        }
        return !NextElement(i2);
    }
    else {
        return !InitIterator(i2, object2);
    }
}
Пример #3
0
// *************************************************************************
// Returns the address of the first data pixel in this ROI.
// Initializes variables needed by NextPixel() to step through all the
// pixels in the ROI.
// *************************************************************************
float *
Line::FirstPixel()
{
    Imginfo *img = owner_frame->imginfo;
    data = InitIterator(img->GetFast(),
			first_point_on_data.x,
			first_point_on_data.y,
			second_point_on_data.x,
			second_point_on_data.y,
			(float *)img->GetData(),
			&pix_step,
			&npix,
			&ipix,
			&req_data_step,
			&opt_data_step,
			&test);
    return data;
}
Пример #4
0
nsresult
nsFind::NextNode(nsIDOMRange* aSearchRange,
                 nsIDOMRange* aStartPoint, nsIDOMRange* aEndPoint,
                 bool aContinueOk)
{
  nsresult rv;

  nsCOMPtr<nsIContent> content;

  if (!mIterator || aContinueOk)
  {
    // If we are continuing, that means we have a match in progress.
    // In that case, we want to continue from the end point
    // (where we are now) to the beginning/end of the search range.
    nsCOMPtr<nsIDOMNode> startNode;
    nsCOMPtr<nsIDOMNode> endNode;
    PRInt32 startOffset, endOffset;
    if (aContinueOk)
    {
#ifdef DEBUG_FIND
      printf("Match in progress: continuing past endpoint\n");
#endif
      if (mFindBackward) {
        aSearchRange->GetStartContainer(getter_AddRefs(startNode));
        aSearchRange->GetStartOffset(&startOffset);
        aEndPoint->GetStartContainer(getter_AddRefs(endNode));
        aEndPoint->GetStartOffset(&endOffset);
      } else {     // forward
        aEndPoint->GetEndContainer(getter_AddRefs(startNode));
        aEndPoint->GetEndOffset(&startOffset);
        aSearchRange->GetEndContainer(getter_AddRefs(endNode));
        aSearchRange->GetEndOffset(&endOffset);
      }
    }
    else  // Normal, not continuing
    {
      if (mFindBackward) {
        aSearchRange->GetStartContainer(getter_AddRefs(startNode));
        aSearchRange->GetStartOffset(&startOffset);
        aStartPoint->GetEndContainer(getter_AddRefs(endNode));
        aStartPoint->GetEndOffset(&endOffset);
        // XXX Needs work:
        // Problem with this approach: if there is a match which starts
        // just before the current selection and continues into the selection,
        // we will miss it, because our search algorithm only starts
        // searching from the end of the word, so we would have to
        // search the current selection but discount any matches
        // that fall entirely inside it.
      } else {     // forward
        aStartPoint->GetStartContainer(getter_AddRefs(startNode));
        aStartPoint->GetStartOffset(&startOffset);
        aEndPoint->GetEndContainer(getter_AddRefs(endNode));
        aEndPoint->GetEndOffset(&endOffset);
      }
    }

    rv = InitIterator(startNode, startOffset, endNode, endOffset);
    NS_ENSURE_SUCCESS(rv, rv);
    if (!aStartPoint)
      aStartPoint = aSearchRange;

    content = do_QueryInterface(mIterator->GetCurrentNode());
#ifdef DEBUG_FIND
    nsCOMPtr<nsIDOMNode> dnode (do_QueryInterface(content));
    printf(":::::: Got the first node "); DumpNode(dnode);
#endif
    if (content && content->IsNodeOfType(nsINode::eTEXT) &&
        !SkipNode(content))
    {
      mIterNode = do_QueryInterface(content);
      // Also set mIterOffset if appropriate:
      nsCOMPtr<nsIDOMNode> node;
      if (mFindBackward) {
        aStartPoint->GetEndContainer(getter_AddRefs(node));
        if (mIterNode.get() == node.get())
          aStartPoint->GetEndOffset(&mIterOffset);
        else
          mIterOffset = -1;   // sign to start from end
      }
      else
      {
        aStartPoint->GetStartContainer(getter_AddRefs(node));
        if (mIterNode.get() == node.get())
          aStartPoint->GetStartOffset(&mIterOffset);
        else
          mIterOffset = 0;
      }
#ifdef DEBUG_FIND
      printf("Setting initial offset to %d\n", mIterOffset);
#endif
      return NS_OK;
    }
  }

  while (1)
  {
    if (mFindBackward)
      mIterator->Prev();
    else
      mIterator->Next();

    content = do_QueryInterface(mIterator->GetCurrentNode());
    if (!content)
      break;

#ifdef DEBUG_FIND
    nsCOMPtr<nsIDOMNode> dnode (do_QueryInterface(content));
    printf(":::::: Got another node "); DumpNode(dnode);
#endif

    // If we ever cross a block node, we might want to reset
    // the match anchor:
    // we don't match patterns extending across block boundaries.
    // But we can't depend on this test here now, because the iterator
    // doesn't give us the parent going in and going out, and we
    // need it both times to depend on this.
    //if (IsBlockNode(content))

    // Now see if we need to skip this node --
    // e.g. is it part of a script or other invisible node?
    // Note that we don't ask for CSS information;
    // a node can be invisible due to CSS, and we'd still find it.
    if (SkipNode(content))
      continue;

    if (content->IsNodeOfType(nsINode::eTEXT))
      break;
#ifdef DEBUG_FIND
    dnode = do_QueryInterface(content);
    printf("Not a text node: "); DumpNode(dnode);
#endif
  }

  if (content)
    mIterNode = do_QueryInterface(content);
  else
    mIterNode = nsnull;
  mIterOffset = -1;

#ifdef DEBUG_FIND
  printf("Iterator gave: "); DumpNode(mIterNode);
#endif
  return NS_OK;
}