本文整理汇总了C++中nsACString::SetIsVoid方法的典型用法代码示例。如果您正苦于以下问题:C++ nsACString::SetIsVoid方法的具体用法?C++ nsACString::SetIsVoid怎么用?C++ nsACString::SetIsVoid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nsACString
的用法示例。
在下文中一共展示了nsACString::SetIsVoid方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetItem
nsresult
nsDOMStorage::GetItem(const nsACString& aKey, nsACString &aData)
{
nsresult rv;
// IMPORTANT:
// CacheStoragePermissions() is called inside of
// GetItem(nsACString, nsIDOMStorageItem)
// To call it particularly in this method would just duplicate
// the call. If the code changes, make sure that call to
// CacheStoragePermissions() is put here!
nsCOMPtr<nsIDOMStorageItem> item;
rv = GetItem(aKey, getter_AddRefs(item));
if (NS_FAILED(rv))
return rv;
if (item) {
nsDOMStorageItem* itemConcrete = static_cast<nsDOMStorageItem*>(item.get());
rv = itemConcrete->GetValueNoConvert(aData);
NS_ENSURE_SUCCESS(rv, rv);
}
else
aData.SetIsVoid(true);
return NS_OK;
}
示例2: FindParameter
NS_IMETHODIMP
calIcalProperty::GetParameter(const nsACString ¶m, nsACString &value)
{
// More ridiculous parameter/X-PARAMETER handling.
icalparameter_kind paramkind =
icalparameter_string_to_kind(PromiseFlatCString(param).get());
if (paramkind == ICAL_NO_PARAMETER)
return NS_ERROR_INVALID_ARG;
const char *icalstr = nullptr;
if (paramkind == ICAL_X_PARAMETER) {
icalparameter *icalparam = FindParameter(mProperty, param, ICAL_X_PARAMETER);
if (icalparam)
icalstr = icalparameter_get_xvalue(icalparam);
} else if (paramkind == ICAL_IANA_PARAMETER) {
icalparameter *icalparam = FindParameter(mProperty, param, ICAL_IANA_PARAMETER);
if (icalparam)
icalstr = icalparameter_get_iana_value(icalparam);
} else {
icalstr = icalproperty_get_parameter_as_string(mProperty,
PromiseFlatCString(param).get());
}
if (!icalstr) {
value.Truncate();
value.SetIsVoid(true);
} else {
value.Assign(icalstr);
}
return NS_OK;
}
示例3: GetInternalStream
nsresult
BlobImplBase::GetSendInfo(nsIInputStream** aBody, uint64_t* aContentLength,
nsACString& aContentType, nsACString& aCharset)
{
MOZ_ASSERT(aContentLength);
ErrorResult rv;
nsCOMPtr<nsIInputStream> stream;
GetInternalStream(getter_AddRefs(stream), rv);
if (NS_WARN_IF(rv.Failed())) {
return rv.StealNSResult();
}
*aContentLength = GetSize(rv);
if (NS_WARN_IF(rv.Failed())) {
return rv.StealNSResult();
}
nsAutoString contentType;
GetType(contentType);
if (contentType.IsEmpty()) {
aContentType.SetIsVoid(true);
} else {
CopyUTF16toUTF8(contentType, aContentType);
}
aCharset.Truncate();
stream.forget(aBody);
return NS_OK;
}
示例4: InitDB
nsresult
DOMStorageImpl::GetDBValue(const nsACString& aKey, nsACString& aValue,
bool* aSecure)
{
aValue.Truncate();
if (!UseDB())
return NS_OK;
nsresult rv = InitDB();
NS_ENSURE_SUCCESS(rv, rv);
nsAutoCString value;
rv = gStorageDB->GetKeyValue(this, aKey, value, aSecure);
if (rv == NS_ERROR_DOM_NOT_FOUND_ERR) {
aValue.SetIsVoid(true);
}
if (NS_FAILED(rv))
return rv;
aValue.Assign(value);
return NS_OK;
}
示例5:
NS_IMETHODIMP
jxMySQL50Statement::GetUTF8String(PRUint32 aIndex, nsACString &_retval)
{
if (mConnection == nsnull)
{
SET_ERROR_RETURN (JX_MYSQL50_ERROR_NOT_CONNECTED);
}
if (mSTMT == nsnull)
{
SET_ERROR_RETURN (JX_MYSQL50_ERROR_STMT_NULL);
}
if (aIndex < 0 || aIndex >= mOut.mCount)
{
SET_ERROR_RETURN (JX_MYSQL50_ERROR_ILLEGAL_VALUE);
}
if (mOut.mBindArrayIsNull[aIndex]) {
// null columns get IsVoid set to distinguish them from empty strings
_retval.Truncate(0);
_retval.SetIsVoid(PR_TRUE);
} else {
PRUint32 slen = mOut.mBindArrayBufferTYPE_STRING_LEN_OUT[aIndex];
const char* cstr = mOut.mBindArrayBufferTYPE_STRING[aIndex];
_retval.Assign(cstr, slen);
}
return NS_OK;
}
示例6: memset
NS_IMETHODIMP
jxMySQL50Statement::GetUTF8Text(PRUint32 aIndex, nsACString &aData)
{
if (mConnection == nsnull)
{
SET_ERROR_RETURN (JX_MYSQL50_ERROR_NOT_CONNECTED);
}
if (mSTMT == nsnull)
{
SET_ERROR_RETURN (JX_MYSQL50_ERROR_STMT_NULL);
}
if (aIndex < 0 || aIndex >= mOut.mCount)
{
SET_ERROR_RETURN (JX_MYSQL50_ERROR_ILLEGAL_VALUE);
}
if (mOut.mBindArrayIsNull[aIndex]) {
// null columns get IsVoid set to distinguish them from empty strings
aData.Truncate(0);
aData.SetIsVoid(PR_TRUE);
}else
{
int nsize = mOut.mBindArrayBufferTYPE_STRING_LEN_OUT[aIndex];
char *data = static_cast<char*>(nsMemory::Alloc(nsize+1));
//extra for the null
if (data == NULL)
{
SET_ERROR_RETURN (JX_MYSQL50_ERROR_OUT_OF_MEMORY);
}
my_bool is_null;
my_bool error;
unsigned long length;
MYSQL_BIND bind;
memset(&bind, 0, sizeof(bind));
bind.buffer= (void*)data;
bind.buffer_length= nsize;
bind.buffer_type = MYSQL_TYPE_STRING;
bind.is_null= &is_null;
bind.length= &length;
bind.error= &error;
if (mysql_stmt_fetch_column(mSTMT, &bind, aIndex, 0))
{
SET_ERROR_RETURN (JX_MYSQL50_MYSQL_ERROR);
}
data[nsize] = 0;
aData = nsDependentCString(data, nsize);
}
return NS_OK;
}
示例7:
static void
ConvertString(const nsAString& aUTF16String, nsACString& aUTF8String)
{
if (aUTF16String.IsVoid()) {
aUTF8String.SetIsVoid(true);
} else {
CopyUTF16toUTF8(aUTF16String, aUTF8String);
}
}
示例8: GetStringProperty
nsresult calIcalComponent::GetStringProperty(icalproperty_kind kind, nsACString &str)
{
icalproperty *prop = icalcomponent_get_first_property(mComponent, kind);
if (!prop) {
str.Truncate();
str.SetIsVoid(true);
} else {
str.Assign(icalvalue_get_string(icalproperty_get_value(prop)));
}
return NS_OK;
}
示例9:
NS_IMETHODIMP
nsPKCS11Module::GetLibName(/*out*/ nsACString& libName)
{
nsNSSShutDownPreventionLock locker;
if (isAlreadyShutDown())
return NS_ERROR_NOT_AVAILABLE;
if (mModule->dllName) {
libName = mModule->dllName;
} else {
libName.SetIsVoid(true);
}
return NS_OK;
}
示例10:
NS_IMETHODIMP
ArgValueArray::GetUTF8String(uint32_t aIndex,
nsACString &_value)
{
ENSURE_INDEX_VALUE(aIndex, mArgc);
if (::sqlite3_value_type(mArgv[aIndex]) == SQLITE_NULL) {
// NULL columns should have IsVoid set to distinguish them from an empty
// string.
_value.Truncate(0);
_value.SetIsVoid(true);
}
else {
_value.Assign(reinterpret_cast<const char *>(::sqlite3_value_text(mArgv[aIndex])),
::sqlite3_value_bytes(mArgv[aIndex]));
}
return NS_OK;
}
示例11:
static nsresult
GetBufferDataAsStream(const uint8_t* aData, uint32_t aDataLength,
nsIInputStream** aResult, uint64_t* aContentLength,
nsACString& aContentType, nsACString& aCharset)
{
aContentType.SetIsVoid(true);
aCharset.Truncate();
*aContentLength = aDataLength;
const char* data = reinterpret_cast<const char*>(aData);
nsCOMPtr<nsIInputStream> stream;
nsresult rv = NS_NewByteInputStream(getter_AddRefs(stream), data, aDataLength,
NS_ASSIGNMENT_COPY);
NS_ENSURE_SUCCESS(rv, rv);
stream.forget(aResult);
return NS_OK;
}
示例12: if
NS_IMETHODIMP
calIcalProperty::GetValue(nsACString &str)
{
icalvalue *value = icalproperty_get_value(mProperty);
icalvalue_kind valuekind = icalvalue_isa(value);
const char *icalstr;
if (valuekind == ICAL_TEXT_VALUE) {
icalstr = icalvalue_get_text(value);
} else if (valuekind == ICAL_X_VALUE) {
icalstr = icalvalue_get_x(value);
} else if (valuekind == ICAL_ATTACH_VALUE) {
icalattach *attach = icalvalue_get_attach(value);
if (icalattach_get_is_url(attach)) {
icalstr = icalattach_get_url(attach);
} else {
icalstr = (const char *)icalattach_get_data(attach);
}
} else {
icalstr = icalproperty_get_value_as_string(mProperty);
}
if (!icalstr) {
if (icalerrno == ICAL_BADARG_ERROR) {
str.Truncate();
// Set string to null, because we don't have a value
// (which is something different then an empty value)
str.SetIsVoid(true);
return NS_OK;
}
#ifdef DEBUG
fprintf(stderr, "Error getting string value: %d (%s)\n",
icalerrno, icalerror_strerror(icalerrno));
#endif
return NS_ERROR_FAILURE;
}
str.Assign(icalstr);
return NS_OK;
}
示例13: GetTypeOfIndex
NS_IMETHODIMP
Statement::GetUTF8String(uint32_t aIndex,
nsACString &_value)
{
// Get type of Index will check aIndex for us, so we don't have to.
int32_t type;
nsresult rv = GetTypeOfIndex(aIndex, &type);
NS_ENSURE_SUCCESS(rv, rv);
if (type == mozIStorageStatement::VALUE_TYPE_NULL) {
// NULL columns should have IsVoid set to distinguish them from the empty
// string.
_value.Truncate(0);
_value.SetIsVoid(true);
}
else {
const char *value =
reinterpret_cast<const char *>(::sqlite3_column_text(mDBStatement,
aIndex));
_value.Assign(value, ::sqlite3_column_bytes(mDBStatement, aIndex));
}
return NS_OK;
}
示例14: refreshSlotInfo
NS_IMETHODIMP
nsPKCS11Slot::GetTokenName(/*out*/ nsACString& tokenName)
{
nsNSSShutDownPreventionLock locker;
if (isAlreadyShutDown())
return NS_ERROR_NOT_AVAILABLE;
if (!PK11_IsPresent(mSlot.get())) {
tokenName.SetIsVoid(true);
return NS_OK;
}
if (PK11_GetSlotSeries(mSlot.get()) != mSeries) {
nsresult rv = refreshSlotInfo(locker);
if (NS_FAILED(rv)) {
return rv;
}
}
tokenName = PK11_GetTokenName(mSlot.get());
return NS_OK;
}
示例15: fprintf
NS_IMETHODIMP
calIcalProperty::GetValueAsIcalString(nsACString &str)
{
const char *icalstr = icalproperty_get_value_as_string(mProperty);
if (!icalstr) {
if (icalerrno == ICAL_BADARG_ERROR) {
str.Truncate();
// Set string to null, because we don't have a value
// (which is something different then an empty value)
str.SetIsVoid(true);
return NS_OK;
}
#ifdef DEBUG
fprintf(stderr, "Error getting string value: %d (%s)\n",
icalerrno, icalerror_strerror(icalerrno));
#endif
return NS_ERROR_FAILURE;
}
str.Assign(icalstr);
return NS_OK;
}