当前位置: 首页>>代码示例>>C++>>正文


C++ SetTo函数代码示例

本文整理汇总了C++中SetTo函数的典型用法代码示例。如果您正苦于以下问题:C++ SetTo函数的具体用法?C++ SetTo怎么用?C++ SetTo使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了SetTo函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: SetTo

/*! \brief Re-initializes the BDirectory to the directory referred to by the
	supplied BEntry.
	\param entry the BEntry referring to the directory
	\return
	- \c B_OK: Everything went fine.
	- \c B_BAD_VALUE: \c NULL \a entry.
	- \c B_ENTRY_NOT_FOUND: Directory not found.
	- \c B_PERMISSION_DENIED: Directory permissions didn't allow operation.
	- \c B_NO_MEMORY: Insufficient memory for operation.
	- \c B_LINK_LIMIT: Indicates a cyclic loop within the file system.
	- \c B_BUSY: A node was busy.
	- \c B_FILE_ERROR: A general file error.
	- \c B_NO_MORE_FDS: The application has run out of file descriptors.
	\todo Implemented using SetTo(entry_ref*). Check, if necessary to
		  reimplement!
*/
status_t
BDirectory::SetTo(const BEntry *entry)
{
	if (!entry) {
		Unset();
		return (fCStatus = B_BAD_VALUE);
	}
	// open node
	entry_ref ref;
	status_t error = (entry ? B_OK : B_BAD_VALUE);
	if (error == B_OK && entry->InitCheck() != B_OK)
		error = B_BAD_VALUE;
	if (error == B_OK)
		error = entry->GetRef(&ref);
	if (error == B_OK)
		error = SetTo(&ref);
	set_status(error);
	return error;
}
开发者ID:Ithamar,项目名称:cosmoe,代码行数:35,代码来源:Directory.cpp

示例2: locker

void
MessageView::_UpdateMessage()
{
	BAutolock locker(fEditor);

	size_t viewSize = fEditor.ViewSize();
	// that may need some more memory...
	if ((off_t)viewSize < fEditor.FileSize())
		fEditor.SetViewSize(fEditor.FileSize());

	const char *buffer;
	if (fEditor.GetViewBuffer((const uint8 **)&buffer) == B_OK) {
		BMessage message;
		message.Unflatten(buffer);
		SetTo(message);
	}

	// restore old view size
	fEditor.SetViewSize(viewSize);
}
开发者ID:DonCN,项目名称:haiku,代码行数:20,代码来源:TypeEditors.cpp

示例3: Intersect

void nsRegionPh :: Intersect( PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight ) 
{
	if( aWidth > 0 && aHeight > 0 ) {
		/* Create a temporary tile to  assign to mRegion */
		PhTile_t tile;
		tile.rect.ul.x = aX;
		tile.rect.ul.y = aY;
		tile.rect.lr.x = (aX+aWidth-1);
		tile.rect.lr.y = (aY+aHeight-1);
		tile.next = NULL;
    
		PhTile_t *original = mRegion;
		mRegion = PhIntersectTilings( mRegion, &tile, NULL );
		PhFreeTiles( original );
		if ( mRegion == NULL )
			SetTo(0, 0, 1, 1);
	}
	else 
		SetRegionEmpty();
}
开发者ID:EdgarChen,项目名称:mozilla-cvs-history,代码行数:20,代码来源:nsRegionPh.cpp

示例4: BMailProtocolConfigView

IMAPConfig::IMAPConfig(BMessage *archive)
	: BMailProtocolConfigView(B_MAIL_PROTOCOL_HAS_USERNAME
		| B_MAIL_PROTOCOL_HAS_PASSWORD | B_MAIL_PROTOCOL_HAS_HOSTNAME
		| B_MAIL_PROTOCOL_CAN_LEAVE_MAIL_ON_SERVER
#ifdef USE_SSL
	 	| B_MAIL_PROTOCOL_HAS_FLAVORS
#endif
	 )
{
#ifdef USE_SSL
		AddFlavor("No encryption");
		AddFlavor("SSL");
#endif

	SetTo(archive);

	((BControl *)(FindView("leave_mail_remote")))->SetValue(B_CONTROL_ON);
	((BControl *)(FindView("leave_mail_remote")))->Hide();

	BRect frame = FindView("delete_remote_when_local")->Frame();

	((BControl *)(FindView("delete_remote_when_local")))->SetEnabled(true);
	((BControl *)(FindView("delete_remote_when_local")))->MoveBy(0,-25);


	frame.right -= 10;// FindView("pass")->Frame().right;
	/*frame.top += 10;
	frame.bottom += 10;*/

	BTextControl *folder = new BTextControl(frame,"root","Top mailbox folder: ","",NULL);
	folder->SetDivider(be_plain_font->StringWidth("Top mailbox folder: "));

	if (archive->HasString("root"))
		folder->SetText(archive->FindString("root"));

	AddChild(folder);

	ResizeToPreferred();
}
开发者ID:mmanley,项目名称:Antares,代码行数:39,代码来源:imap_config.cpp

示例5: String

void DString::ReplaceString(const char *oldstring, const char *newstring)
{	
	char *str = String();
	char *hit = strstr(str, oldstring);
	if (!hit) return;	// avoid strlens in common case of no hits

	int oldlen = strlen(oldstring);
	int newlen = strlen(newstring);
	
	for(;;)
	{
		DString temp(str, (hit - str));
		temp.AppendString(newstring);
		temp.AppendString(hit + oldlen);
		
		SetTo(temp.String());
		
		int index = (hit - str) + newlen;
		str = String() + index;

		hit = strstr(str, oldstring);
		if (!hit) break;
	}
}
开发者ID:histat,项目名称:dc-nx,代码行数:24,代码来源:DString.cpp

示例6: file

//!	Load a map from a file
status_t
Keymap::Load(const entry_ref& ref)
{
	BEntry entry;
	status_t status = entry.SetTo(&ref, true);
	if (status != B_OK)
		return status;

	BFile file(&entry, B_READ_ONLY);
	status = SetTo(file);
	if (status != B_OK)
		return status;

	// fetch name from attribute and fall back to filename

	ssize_t bytesRead = file.ReadAttr("keymap:name", B_STRING_TYPE, 0, fName,
		sizeof(fName));
	if (bytesRead > 0)
		fName[bytesRead] = '\0';
	else
		strlcpy(fName, ref.name, sizeof(fName));

	return B_OK;
}
开发者ID:mmadia,项目名称:Haiku-services-branch,代码行数:25,代码来源:Keymap.cpp

示例7: SetTo

BNetworkAddress::BNetworkAddress(const in6_addr& address, uint16 port)
{
	SetTo(address, port);
}
开发者ID:looncraz,项目名称:haiku,代码行数:4,代码来源:NetworkAddress.cpp

示例8: while

void
nsAttrValue::ParseAtomArray(const nsAString& aValue)
{
  nsAString::const_iterator iter, end;
  aValue.BeginReading(iter);
  aValue.EndReading(end);
  PRBool hasSpace = PR_FALSE;
  
  // skip initial whitespace
  while (iter != end && nsContentUtils::IsHTMLWhitespace(*iter)) {
    hasSpace = PR_TRUE;
    ++iter;
  }

  if (iter == end) {
    SetTo(aValue);
    return;
  }

  nsAString::const_iterator start(iter);

  // get first - and often only - atom
  do {
    ++iter;
  } while (iter != end && !nsContentUtils::IsHTMLWhitespace(*iter));

  nsCOMPtr<nsIAtom> classAtom = do_GetAtom(Substring(start, iter));
  if (!classAtom) {
    Reset();
    return;
  }

  // skip whitespace
  while (iter != end && nsContentUtils::IsHTMLWhitespace(*iter)) {
    hasSpace = PR_TRUE;
    ++iter;
  }

  if (iter == end && !hasSpace) {
    // we only found one classname and there was no whitespace so
    // don't bother storing a list
    ResetIfSet();
    nsIAtom* atom = nsnull;
    classAtom.swap(atom);
    SetPtrValueAndType(atom, eAtomBase);
    return;
  }

  if (!EnsureEmptyAtomArray()) {
    return;
  }

  AtomArray* array = GetAtomArrayValue();
  
  if (!array->AppendElement(classAtom)) {
    Reset();
    return;
  }

  // parse the rest of the classnames
  while (iter != end) {
    start = iter;

    do {
      ++iter;
    } while (iter != end && !nsContentUtils::IsHTMLWhitespace(*iter));

    classAtom = do_GetAtom(Substring(start, iter));

    if (!array->AppendElement(classAtom)) {
      Reset();
      return;
    }

    // skip whitespace
    while (iter != end && nsContentUtils::IsHTMLWhitespace(*iter)) {
      ++iter;
    }
  }

  SetMiscAtomOrString(&aValue);
  return;
}
开发者ID:Egyptghost1,项目名称:DOMinator,代码行数:83,代码来源:nsAttrValue.cpp

示例9: SetTo

EasyPath::EasyPath(const entry_ref &ref)
{
	SetTo(ref);
}
开发者ID:HaikuArchives,项目名称:LibWalter,代码行数:4,代码来源:EasyPath.cpp

示例10: mBits

nsAttrValue::nsAttrValue(const nsIntMargin& aValue)
    : mBits(0)
{
  SetTo(aValue);
}
开发者ID:ehsan,项目名称:mozilla-history,代码行数:5,代码来源:nsAttrValue.cpp

示例11: SetTo

Region& Region::operator=(const Region &copyRegion)
{
	return SetTo(copyRegion);
}
开发者ID:danilaslau,项目名称:frotznet,代码行数:4,代码来源:Region.cpp

示例12: SetTo

void
nsTextFragment::Append(const PRUnichar* aBuffer, PRUint32 aLength, PRBool aUpdateBidi)
{
    // This is a common case because some callsites create a textnode
    // with a value by creating the node and then calling AppendData.
    if (mState.mLength == 0) {
        SetTo(aBuffer, aLength, aUpdateBidi);

        return;
    }

    // Should we optimize for aData.Length() == 0?

    if (mState.mIs2b) {
        // Already a 2-byte string so the result will be too
        PRUnichar* buff = (PRUnichar*)nsMemory::Realloc(m2b, (mState.mLength + aLength) * sizeof(PRUnichar));
        if (!buff) {
            return;
        }

        memcpy(buff + mState.mLength, aBuffer, aLength * sizeof(PRUnichar));
        mState.mLength += aLength;
        m2b = buff;

        if (aUpdateBidi) {
            UpdateBidiFlag(aBuffer, aLength);
        }

        return;
    }

    // Current string is a 1-byte string, check if the new data fits in one byte too.
    PRInt32 first16bit = FirstNon8Bit(aBuffer, aBuffer + aLength);

    if (first16bit != -1) { // aBuffer contains no non-8bit character
        // The old data was 1-byte, but the new is not so we have to expand it
        // all to 2-byte
        PRUnichar* buff = (PRUnichar*)nsMemory::Alloc((mState.mLength + aLength) *
                          sizeof(PRUnichar));
        if (!buff) {
            return;
        }

        // Copy data into buff
        LossyConvertEncoding8to16 converter(buff);
        copy_string(m1b, m1b+mState.mLength, converter);

        memcpy(buff + mState.mLength, aBuffer, aLength * sizeof(PRUnichar));
        mState.mLength += aLength;
        mState.mIs2b = PR_TRUE;

        if (mState.mInHeap) {
            nsMemory::Free(m2b);
        }
        m2b = buff;

        mState.mInHeap = PR_TRUE;

        if (aUpdateBidi) {
            UpdateBidiFlag(aBuffer + first16bit, aLength - first16bit);
        }

        return;
    }

    // The new and the old data is all 1-byte
    char* buff;
    if (mState.mInHeap) {
        buff = (char*)nsMemory::Realloc(const_cast<char*>(m1b),
                                        (mState.mLength + aLength) * sizeof(char));
        if (!buff) {
            return;
        }
    }
    else {
        buff = (char*)nsMemory::Alloc((mState.mLength + aLength) * sizeof(char));
        if (!buff) {
            return;
        }

        memcpy(buff, m1b, mState.mLength);
        mState.mInHeap = PR_TRUE;
    }

    // Copy aBuffer into buff.
    LossyConvertEncoding16to8 converter(buff + mState.mLength);
    copy_string(aBuffer, aBuffer + aLength, converter);

    m1b = buff;
    mState.mLength += aLength;

}
开发者ID:harthur,项目名称:mozilla-central,代码行数:92,代码来源:nsTextFragment.cpp

示例13: SetTo

void
DisplayItemClip::SetTo(const nsRect& aRect)
{
  SetTo(aRect, nullptr);
}
开发者ID:AtulKumar2,项目名称:gecko-dev,代码行数:5,代码来源:DisplayItemClip.cpp

示例14: SetTo

	inline file_descriptor* SetTo(int fd, bool kernel,
		bool contextLocked = false)
	{
		return SetTo(get_current_io_context(kernel), fd, contextLocked);
	}
开发者ID:simonsouth,项目名称:haiku,代码行数:5,代码来源:fd.cpp


注:本文中的SetTo函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。