Esempio n. 1
0
//
//  Unlike the external getOwnerDocument, this one returns the owner document
//     for document nodes as well as all of the other node types.
//
DOMDocument *DOMNodeImpl::getOwnerDocument() const
{
    if (!this->isLeafNode())
    {
        DOMElementImpl *ep = (DOMElementImpl *)castToNode(this);
        return ep->fParent.fOwnerDocument;
    }

    //  Leaf node types - those that cannot have children, like Text.
    if (isOwned()) {

        DOMDocument* ownerDoc = fOwnerNode->getOwnerDocument();

        if (!ownerDoc) {

            assert (fOwnerNode->getNodeType() == DOMNode::DOCUMENT_NODE);
            return  (DOMDocument *)fOwnerNode;
        }
        else {
            return ownerDoc;
        }
    } else {
        assert (fOwnerNode->getNodeType() == DOMNode::DOCUMENT_NODE);
        return  (DOMDocument *)fOwnerNode;
    }
}
Esempio n. 2
0
    /* note: addFields always adds _id even if not specified
       returns n added not counting _id unless requested.
    */
    int BSONObj::addFields(BSONObj& from, set<string>& fields) {
        assert( isEmpty() && !isOwned() ); /* partial implementation for now... */

        BSONObjBuilder b;

        int N = fields.size();
        int n = 0;
        BSONObjIterator i(from);
        bool gotId = false;
        while ( i.moreWithEOO() ) {
            BSONElement e = i.next();
            const char *fname = e.fieldName();
            if ( fields.count(fname) ) {
                b.append(e);
                ++n;
                gotId = gotId || strcmp(fname, "_id")==0;
                if ( n == N && gotId )
                    break;
            } else if ( strcmp(fname, "_id")==0 ) {
                b.append(e);
                gotId = true;
                if ( n == N && gotId )
                    break;
            }
        }

        if ( n ) {
            int len;
            init( b.decouple(len), true );
        }

        return n;
    }
void ClusterClientCursorImpl::queueResult(const ClusterQueryResult& result) {
    auto resultObj = result.getResult();
    if (resultObj) {
        invariant(resultObj->isOwned());
    }
    _stash.push(result);
}
Esempio n. 4
0
void gcore::Pipe::close() {
  if (isNamed() && isOwned()) {
#ifndef _WIN32
    gcore::String path = "/tmp/" + mName;
    closeRead();
    closeWrite();
    unlink(path.c_str());
#else
    if (mConnected) {
      FlushFileBuffers(mDesc[1]);
      DisconnectNamedPipe(mDesc[0]);
    }
    closeRead();
    closeWrite();
#endif
  } else {
    closeRead();
    closeWrite();
  }
  mName = "";
  mOwn = false;
#ifdef _WIN32
  mConnected = false;
#endif
}
void NodeImpl::setOwnerDocument(DocumentImpl *doc) {
    // if we have an owner we rely on it to have it right
    // otherwise ownerNode is our ownerDocument
    if (!isOwned()) {
        ownerNode = doc;
    }
}
FriendAPI::~FriendAPI() {
	FBLOG_DEBUG("FriendAPI::~FriendAPI", "this=" << this);
	if (isOwned()) {
		if(mFriend != NULL) {
			linphone_friend_destroy(mFriend);
		}
	}
}
Esempio n. 7
0
Element *
Attr::getOwnerElement() const
{
  if (isOwned())
    return dynamic_cast<Element*>(ownerNode);
  else
    return null;
}
AuthInfoAPI::~AuthInfoAPI() {
	FBLOG_DEBUG("AuthInfoAPI::~AuthInfoAPI", "this=" << this);
	if(isOwned()) {
		if(mAuthInfo != NULL) {
			linphone_auth_info_destroy(mAuthInfo);
		}
	}
}
Esempio n. 9
0
 void StringRef::takeOwnership() {
     if( !isOwned() ) {
         m_data = new char[m_size+1];
         memcpy( m_data, m_start, m_size );
         m_data[m_size] = '\0';
         m_start = m_data;
     }
 }
AddressAPI::~AddressAPI() {
	FBLOG_DEBUG("AddressAPI::~AddressAPI", "this=" << this);
	if(isOwned()) {
		if(mAddress != NULL) {
			linphone_address_destroy(mAddress);
		}
	}
}
Esempio n. 11
0
void DOMNodeImpl::setOwnerDocument(DOMDocument *doc) {
    // if we have an owner we rely on it to have it right
    // otherwise fOwnerNode is our ownerDocument
    if (!isOwned()) {
        // revisit.  Problem with storage for doctype nodes that were created
        //                on the system heap in advance of having a document.
        fOwnerNode = doc;
    }
}
Esempio n. 12
0
// unlike getOwnerDocument this is not overriden by DocumentImpl to return null
DocumentImpl *NodeImpl::getDocument()
{
    // if we have an owner simply forward the request
    // otherwise ownerNode is our ownerDocument
    if (isOwned()) {
        return ownerNode->getDocument();
    } else {
        return (DocumentImpl *) ownerNode;
    }
};
Esempio n. 13
0
void
Attr::setOwnerElement(Element * e)
{
  if (e == null) {
    if (ownerNode != null) {
      ownerNode = getOwnerDocument();
      isOwned(false);
      isSpecified(true);
      isId(false);
    }
  }
  else {
    if (isOwned())
      throw DOMException(DOMException::INUSE_ATTRIBUTE_ERR);
    ownerNode = e;
    isOwned(true);
    setId();
  }
}
Esempio n. 14
0
int gcore::Pipe::read(String &str, bool retryOnInterrupt) const {
  char rdbuf[256];

  if (canRead()) {
#ifndef _WIN32
    int bytesRead = ::read(mDesc[0], rdbuf, 255);
    while (bytesRead == -1 && (errno == EAGAIN || (errno == EINTR && retryOnInterrupt))) {
      bytesRead = ::read(mDesc[0], rdbuf, 255);
    }
    if (bytesRead >= 0) {
      rdbuf[bytesRead] = '\0';
      str = rdbuf;
    }
    return bytesRead;
#else
    bool namedPipeServer = (isNamed() && isOwned());
    if (namedPipeServer && !mConnected) {
      if (ConnectNamedPipe(mDesc[0], NULL)) {
        mConnected = true;
      } else {
        return -1;
      }
    }
    DWORD bytesRead = 0;
    BOOL rv = ReadFile(mDesc[0], rdbuf, 255, &bytesRead, NULL);
    while (rv == FALSE) {
      DWORD lastErr = GetLastError();
      if (lastErr == ERROR_IO_PENDING) {
        rv = ReadFile(mDesc[0], rdbuf, 255, &bytesRead, NULL);
      } else {
        if (namedPipeServer) {
          DisconnectNamedPipe(mDesc[0]);
          mConnected = false;
        }
        if (lastErr == ERROR_HANDLE_EOF || lastErr == ERROR_BROKEN_PIPE) {
          rv = TRUE;
          bytesRead = 0;
        }
        break;
      }
    }
    if (rv) {
      rdbuf[bytesRead] = '\0';
      str = rdbuf;
      return bytesRead;
    }
#endif
  }

  str = "";
  return -1;
}
Esempio n. 15
0
bool FileHandle::close() {
  if (!isOpened()) {
    setState(BadBit);
    return false;
  }

  if (isOwned()) {
    if (::close(m_Handler) == -1) {
      setState(FailBit);
      return false;
    }
  }

  m_Path.native().clear();
  m_Size = 0;
  m_OpenMode = OpenMode(NotOpen);
  cleanState();
  return true;
}
Esempio n. 16
0
void PmrWorkspace::deleteFileNodes(PmrWorkspaceFileNode *pFileNode,
                                   PmrWorkspaceFileNodes &pFileNodes)
{
    // Recursively delete the given file nodes, unless there is none left

    if (pFileNodes.isEmpty()) {
        return;
    }

    if (pFileNode->hasChildren()) {
        for (auto child : pFileNode->children()) {
            deleteFileNodes(child, pFileNodes);
        }

        // Remove the file node or let people know that we have been uncloned,
        // if the file node doesn't have any children anymore

        if (!pFileNode->hasChildren()) {
            if (pFileNode->parent() != nullptr) {
                pFileNode->parent()->removeChild(pFileNode);
            } else {
                // The folder where we were cloned has been deleted, so close
                // ourselves and ask the workspace manager to stop tracking us,
                // if we are not owned

                close();

                if (!isOwned()) {
                    PmrWorkspaceManager::instance()->removeWorkspace(this);
                }

                emit workspaceUncloned(this);
            }

            pFileNodes.removeOne(pFileNode);
        }
    } else if (pFileNodes.contains(pFileNode)) {
        pFileNode->parent()->removeChild(pFileNode);

        pFileNodes.removeOne(pFileNode);
    }
}
Esempio n. 17
0
void CtrlrGroup::itemDropped (const SourceDetails &dragSourceDetails)
{
	if (dragSourceDetails.description == "__ctrlr_component_selection")
	{
		if (owner.getOwnerPanel().getEditor() && owner.getOwnerPanel().getEditor()->getSelection())
		{
			AffineTransform trans = owner.getOwnerPanel().getEditor()->moveSelectionToPosition(dragSourceDetails.localPosition.getX(), dragSourceDetails.localPosition.getY());

			for (int i=0; i<owner.getOwnerPanel().getEditor()->getSelection()->getNumSelected(); i++)
			{
				CtrlrComponent *c = owner.getOwnerPanel().getEditor()->getSelection()->getSelectedItem(i);

				if (c == this || isOwned(c) || (bool)c->getProperty(Ids::componentIsLocked) == true)
					continue;

				setOwned (c, 0, true);

				c->setBounds (c->getBounds().transformedBy(trans));
			}
		}
	}
}
Esempio n. 18
0
int gcore::Pipe::write(const char *buffer, int size) const {
  if (canWrite()) {
#ifndef _WIN32
    int bytesToWrite = size;
    int rv = ::write(mDesc[1], buffer, bytesToWrite);
    while (rv == -1 && errno == EAGAIN) {
      rv = ::write(mDesc[1], buffer, bytesToWrite);
    }
    return rv;
#else
    bool namedPipeServer = (isNamed() && isOwned());
    if (namedPipeServer && !mConnected) {
      if (ConnectNamedPipe(mDesc[1], NULL)) {
        mConnected = true;
      } else {
        return -1;
      }
    }
    DWORD bytesToWrite = (DWORD)size;
    DWORD bytesWritten = 0;
    BOOL rv = WriteFile(mDesc[1], buffer, bytesToWrite, &bytesWritten, NULL);
    while (rv == FALSE) {
      DWORD lastErr = GetLastError();
      if (lastErr == ERROR_IO_PENDING) {
        rv = WriteFile(mDesc[1], buffer, bytesToWrite, &bytesWritten, NULL);
      } else {
        if (namedPipeServer) {
          DisconnectNamedPipe(mDesc[1]);
          mConnected = false;
        }
        break;
      }
    }
    return (rv == TRUE ? bytesWritten : -1);
#endif
  }
return -1;
}
Esempio n. 19
0
NodeImpl * ChildNode::getParentNode()
{
    // if we have an owner, ownerNode is our parent, otherwise it's
    // our ownerDocument and we don't have a parent
    return isOwned() ? ownerNode : null;
}
Esempio n. 20
0
BSONObj BSONObj::getOwned() const {
    if ( isOwned() )
        return *this;
    return copy();
}
Esempio n. 21
0
Handle<Value> DispObject::findElement(uint32_t index)
{
	if (!isOwned()) Undefined();
	return DispObject::NodeCreate(owner_disp, name.GetString(), owner_id, index);
}
Esempio n. 22
0
//internal use by parser only
void AttrImpl::setOwnerElement(ElementImpl *ownerElem)
{
    ownerNode = ownerElem;
    isOwned(false);
}
Esempio n. 23
0
ElementImpl *AttrImpl::getOwnerElement()
{
    // if we have an owner, ownerNode is our ownerElement, otherwise it's
    // our ownerDocument and we don't have an ownerElement
    return (ElementImpl *) (isOwned() ? ownerNode : null);
}