本文整理汇总了C++中TempBuffer::Append方法的典型用法代码示例。如果您正苦于以下问题:C++ TempBuffer::Append方法的具体用法?C++ TempBuffer::Append怎么用?C++ TempBuffer::Append使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TempBuffer
的用法示例。
在下文中一共展示了TempBuffer::Append方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
/* static */ OP_STATUS
DOM_LSInput::GetSystemId(const uni_char *&systemId, ES_Object *input, DOM_EnvironmentImpl *environment)
{
OP_BOOLEAN result;
ES_Value value;
systemId = NULL;
const uni_char *stringData;
RETURN_IF_ERROR(GetStringData(stringData, input, environment));
if (stringData)
return OpStatus::OK;
RETURN_IF_ERROR(result = environment->GetDOMRuntime()->GetName(input, UNI_L("systemId"), &value));
if (result == OpBoolean::IS_TRUE && value.type == VALUE_STRING && *value.value.string)
{
TempBuffer *buffer = environment->GetWindow()->GetEmptyTempBuf();
RETURN_IF_ERROR(buffer->Append(value.value.string));
systemId = buffer->GetStorage();
}
return OpStatus::OK;
}
示例2:
/* static */ BOOL
ES_DebugBuiltins::getObjectDemographics(ES_Execution_Context *context, unsigned argc, ES_Value_Internal *argv, ES_Value_Internal *return_value)
{
return_value->SetNull();
if (argc == 1)
{
if (!argv[0].ToNumber(context) || !argv[0].IsUInt32())
return FALSE;
if (ES_Heap *heap = g_ecmaManager->GetHeapById(argv[0].GetNumAsUInt32()))
{
TempBuffer *buffer = g_ecmaManager->GetHeapDebuggerBuffer();
buffer->Clear();
buffer->Append("{ ");
unsigned *live_objects = heap->live_objects;
for (unsigned index = 0; index < GCTAG_UNINITIALIZED; ++index)
{
if (index != 0)
buffer->Append(", ");
buffer->Append("\"");
buffer->Append(g_ecmaClassName[index]);
buffer->Append("\": ");
buffer->AppendUnsignedLong(live_objects[index]);
}
buffer->Append(" }");
return_value->SetString(JString::Make(context, buffer->GetStorage(), buffer->Length()));
}
}
return TRUE;
}
示例3: InternalGetName
/* virtual */
ES_GetState DOM_JILRadioInfo::InternalGetName(OpAtom property_atom, ES_Value* value, DOM_Runtime* origining_runtime, ES_Value* restart_value)
{
switch (property_atom)
{
case OP_ATOM_isRadioEnabled:
{
if (value)
{
OP_BOOLEAN is_radio_enabled = g_op_telephony_network_info->IsRadioEnabled();
if (!OpStatus::IsError(is_radio_enabled))
DOMSetBoolean(value, is_radio_enabled == OpBoolean::IS_TRUE);
else if (is_radio_enabled == OpStatus::ERR_NOT_SUPPORTED)
DOMSetUndefined(value);
else
return ConvertCallToGetName(HandleJILError(is_radio_enabled, value, origining_runtime), value);
}
return GET_SUCCESS;
}
case OP_ATOM_isRoaming:
{
if (value)
{
OP_BOOLEAN is_roaming = g_op_telephony_network_info->IsRoaming();
if (!OpStatus::IsError(is_roaming))
DOMSetBoolean(value, is_roaming == OpBoolean::IS_TRUE);
else if (is_roaming == OpStatus::ERR_NOT_SUPPORTED)
DOMSetUndefined(value);
else
return ConvertCallToGetName(HandleJILError(is_roaming, value, origining_runtime), value);
}
return GET_SUCCESS;
}
case OP_ATOM_radioSignalSource:
{
if (value)
{
OpTelephonyNetworkInfo::RadioSignalSource radio_source;
OP_STATUS ret_val = g_op_telephony_network_info->GetRadioSignalSource(&radio_source);
if (!OpStatus::IsError(ret_val))
{
TempBuffer* buffer = GetEmptyTempBuf();
ret_val = buffer->Append(RadioSignalSourceValueToString(radio_source));
if (OpStatus::IsSuccess(ret_val))
DOMSetString(value, buffer);
}
else if (ret_val == OpStatus::ERR_NOT_SUPPORTED)
DOMSetUndefined(value);
if (OpStatus::IsError(ret_val))
return ConvertCallToGetName(HandleJILError(ret_val, value, origining_runtime), value);
}
return GET_SUCCESS;
}
case OP_ATOM_radioSignalStrengthPercent:
{
if (value)
{
double signal_strength;
OP_STATUS ret_val = g_op_telephony_network_info->GetRadioSignalStrength(&signal_strength);
if (!OpStatus::IsError(ret_val))
DOMSetNumber(value, signal_strength);
else if (ret_val == OpStatus::ERR_NOT_SUPPORTED)
DOMSetUndefined(value);
else
return ConvertCallToGetName(HandleJILError(ret_val, value, origining_runtime), value);
}
return GET_SUCCESS;
}
case OP_ATOM_onSignalSourceChange:
DOMSetObject(value, m_on_radio_source_changed);
return GET_SUCCESS;
}
return GET_FAILED;
}
示例4: if
/* static */ OP_STATUS
JS_Console::FormatString(ES_Value* argv, int argc, OpString &str)
{
if (argc == 0)
return OpStatus::OK;
// Holds the formatted string.
TempBuffer buf;
// The argument which will be stringified next.
int argument = 0;
// If the first argument is a string, check if it contains placeholders.
if (argv[0].type == VALUE_STRING)
{
// The first argument is the format string. It may or may not contain
// formatting placeholders (%).
const uni_char *placeholder = argv[0].value.string;
const uni_char *stored = placeholder;
// Skip the formatting string.
++argument;
while ((placeholder = uni_strchr(placeholder, '%')) != NULL)
{
// Calculate the length until the '%'.
int length = (placeholder - stored);
// Skip the '%', and check that 'placeholder' now points to
// a supported character.
if (!JS_Console::IsSupportedPlaceholder(++placeholder))
continue;
// Append everything up until the '%'.
if (length > 0)
RETURN_IF_ERROR(buf.Append(stored, length));
// If the character after the first '%' is another '%', then output
// a single '%'.
if (*placeholder == '%')
RETURN_IF_ERROR(buf.Append("%"));
// Otherwise, append the string representation of the ES_Value.
else if (argument < argc)
RETURN_IF_ERROR(JS_Console::AppendValue(argv[argument++], buf));
// Or, if we don't have more arguments, output the original placeholder.
else
RETURN_IF_ERROR(buf.Append(placeholder - 1, 2));
// Skip the character following the %, but only if not at the
// end of string.
if (*placeholder != '\0')
++placeholder;
stored = placeholder;
}
// Append the rest of the formatting string, if any.
if (*stored != '\0')
RETURN_IF_ERROR(buf.Append(stored));
}
// If we have more arguments, append them in a space delimited list.
while (argument < argc)
{
// Never start a string with a space.
if (argument > 0)
RETURN_IF_ERROR(buf.Append(" "));
RETURN_IF_ERROR(AppendValue(argv[argument++], buf));
}
return str.Set(buf.GetStorage());
}
示例5: GetTabWindow
ES_GetState
DOM_BrowserTab::GetTabInfo(OpAtom property_name, ES_Value* value, ES_Runtime* origining_runtime, ES_Object* restart_object)
{
if (!value)
return GET_SUCCESS;
// Private mode can be obtained synchronously if we have window.
if (property_name == OP_ATOM_private)
{
Window* window = GetTabWindow();
if (window)
{
DOMSetBoolean(value, window->GetPrivacyMode());
return GET_SUCCESS;
}
}
OP_ASSERT(GetTabId());
DOM_TabsApiHelper* call_helper;
if (!restart_object)
{
GET_FAILED_IF_ERROR(DOM_TabsApiHelper::Make(call_helper, static_cast<DOM_Runtime*>(origining_runtime)));
call_helper->QueryTab(GetTabId());
}
else
call_helper = DOM_HOSTOBJECT(restart_object, DOM_TabsApiHelper);
if (call_helper->IsFinished())
{
if (property_name == OP_ATOM_closed)
{
DOMSetBoolean(value, OpStatus::IsError(call_helper->GetStatus()));
return GET_SUCCESS;
}
else
GET_FAILED_IF_ERROR(call_helper->GetStatus());
switch (property_name)
{
case OP_ATOM_browserWindow:
DOM_BrowserWindow* new_win;
GET_FAILED_IF_ERROR(DOM_TabApiCache::GetOrCreateWindow(new_win, m_extension_support, call_helper->GetResult().value.query_tab.browser_window_id, GetRuntime()));
DOMSetObject(value, new_win);
break;
case OP_ATOM_locked:
DOMSetBoolean(value, call_helper->GetResult().value.query_tab.is_locked);
break;
case OP_ATOM_position:
DOMSetNumber(value, call_helper->GetResult().value.query_tab.position);
break;
case OP_ATOM_tabGroup:
if (call_helper->GetResult().value.query_tab.tab_group_id == 0)
DOMSetNull(value);
else
{
DOM_BrowserTabGroup* tab_group;
GET_FAILED_IF_ERROR(DOM_TabApiCache::GetOrCreateTabGroup(tab_group, m_extension_support, call_helper->GetResult().value.query_tab.tab_group_id, GetRuntime()));
DOMSetObject(value, tab_group);
}
break;
case OP_ATOM_focused:
case OP_ATOM_selected:
DOMSetBoolean(value, call_helper->GetResult().value.query_tab.is_selected);
break;
case OP_ATOM_title:
if (!call_helper->GetResult().value.query_tab.is_private || IsPrivateDataAllowed())
{
TempBuffer* tmp = GetEmptyTempBuf();
GET_FAILED_IF_ERROR(tmp->Append(call_helper->GetResult().value.query_tab.title));
DOMSetString(value, tmp);
}
return GET_SUCCESS;
case OP_ATOM_private:
DOMSetBoolean(value, call_helper->GetResult().value.query_tab.is_private);
return GET_SUCCESS;
default:
OP_ASSERT(!"Unexpected property");
}
return GET_SUCCESS;
}
else
return call_helper->BlockGet(value, origining_runtime);
}
示例6: if
/* virtual */ ES_PutState
JS_Location::PutName(OpAtom property_name, ES_Value* value, ES_Runtime* origining_runtime)
{
if (GetName(property_name, NULL, origining_runtime) != GET_SUCCESS)
return PUT_FAILED;
FramesDocument *frames_doc = GetFramesDocument();
if (!frames_doc)
return PUT_SUCCESS;
if (value->type != VALUE_STRING)
return PUT_NEEDS_STRING;
const uni_char *value_string = value->value.string;
while (value_string[0] == ' ')
++value_string;
if (property_name == OP_ATOM_href)
if (value_string[0] == '#')
property_name = OP_ATOM_hash;
else if (value_string[0] == '?')
property_name = OP_ATOM_search;
URL url;
DocumentReferrer ref_url(GetStandardRefURL(frames_doc, origining_runtime));
TempBuffer buffer;
URL current_url = ref_url.url;
#ifdef SELFTEST
if (!do_navigation)
current_url = this->current_url;
#endif // SELFTEST
switch (property_name)
{
case OP_ATOM_href:
case OP_ATOM_protocol:
case OP_ATOM_host:
case OP_ATOM_hostname:
case OP_ATOM_port:
case OP_ATOM_pathname:
BOOL allowed;
if (OpStatus::IsError(OpSecurityManager::CheckSecurity(OpSecurityManager::DOM_ALLOWED_TO_NAVIGATE, static_cast<DOM_Runtime *>(origining_runtime), GetRuntime(), allowed)) ||
!allowed)
return PUT_SECURITY_VIOLATION;
}
switch (property_name)
{
case OP_ATOM_protocol:
{
unsigned length = uni_strlen(value_string);
while (length > 0 && value_string[length - 1] == ':')
length--;
if (length > 0)
{
const uni_char *current_url_string = current_url.GetAttribute(URL::KUniName_Username_Password_NOT_FOR_UI).CStr();
const uni_char *current_scheme_end = uni_strchr(current_url_string, ':');
if (!current_scheme_end)
return PUT_SUCCESS;
PUT_FAILED_IF_ERROR(buffer.Append(value_string, length));
PUT_FAILED_IF_ERROR(buffer.Append(current_scheme_end));
url = GetEncodedURL(origining_runtime->GetFramesDocument(), buffer.GetStorage());
BOOL allowed;
if (url.Type() == URL_JAVASCRIPT)
if (OpStatus::IsError(OpSecurityManager::CheckSecurity(OpSecurityManager::DOM_STANDARD, static_cast<DOM_Runtime *>(origining_runtime), GetRuntime(), allowed)) ||
!allowed)
return PUT_SUCCESS;
}
break;
}
case OP_ATOM_host:
{
const uni_char *current_url_string = current_url.GetAttribute(URL::KUniName_Username_Password_NOT_FOR_UI).CStr();
const uni_char *current_scheme_end = uni_strchr(current_url_string, ':');
// URL must be an "authority-based URL"
if (current_scheme_end && current_scheme_end[1] == '/' && current_scheme_end[2] == '/')
{
OpString hostname;
PUT_FAILED_IF_ERROR(current_url.GetAttribute(URL::KUniHostName, hostname));
/* Just bail if the URL doesn't have a hostname after all. */
if (!hostname.CStr())
return PUT_SUCCESS;
uni_char *hostname_start = uni_strstr(current_url_string, hostname.CStr());
OP_ASSERT(hostname_start);
uni_char *hostname_end = hostname_start + hostname.Length();
unsigned short port = current_url.GetAttribute(URL::KServerPort);
if (port > 0 && *hostname_end == ':')
{
hostname_end++;
while (uni_isdigit(*hostname_end))
hostname_end++;
}
//.........这里部分代码省略.........
示例7:
/* virtual */ OP_STATUS
DOM_XSLTStringDataCollector::CollectStringData(const uni_char *string, unsigned string_length)
{
return resulting_text.Append(string, string_length);
}