mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 20:42:21 +02:00
Minor lib changes
This commit is contained in:
parent
9d125eaaf2
commit
891e4fd789
4 changed files with 58 additions and 0 deletions
|
@ -295,6 +295,12 @@ namespace System
|
|||
return Span<uint8>((uint8*)mPtr, mLength * sizeof(T));
|
||||
}
|
||||
|
||||
public void Sort(Comparison<T> comp)
|
||||
{
|
||||
var sorter = Sorter<T, void>(Ptr, null, Length, comp);
|
||||
sorter.[Friend]Sort(0, Length);
|
||||
}
|
||||
|
||||
public Enumerator GetEnumerator()
|
||||
{
|
||||
return Enumerator(this);
|
||||
|
|
|
@ -3487,6 +3487,12 @@ namespace System
|
|||
mLength = length;
|
||||
}
|
||||
|
||||
public this(Span<uint8> data)
|
||||
{
|
||||
mPtr = (.)data.Ptr;
|
||||
mLength = data.Length;
|
||||
}
|
||||
|
||||
public ref char8 this[int index]
|
||||
{
|
||||
[Checked]
|
||||
|
|
|
@ -865,6 +865,15 @@ namespace CURL
|
|||
[CLink, CallingConvention(.Stdcall)]
|
||||
static extern void* curl_easy_init();
|
||||
|
||||
[CLink, CallingConvention(.Stdcall)]
|
||||
static extern void curl_free(void* ptr);
|
||||
|
||||
[CLink, CallingConvention(.Stdcall)]
|
||||
static extern char8* curl_easy_escape(void* curl, char8* str, int32 length);
|
||||
|
||||
[CLink, CallingConvention(.Stdcall)]
|
||||
static extern char8* curl_easy_unescape(void* curl, char8* input, int32 inlength, int32* outlength);
|
||||
|
||||
[CLink, CallingConvention(.Stdcall)]
|
||||
static extern int curl_easy_setopt(void* curl, int option, int optVal);
|
||||
|
||||
|
@ -984,5 +993,26 @@ namespace CURL
|
|||
{
|
||||
curl_slist_free_all(list);
|
||||
}
|
||||
|
||||
public void Escape(StringView str, String outStr)
|
||||
{
|
||||
char8* ptr = curl_easy_escape(mCURL, str.Ptr, (.)str.Length);
|
||||
if (ptr != null)
|
||||
{
|
||||
outStr.Append(ptr);
|
||||
curl_free(ptr);
|
||||
}
|
||||
}
|
||||
|
||||
public void Unescape(StringView str, String outStr)
|
||||
{
|
||||
int32 outLen = 0;
|
||||
char8* ptr = curl_easy_unescape(mCURL, str.Ptr, (.)str.Length, &outLen);
|
||||
if (ptr != null)
|
||||
{
|
||||
outStr.Append(ptr, outLen);
|
||||
curl_free(ptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -161,6 +161,22 @@ namespace CURL
|
|||
mCurl.SetOpt(.Postfields, param);
|
||||
}
|
||||
|
||||
public void Escape(StringView str, String outStr)
|
||||
{
|
||||
mCurl.Escape(str, outStr);
|
||||
}
|
||||
|
||||
public void Unescape(StringView str, String outStr)
|
||||
{
|
||||
int startPos = outStr.Length;
|
||||
|
||||
mCurl.Unescape(str, outStr);
|
||||
|
||||
for (int i = startPos; i < outStr.Length; i++)
|
||||
if (outStr[i] == '+')
|
||||
outStr[i] = ' ';
|
||||
}
|
||||
|
||||
public Result<Span<uint8>> Perform()
|
||||
{
|
||||
if (mHeaderList != null)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue