Page 1 of 1

Dynamically create String variables

Posted: Sun Dec 10, 2017 9:22 am
by PrinceOfFunky
I was looking through all the native function declarations in the UT packages and I found interesting stuff in WebRequest.uc:

Code: Select all

native final function AddVariable(string VariableName, string Value);
native final function string GetVariable(string VariableName, optional string DefaultValue);
native final function int GetVariableCount(string VariableName);
native final function string GetVariableNumber(string VariableName, int Number, optional string DefaultValue);
Does it mean we could dynamically create String variables like with a dynamic array?

Also, this variable is another interesting thing:

Code: Select all

var private native const int VariableMap[5];	// TMultiMap<FString, FString>!
I wonder if this map could be set by SetPropertyText().

And this is what I found in WebResponse.uc:

Code: Select all

native final function IncludeBinaryFile(string Filename);
Does it mean we can send binary files to those who access our UT built webpage?

Re: Dynamically create String variables

Posted: Sun Dec 10, 2017 12:24 pm
by Barbie
PrinceOfFunky wrote:Does it mean we could dynamically create String variables like with a dynamic array?
From a first and quick view: no. I guess that these functions manage ampersand-separated name/value-pairs (aka "associative array") that are used in a URL for example:

Code: Select all

http://23.45.67.89/page.html?name1=value1&name2=value2

Re: Dynamically create String variables

Posted: Sun Dec 10, 2017 1:20 pm
by nogardilaref
What Barbie said. ^
Everything there represents an HTTP request and nothing more.

As a matter of fact, as it is, the HTTP support is extremely primitive with those classes however, but fortunately the engine gives you full control of what you send and receive so you can essentially create your own HTTP request class pretty much from scratch, and theoretically even support for SSL and HTTP/2 would be possible, although it wouldn't probably compensate the effort.
PrinceOfFunky wrote: And this is what I found in WebResponse.uc:

Code: Select all

native final function IncludeBinaryFile(string Filename);
Does it mean we can send binary files to those who access our UT built webpage?
Yes, that's mostly meant for things like images though, like returning a JPG or PNG as part of your web interface, but you can return anything really.

Re: Dynamically create String variables

Posted: Sun Dec 10, 2017 5:19 pm
by PrinceOfFunky
I know it's for the HTTP query string options, but it's still an AddVariable() and GetVariable(), so I guess it can be used to store an arbitrary amount of string variables, no?

Re: Dynamically create String variables

Posted: Sun Dec 10, 2017 5:29 pm
by Higor
UnTemplate.h > TMap
That's what it is, all you're seeing is a halfassed unrealscript implementation.