CloverBootloader/rEFIt_UEFI/cpp_foundation/XString.cpp

106 lines
3.0 KiB
C++
Raw Normal View History

2020-04-23 15:20:48 +02:00
//*************************************************************************************************
//*************************************************************************************************
//
2020-03-12 15:40:38 +01:00
// STRING
2020-04-23 15:20:48 +02:00
//
// Developed by jief666, from 1997.
//
//*************************************************************************************************
//*************************************************************************************************
2020-03-12 15:40:38 +01:00
#if 0
2020-04-24 11:30:09 +02:00
#define DBG(...) printf__VA_ARGS__)
2020-03-12 15:40:38 +01:00
#else
#define DBG(...)
#endif
2020-04-24 11:30:09 +02:00
#include <Platform.h>
2020-03-12 15:40:38 +01:00
#include "XString.h"
#include "../../Include/Library/printf_lite.h"
2020-03-12 15:40:38 +01:00
2020-04-23 15:20:48 +02:00
//-----------------------------------------------------------------------------
// Functions
//-----------------------------------------------------------------------------
//
2020-04-30 08:22:26 +02:00
//constexpr LString8 operator"" _XS8 ( const char* s, size_t len)
//{
//// LString8 returnValue;
//// returnValue.takeValueFromLiteral(s);
//// (void)len;
//// return returnValue; // don't do "return returnValue.takeValueFrom(s, len)" because it break the return value optimization.
// return LString8(s); // don't do "return returnValue.takeValueFrom(s, len)" because it break the return value optimization.
//}
//
//XString16 operator"" _XS16 ( const char16_t* s, size_t len)
//{
// XString16 returnValue;
// returnValue.takeValueFromLiteral(s);
// (void)len;
// return returnValue; // don't do "return returnValue.takeValueFrom(s, len)" because it break the return value optimization.
//}
//
//XString32 operator"" _XS32 ( const char32_t* s, size_t len)
//{
// XString32 returnValue;
// returnValue.takeValueFromLiteral(s);
// (void)len;
// return returnValue; // don't do "return returnValue.takeValueFrom(s, len)" because it break the return value optimization.
//}
//
//XStringW operator"" _XSW ( const wchar_t* s, size_t len)
//{
// XStringW returnValue;
// returnValue.takeValueFromLiteral(s);
// (void)len;
// return returnValue; // don't do "return returnValue.takeValueFrom(s, len)" because it break the return value optimization.
//}
2020-03-12 15:40:38 +01:00
2020-04-30 08:03:56 +02:00
const XString8 NullXString;
const XString16 NullXString16;
const XString32 NullXString32;
2020-04-23 15:20:48 +02:00
const XStringW NullXStringW;
2020-03-12 15:40:38 +01:00
//template<class O/*, enable_if(is_char(O))*/>
//XStringW LStringW::operator + (const O* p2) { XStringW s; s.strcat(this->s()); s.strcat(p2); return s; }
//
//template<>
//XStringW LStringW::operator + (const wchar_t* p2) { XStringW s; s.strcat(this->s()); s.strcat(p2); return s; }
2020-04-30 08:03:56 +02:00
XString8 SPrintf(const char* format, ...)
2020-03-12 15:40:38 +01:00
{
2020-04-23 15:20:48 +02:00
va_list va;
2020-04-30 08:03:56 +02:00
XString8 str;
2020-03-12 15:40:38 +01:00
2020-04-23 15:20:48 +02:00
va_start (va, format);
str.vSPrintf(format, va);
va_end(va);
2020-03-12 15:40:38 +01:00
2020-04-23 15:20:48 +02:00
return str;
2020-03-12 15:40:38 +01:00
}
2020-04-23 15:20:48 +02:00
XStringW SWPrintf(const char* format, ...)
2020-03-12 15:40:38 +01:00
{
2020-04-23 15:20:48 +02:00
va_list va;
XStringW str;
2020-03-12 15:40:38 +01:00
2020-04-23 15:20:48 +02:00
va_start (va, format);
str.vSWPrintf(format, va);
va_end(va);
2020-03-12 15:40:38 +01:00
2020-04-23 15:20:48 +02:00
return str;
2020-03-12 15:40:38 +01:00
}
2020-04-23 15:20:48 +02:00
//XStringW SubString(const wchar_t *S, UINTN pos, UINTN count)
2020-03-12 15:40:38 +01:00
//{
2020-04-23 15:20:48 +02:00
// if ( wcslen(S)-pos < count ) count = wcslen(S)-pos;
// XStringW ret;
// ret.StrnCpy(S+pos, count);
//// return ( XStringW(S+pos, count) );
// return ret;
2020-03-12 15:40:38 +01:00
//}
//