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


C++ TempBuffer类代码示例

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


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

示例1: RETURN_IF_ERROR

/* static */ OP_STATUS
DOM_LSInput::GetStringData(const uni_char *&stringData, ES_Object *input, DOM_EnvironmentImpl *environment)
{
	DOM_Runtime *runtime = environment->GetDOMRuntime();
	OP_BOOLEAN result;
	ES_Value value;

	stringData = NULL;

	RETURN_IF_ERROR(result = runtime->GetName(input, UNI_L("characterStream"), &value));
	if (result == OpBoolean::IS_TRUE && value.type != VALUE_NULL && value.type != VALUE_UNDEFINED && !(value.type == VALUE_STRING && *value.value.string))
		return OpStatus::OK;

	RETURN_IF_ERROR(result = runtime->GetName(input, UNI_L("byteStream"), &value));
	if (result == OpBoolean::IS_TRUE && value.type != VALUE_NULL && value.type != VALUE_UNDEFINED && !(value.type == VALUE_STRING && *value.value.string))
		return OpStatus::OK;

	RETURN_IF_ERROR(result = runtime->GetName(input, UNI_L("stringData"), &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));
		stringData = buffer->GetStorage();
	}

	return OpStatus::OK;
}
开发者ID:prestocore,项目名称:browser,代码行数:27,代码来源:lsinput.cpp

示例2: OP_ASSERT

double
XPath_ConversionExpressionHelper::GetNumberL (XPath_Context *context, BOOL initial)
{
  OP_ASSERT (!numberexpression);

  StartL (context, initial);

  TempBuffer buffer; ANCHOR (TempBuffer, buffer);
  if (GetStringValueL (context, initial, buffer))
    return XPath_Value::AsNumber (buffer.GetStorage ());
  else if (booleanexpression)
    return booleanexpression->EvaluateToBooleanL (context, initial) ? 1. : 0.;
  else if (stringexpression)
    return XPath_Value::AsNumber (stringexpression->EvaluateToStringL (context, initial, buffer));

#ifdef XPATH_EXTENSION_SUPPORT
  OP_ASSERT (unknown);
  XPath_Value *value = unknown->EvaluateL (context, initial);
  double number = value->AsNumberL ();
  XPath_Value::DecRef (context, value);
  return number;
#else // XPATH_EXTENSION_SUPPORT
  OP_ASSERT (FALSE);
  return op_nan (0);
#endif // XPATH_EXTENSION_SUPPORT
}
开发者ID:prestocore,项目名称:browser,代码行数:26,代码来源:xpexpr.cpp

示例3: MapAttributeToPropertyName

/**
 * Returns OpStatus:ERR if there is no legal mapping.
 */
static OP_STATUS MapAttributeToPropertyName(const uni_char* attr, TempBuffer& prop)
{
	if (uni_strncmp(attr, "data-", 5) != 0)
		return OpStatus::ERR;

	attr += 5;
	const uni_char* p = attr;
	while (*p)
	{
		if (*p >= 'A' && *p <= 'Z')
			return OpStatus::ERR;
		p++;
	}

	while (*attr)
	{
		if (*attr == '-' && attr[1] >= 'a' && attr[1] <= 'z')
		{
			RETURN_IF_ERROR(prop.Append(attr[1] - 'a' + 'A'));
			attr++;
		}
		else
			RETURN_IF_ERROR(prop.Append(*attr));
		attr++;
	}

	return OpStatus::OK;
}
开发者ID:prestocore,项目名称:browser,代码行数:31,代码来源:domstringmap.cpp

示例4: ANCHOR

/* static */ double
XPath_Value::AsNumberL (const uni_char *string, unsigned string_length)
{
  TempBuffer buffer; ANCHOR (TempBuffer, buffer);
  buffer.AppendL (string, string_length);

  uni_char *endptr;
  return uni_strtod (buffer.GetStorage (), &endptr);
}
开发者ID:prestocore,项目名称:browser,代码行数:9,代码来源:xpvalue.cpp

示例5:

/* static */ OP_STATUS
JS_Console::AppendValue(const ES_Value &value, TempBuffer &buf)
{
	switch (value.type)
	{
	case VALUE_UNDEFINED:
		return buf.Append("undefined");
	case VALUE_NULL:
		return buf.Append("null");
	case VALUE_BOOLEAN:
		return buf.Append(value.value.boolean ? "true" : "false");
	case VALUE_NUMBER:
		return buf.AppendDouble(value.value.number);
	case VALUE_STRING:
		return buf.Append(value.value.string);
	case VALUE_OBJECT:
		RETURN_IF_ERROR(buf.Append("[object "));
		RETURN_IF_ERROR(buf.Append(ES_Runtime::GetClass(value.value.object)));
		return buf.Append("]");
	case VALUE_STRING_WITH_LENGTH:
		return buf.Append(value.value.string_with_length->string, value.value.string_with_length->length);
	}

	return OpStatus::OK;
}
开发者ID:prestocore,项目名称:browser,代码行数:25,代码来源:js_console.cpp

示例6: ANCHOR

XMLTreeAccessor::Node *
XPath_Node::GetTreeNodeByIdL (const uni_char *id, unsigned id_length)
{
  TempBuffer buffer; ANCHOR (TempBuffer, buffer);
  buffer.AppendL (id, id_length);

  XMLTreeAccessor::Node *node;
  LEAVE_IF_ERROR (tree->GetElementById (node, buffer.GetStorage ()));

  return node;
}
开发者ID:prestocore,项目名称:browser,代码行数:11,代码来源:xpnode.cpp

示例7: app2net

std::string app2net(const wchar_t * w, int cp)
{
	if (!w)
		return std::string();

	// utf16 -> utf8
	TempBuffer<char> str;

	// 计算大小
	int size = WideCharToMultiByte(cp, 0, w, -1, NULL, NULL, NULL, NULL);

	// 转换
	WideCharToMultiByte(cp, 0, w, -1, str.Allocate(size), size, NULL, NULL);

	return std::string(str.data());
}
开发者ID:NonPlayerCharactor,项目名称:serviceframe,代码行数:16,代码来源:utf8to.cpp

示例8: Scale_BGRA_Generic

void Scale_BGRA_Generic(unsigned int in_w, unsigned int in_h, const uint8_t* in_data, int in_stride,
						unsigned int out_w, unsigned int out_h, uint8_t* out_data, int out_stride,
						MipMapFunction mipmap_function, BilinearFunction bilinear_function) {

	// no scaling?
	if(in_w == out_w && in_h == out_h) {
		if(in_stride == out_stride) {
			memcpy(out_data, in_data, in_stride * in_h);
		} else {
			for(unsigned int out_j = 0; out_j < out_h; ++out_j) {
				memcpy(out_data, in_data, in_w * 4);
				in_data += in_stride;
				out_data += out_stride;
			}
		}
		return;
	}

	// calculate mipmap factors
	unsigned int mx = 0, my = 0;
	while((out_w << (mx + 1)) <= in_w) ++mx;
	while((out_h << (my + 1)) <= in_h) ++my;
	if(mx + my > 8) {
		if(mx <= 4)
			my = 8 - mx;
		else if(my <= 4)
			mx = 8 - my;
		else
			mx = my = 4;
	}

	// pure mipmap scaling?
	if((out_w << mx) == in_w && (out_h << my) == in_h) {
		mipmap_function(in_w, in_h, in_data, in_stride, out_data, out_stride, mx, my);
		return;
	}

	// create mipmap
	TempBuffer<uint8_t> mipmap;
	if(mx != 0 || my != 0) {
		unsigned int mipmap_w = ((in_w - 1) >> mx) + 1, mipmap_h = ((in_h - 1) >> my) + 1;
		int mipmap_stride = grow_align16(mipmap_w * 4);
		mipmap.Alloc(mipmap_stride * mipmap_h);
		mipmap_function(in_w, in_h, in_data, in_stride, mipmap.GetData(), mipmap_stride, mx, my);
		in_data = mipmap.GetData();
		in_stride = mipmap_stride;
	}
开发者ID:MaartenBaert,项目名称:ssr-packages,代码行数:47,代码来源:FastScaler_Scale_Generic.cpp

示例9: MapPropertyToAttributeName

/**
 * Returns OpStatus:ERR if there is no legal mapping.
 */
static OP_STATUS MapPropertyToAttributeName(const uni_char* prop, TempBuffer& attr)
{
	RETURN_IF_ERROR(attr.Append("data-"));
	while (*prop)
	{
		if (*prop == '-' && prop[1] >= 'a' && prop[1] <= 'z')
			return OpStatus::ERR;

		if (*prop >= 'A' && *prop <= 'Z')
		{
			RETURN_IF_ERROR(attr.Append('-'));
			RETURN_IF_ERROR(attr.Append(*prop - 'A' + 'a'));
		}
		else
			RETURN_IF_ERROR(attr.Append(*prop));

		prop++;
	}
	return OpStatus::OK;
}
开发者ID:prestocore,项目名称:browser,代码行数:23,代码来源:domstringmap.cpp

示例10: XMLWriteToFileEscaped

static OP_STATUS
XMLWriteToFileEscaped (OpFile &file, const uni_char *string)
{
  if (*string)
    {
      TempBuffer buffer;

      while (*string)
        {
          if (*string == '&')
            RETURN_IF_ERROR (buffer.Append ("&#38;"));
          else if (*string == '<')
            RETURN_IF_ERROR (buffer.Append ("&#60;"));
          else if (*string == '\'')
            RETURN_IF_ERROR (buffer.Append ("&#27;"));
          else
            RETURN_IF_ERROR (buffer.Append (*string));

          ++string;
        }

      return XMLWriteToFile (file, buffer.GetStorage ());
    }
  else
    return OpStatus::OK;
}
开发者ID:prestocore,项目名称:browser,代码行数:26,代码来源:xmldoctype_dump.cpp

示例11:

OP_STATUS
DOM_CSSStyleDeclaration::MutationState::AfterChange()
{
	if (send_attrmodified)
	{
		TempBuffer newBuffer;
		StyleAttribute* styleattr = element->GetThisElement()->GetStyleAttribute();
		if (styleattr)
			OpStatus::Ignore(styleattr->ToString(&newBuffer));

		const uni_char *prevValue = prevBuffer.GetStorage(), *newValue = newBuffer.GetStorage();
		if (!(prevValue == newValue || prevValue && newValue && uni_strcmp(prevValue, newValue) == 0))
		{
			DOM_Attr* attr;
			PUT_FAILED_IF_ERROR(element->GetAttributeNode(attr, ATTR_XML, UNI_L("style"), NS_IDX_DEFAULT, TRUE, TRUE, TRUE));
			if (attr)
				PUT_FAILED_IF_ERROR(element->SendAttrModified(DOM_Object::GetCurrentThread(origining_runtime), attr, prevValue, newValue));
		}
	}

	return OpStatus::OK;
}
开发者ID:prestocore,项目名称:browser,代码行数:22,代码来源:cssstyledeclaration.cpp

示例12:

void
XPath_Node::GetQualifiedNameL (TempBuffer &qname)
{
  OP_ASSERT (type == XP_NODE_ELEMENT || type == XP_NODE_ATTRIBUTE);

  XMLCompleteName temporary, *completename;

  if (type == XP_NODE_ELEMENT)
    {
      tree->GetName (temporary, treenode);
      completename = &temporary;
    }
  else
    completename = &name;

  const uni_char *prefix = completename->GetPrefix ();
  if (prefix)
    {
      qname.AppendL (prefix);
      qname.AppendL (":");
    }

  qname.AppendL (completename->GetLocalPart ());
}
开发者ID:prestocore,项目名称:browser,代码行数:24,代码来源:xpnode.cpp

示例13: GetEmptyTempBuf

/* virtual */ ES_GetState
JS_Location::GetName(OpAtom property_name, ES_Value* value, ES_Runtime* origining_runtime)
{
	TempBuffer *buffer = GetEmptyTempBuf();
	URL url;

	if (fakewindow)
		url = fakewindow->GetURL();
#ifdef SELFTEST
	else if (!do_navigation)
		url = current_url;
#endif // SELFTEST
	else if (FramesDocument *frames_doc = GetFramesDocument())
	{
		url = frames_doc->GetURL();

		// The anchors (hash) might be better in DocumentManager
		URL doc_man_url = frames_doc->GetDocManager()->GetCurrentURL();
		if (doc_man_url == url) // Doesn't compare anchors
			url = doc_man_url;
	}
#ifdef DOM_WEBWORKERS_SUPPORT
	/* No FramesDocument to query, so consult the origin DocumentManager for the Worker */
	if (!GetFramesDocument())
	{
		DOM_WebWorkerController *web_workers = GetEnvironment()->GetWorkerController();
		if (DOM_WebWorker *ww = web_workers->GetWorkerObject())
			url = ww->GetLocationURL();
		else if (DocumentManager *doc = web_workers->GetWorkerDocManager())
			url = doc->GetCurrentURL();
		OP_ASSERT(!url.IsEmpty());
	}
#endif // DOM_WEBWORKERS_SUPPORT

	switch (property_name)
	{
	case OP_ATOM_href:
		DOMSetString(value, url.GetAttribute(URL::KUniName_With_Fragment_Escaped).CStr());
		return GET_SUCCESS;

	case OP_ATOM_protocol:
		if (value)
		{
			const char *protocol = url.GetAttribute(URL::KProtocolName).CStr();
			if (protocol)
			{
				GET_FAILED_IF_ERROR(buffer->Append(protocol));
				GET_FAILED_IF_ERROR(buffer->Append(":"));
			}

			DOMSetString(value, buffer);
		}
		return GET_SUCCESS;

	case OP_ATOM_host:
	case OP_ATOM_hostname:
		if (value)
		{
			const uni_char *name = url.GetServerName() ? url.GetServerName()->UniName() : NULL;

			if (property_name == OP_ATOM_host)
			{
				unsigned short port = url.GetServerPort();
				if (port)
				{
					GET_FAILED_IF_ERROR(buffer->Append(name));
					GET_FAILED_IF_ERROR(buffer->Append(":"));
					GET_FAILED_IF_ERROR(buffer->AppendUnsignedLong(port));
					name = buffer->GetStorage();
				}
			}

			DOMSetString(value, name);
		}
		return GET_SUCCESS;

	case OP_ATOM_port:
		if (value)
		{
			unsigned short port = url.GetServerPort();
			if (port)
				GET_FAILED_IF_ERROR(buffer->AppendUnsignedLong(port));

			DOMSetString(value, buffer);
		}
		return GET_SUCCESS;

	case OP_ATOM_pathname:
		if (value)
		{
			const uni_char *path = url.GetAttribute(URL::KUniPath).CStr();

			if (path)
			{
				GET_FAILED_IF_ERROR(buffer->Append(path));
				uni_char *path_tmp = buffer->GetStorage();

				/* It isn't obvious from the JS spec and the relevant RFC, but in
				   Javascript the 'pathname' excludes any arguments passed to the page. */
				if (uni_char *query_start = uni_strchr(path_tmp, '?'))
//.........这里部分代码省略.........
开发者ID:prestocore,项目名称:browser,代码行数:101,代码来源:location.cpp

示例14: switch

/* 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;
}
开发者ID:prestocore,项目名称:browser,代码行数:74,代码来源:domjilradioinfo.cpp

示例15: GetFramesDocument

/* 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++;
			}
//.........这里部分代码省略.........
开发者ID:prestocore,项目名称:browser,代码行数:101,代码来源:location.cpp


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