Пример #1
0
std::vector<long long> q::qList2Dec(K data) throw(std::string) {
	if (data == K_NIL) {
		throw std::string("nil decimal list");
	}
	else if (data->t <= 0) {
		throw std::string("not a decimal list");
	}
	assert(data->n >= 0);
	std::vector<long long> result(static_cast<std::size_t>(data->n), 0L);
	switch (data->t) {
	case KB: {
		struct Converter {
			long long operator()(G x) const { return x ? 1 : 0; }
		};
		std::transform(kG(data), kG(data) + data->n, result.begin(), Converter());
		break;
	}
	case KG:
		std::copy(kG(data), kG(data) + data->n, result.begin());
		break;
	case KH:
		std::copy(kH(data), kH(data) + data->n, result.begin());
		break;
	case KI:
		std::copy(kI(data), kI(data) + data->n, result.begin());
		break;
	case KJ:
		std::copy(kJ(data), kJ(data) + data->n, result.begin());
		break;
	default:
		throw std::string("not a decimal list");
	}
	return result;
}
Пример #2
0
bool FCrashUpload::SendCheckReportRequest()
{
	FString XMLString;

	UE_LOG(CrashReportClientLog, Log, TEXT("Sending HTTP request (checking report)"));
	auto Request = CreateHttpRequest();
	if (State == EUploadState::CheckingReport)
	{
		AssignReportIdToPostDataBuffer();
		Request->SetURL(UrlPrefix / TEXT("CheckReport"));
		Request->SetHeader(TEXT("Content-Type"), TEXT("text/plain; charset=us-ascii"));
	}
	else
	{
		// This part is Windows-specific on the server
		ErrorReport.LoadWindowsReportXmlFile( XMLString );

		// Convert the XMLString into the UTF-8.
		FTCHARToUTF8 Converter( (const TCHAR*)*XMLString, XMLString.Len() );
		const int32 Length = Converter.Length();
		PostData.Reset( Length );
		PostData.AddUninitialized( Length );
		CopyAssignItems( (ANSICHAR*)PostData.GetData(), Converter.Get(), Length );

		Request->SetURL(UrlPrefix / TEXT("CheckReportDetail"));
		Request->SetHeader(TEXT("Content-Type"), TEXT("text/plain; charset=utf-8"));
	}

	UE_LOG( CrashReportClientLog, Log, TEXT( "PostData Num: %i" ), PostData.Num() );
	Request->SetVerb(TEXT("POST"));
	Request->SetContent(PostData);

	return Request->ProcessRequest();
}
void convert (const collada::Model& source, animation::AnimationLibrary& destination, const char* merge_animation)
{
  if (!merge_animation)
    throw xtl::make_null_argument_exception ("media::collada::convert (const collada::Model&, AnimationLibrary&, const char*)", "merge_animation");

  Converter (source, destination, merge_animation);
}
Пример #4
0
std::vector<double> q::qList2Fp(K data) throw(std::string) {
	if (data == K_NIL) {
		throw std::string("nil floating-point list");
	}
	else if (data->t <= 0) {
		throw std::string("not a floating-point list");
	}
	assert(data->n >= 0);
	std::vector<double> result(static_cast<std::size_t>(data->n), 0.);
	switch (data->t) {
	case KB:
	case KG:
	case KH:
	case KI:
	case KJ: {
		std::vector<long long> decs = qList2Dec(data);
		struct Converter {
			double operator()(long long x) const { return static_cast<double>(x); }
		};
		std::transform(decs.begin(), decs.end(), result.begin(), Converter());
		break;
	}
	case KE:
		std::copy(kE(data), kE(data) + data->n, result.begin());
		break;
	case KF:
		std::copy(kF(data), kF(data) + data->n, result.begin());
		break;
	default:
		throw std::string("not a floating-point list");
	}
	return result;
}
Пример #5
0
FString FGenericPlatformHttp::UrlEncode(const FString &UnencodedString)
{
	FTCHARToUTF8 Converter(*UnencodedString);	//url encoding must be encoded over each utf-8 byte
	const UTF8CHAR* UTF8Data = (UTF8CHAR*) Converter.Get();	//converter uses ANSI instead of UTF8CHAR - not sure why - but other code seems to just do this cast. In this case it really doesn't matter
	FString EncodedString = TEXT("");
	
	TCHAR Buffer[2] = { 0, 0 };

	for (int32 ByteIdx = 0, Length = Converter.Length(); ByteIdx < Length; ++ByteIdx)
	{
		UTF8CHAR ByteToEncode = UTF8Data[ByteIdx];
		
		if (IsAllowedChar(ByteToEncode))
		{
			Buffer[0] = ByteToEncode;
			FString TmpString = Buffer;
			EncodedString += TmpString;
		}
		else if (ByteToEncode != '\0')
		{
			EncodedString += TEXT("%");
			EncodedString += FString::Printf(TEXT("%.2X"), ByteToEncode);
		}
	}
	return EncodedString;
}
Пример #6
0
int main(int argc, char** argv) {
    Expression expr = parseArguments(argc, argv);
    printf("%lf %d to %d = ", expr.value,
        expr.curUnit, expr.newUnit);
    AreaConverter Converter(expr.value, expr.curUnit);
    printf("%lf", Converter.ConvertToNewType(expr.newUnit));
    return 0;
}
Пример #7
0
 UString::UString(
     const char *    _STRING
 )
     : UStringBase(
         Converter(
             _STRING
             , std::strlen( _STRING )
         ).getString()
     )
 {
 }
Пример #8
0
 UString::UString(
     const String &  _STRING
 )
     : UStringBase(
         Converter(
             _STRING.getPtr()
             , _STRING.getSize()
         ).getString()
     )
 {
 }
PoissonDiskSampling3D::PoissonDiskSampling3D(int size_x, int size_y, int size_z, double pitch):size_x_(size_x), size_y_(size_y), size_z_(size_z), pitch_(pitch)
{
	nodes_.resize(size_x_*size_y_*size_z_);
	for(int k=0; k<size_z_; k++){
		for(int j=0; j<size_y_; j++){
			for(int i=0; i<size_x_; i++){		
				nodes_[i+j*size_x_+k*size_x_*size_y_] = Node(i, j, k, 1.0);
			}
		}
	}
	srand(time(0));
	func_ = NULL;
	f_ = Converter();
	origin_ = Eigen::Vector3d::Zero();
}
Пример #10
0
bool FXmlFile::Save(const FString& Path)
{
	FString Xml;
	Xml += TEXT("<?xml version=\"1.0\" encoding=\"UTF-8\"?>") LINE_TERMINATOR;

	TArray<const FXmlNode*> NodeStack;
	static const TCHAR Tabs[] = TEXT("\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t");
	auto Indent = &Tabs[ARRAY_COUNT(Tabs) - 1];
	const auto* CurrentNode = GetRootNode();
	while (CurrentNode)
	{
		if (auto Child = CurrentNode->GetFirstChildNode())
		{
			NodeStack.Push(CurrentNode);
			Xml += FString::Printf(TEXT("%s<%s>") LINE_TERMINATOR, Indent, *CurrentNode->GetTag());

			CurrentNode = Child;	
			// Actually increases the indent by one tab
			--Indent;
			continue;
		}

		auto Tag = *CurrentNode->GetTag();
		Xml += FString::Printf(TEXT("%s<%s>%s</%s>") LINE_TERMINATOR, Indent, Tag, *CurrentNode->GetContent(), Tag);
		CurrentNode = CurrentNode->GetNextNode();

		while (!CurrentNode && NodeStack.Num() != 0)
		{
			// Actually decreases the indent by one tab
			++Indent;
			CurrentNode = NodeStack.Pop();
			Xml += FString::Printf(TEXT("%s</%s>") LINE_TERMINATOR, Indent, *CurrentNode->GetTag());
			CurrentNode = CurrentNode->GetNextNode();
		}
	}
	
	TUniquePtr<FArchive> Archive(IFileManager::Get().CreateFileWriter(*Path));
	if (!Archive)
	{
		ErrorMessage = NSLOCTEXT("XmlParser", "FileSaveFail", "Failed to save the file").ToString();
		ErrorMessage += FString::Printf(TEXT("\"%s\""), *Path);
		return false;
	}

	FTCHARToUTF8 Converter(*Xml);
	Archive->Serialize(const_cast<char*>(Converter.Get()), Converter.Length());
	return true;
}
Пример #11
0
bool FPerfCounters::ReportUnplayableCondition(const FString& ConditionDescription)
{
	FString UnplayableConditionFile(FPaths::Combine(*FPaths::GameSavedDir(), *FString::Printf(TEXT("UnplayableConditionForPid_%d.txt"), FPlatformProcess::GetCurrentProcessId())));

	FArchive* ReportFile = IFileManager::Get().CreateFileWriter(*UnplayableConditionFile);
	if (UNLIKELY(ReportFile == nullptr))
	{
		return false;
	}

	// include description for debugging
	FTCHARToUTF8 Converter(*FString::Printf(TEXT("Unplayable condition encountered: %s\n"), *ConditionDescription));
	ReportFile->Serialize(reinterpret_cast<void *>(const_cast<char *>(Converter.Get())), Converter.Length());

	ReportFile->Close();
	delete ReportFile;

	return true;
}
Пример #12
0
bool FXmlFile::Save(const FString& Path)
{
	FString Xml = TEXT("<?xml version=\"1.0\" encoding=\"UTF-8\"?>") LINE_TERMINATOR;

	const FXmlNode* CurrentNode = GetRootNode();
	if(CurrentNode != nullptr)
	{
		WriteNodeHierarchy(*CurrentNode, FString(), Xml);
	}
	
	TUniquePtr<FArchive> Archive(IFileManager::Get().CreateFileWriter(*Path));
	if (!Archive)
	{
		ErrorMessage = NSLOCTEXT("XmlParser", "FileSaveFail", "Failed to save the file").ToString();
		ErrorMessage += FString::Printf(TEXT("\"%s\""), *Path);
		return false;
	}

	FTCHARToUTF8 Converter(*Xml);
	Archive->Serialize(const_cast<char*>(Converter.Get()), Converter.Length());
	return true;
}
Пример #13
0
bool ConvertStorage1To2(GView *Parent, char *InFile, char *OutFile)
{
	GFileSelect In;
	In.Parent(Parent);
	In.Type("Mail folders", "*.mail");
	if (!InFile &&
		In.Open())
	{
		InFile = In.Name();
	}

	if (InFile)
	{
		GFileSelect Out;
		Out.Parent(Parent);
		Out.Type("Mail folders", "*.mail2");
		if ((!OutFile || strlen(OutFile) == 0) &&
			Out.Save())
		{
			if (OutFile)
			{
				strcpy(OutFile, Out.Name());
			}
			else
			{
				OutFile = Out.Name();
			}
		}

		if (OutFile)
		{
			StoreConverter1To2 Converter(InFile, OutFile);
			return Converter.Convert(Parent);
		}
	}

	return false;
}
///Преобразование коллада-модели в библиотеку мешей
void convert_triangle_meshes (const collada::Model& source, physics::PhysicsLibrary& destination)
{
  Converter (source, destination);
}
Пример #15
0
FString FGenericPlatformHttp::UrlDecode(const FString &EncodedString)
{
	FTCHARToUTF8 Converter(*EncodedString);	
	const UTF8CHAR* UTF8Data = (UTF8CHAR*)Converter.Get();	
	
	TArray<ANSICHAR> Data;
	Data.Reserve(EncodedString.Len());

	for (int32 CharIdx = 0; CharIdx < Converter.Length();)
	{
		if (UTF8Data[CharIdx] == '%')
		{
			int32 Value = 0;
			if (UTF8Data[CharIdx + 1] == 'u')
			{
				if (CharIdx + 6 <= Converter.Length())
				{
					// Treat all %uXXXX as code point
					Value = FParse::HexDigit(UTF8Data[CharIdx + 2]) << 12;
					Value += FParse::HexDigit(UTF8Data[CharIdx + 3]) << 8;
					Value += FParse::HexDigit(UTF8Data[CharIdx + 4]) << 4;
					Value += FParse::HexDigit(UTF8Data[CharIdx + 5]);
					CharIdx += 6;

					ANSICHAR Buffer[8] = { 0 };
					ANSICHAR* BufferPtr = Buffer;
					int32 len = ARRAY_COUNT(Buffer);
					FTCHARToUTF8_Convert::utf8fromcodepoint(Value, &BufferPtr, &len);

					Data.Append(Buffer, BufferPtr - Buffer);
				}
				else
				{
					// Not enough in the buffer for valid decoding, skip it
					CharIdx++;
					continue;
				}
			}
			else if(CharIdx + 3 <= Converter.Length())
			{
				// Treat all %XX as straight byte
				Value = FParse::HexDigit(UTF8Data[CharIdx + 1]) << 4;
				Value += FParse::HexDigit(UTF8Data[CharIdx + 2]);
				CharIdx += 3;
				Data.Add((ANSICHAR)(Value));
			}
			else
			{
				// Not enough in the buffer for valid decoding, skip it
				CharIdx++;
				continue;
			}
		}
		else
		{
			// Non escaped characters
			Data.Add(UTF8Data[CharIdx]);
			CharIdx++;
		}
	}

	Data.Add(0);
	FUTF8ToTCHAR DecodeConvert(Data.GetData());
	return DecodeConvert.Get();
}
Пример #16
0
void FHttpRequestWinInet::SetContentAsString(const FString& ContentString)
{
	FTCHARToUTF8 Converter(*ContentString);
	RequestPayload.SetNumUninitialized(ContentString.Len());
	FMemory::Memcpy(RequestPayload.GetTypedData(), (const uint8*)Converter.Get(), RequestPayload.Num());
}
Пример #17
0
int main() {
    AreaConverter Converter(100, sKilometer);
    printf("100 kilomerers = %lf foots \n", Converter.ConvertToNewType(sFoot) );
    return 0;
}
//преобразование коллада-модели в библиотеку анимаций
void convert (const media::collada::Model& src_model, animation::AnimationLibrary& dst_library)
{
  Converter (src_model, dst_library);
}