Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • alchemy/viewer
  • Miezhiko/alchemy-next
  • JennaHuntsman/xdg-integration
  • logue/alchemy-next
  • FelixWolf/alchemy-viewer
  • XenHat/xdg-integration
6 results
Show changes
Commits on Source (12)
Showing
with 185 additions and 237 deletions
......@@ -2058,7 +2058,7 @@ BOOL LLKeyframeMotion::serialize(LLDataPacker& dp) const
success &= dp.packU8(shared_constraintp->mChainLength, "chain_length");
success &= dp.packU8(shared_constraintp->mConstraintType, "constraint_type");
char source_volume[16]; /* Flawfinder: ignore */
snprintf(source_volume, sizeof(source_volume), "%s", /* Flawfinder: ignore */
absl::SNPrintF(source_volume, sizeof(source_volume), "%s", /* Flawfinder: ignore */
mCharacter->findCollisionVolume(shared_constraintp->mSourceConstraintVolume)->getName().c_str());
success &= dp.packBinaryDataFixed((U8*)source_volume, 16, "source_volume");
......@@ -2066,11 +2066,11 @@ BOOL LLKeyframeMotion::serialize(LLDataPacker& dp) const
char target_volume[16]; /* Flawfinder: ignore */
if (shared_constraintp->mConstraintTargetType == CONSTRAINT_TARGET_TYPE_GROUND)
{
snprintf(target_volume,sizeof(target_volume), "%s", "GROUND"); /* Flawfinder: ignore */
absl::SNPrintF(target_volume,sizeof(target_volume), "%s", "GROUND"); /* Flawfinder: ignore */
}
else
{
snprintf(target_volume, sizeof(target_volume),"%s", /* Flawfinder: ignore */
absl::SNPrintF(target_volume, sizeof(target_volume),"%s", /* Flawfinder: ignore */
mCharacter->findCollisionVolume(shared_constraintp->mTargetConstraintVolume)->getName().c_str());
}
success &= dp.packBinaryDataFixed((U8*)target_volume, 16, "target_volume");
......@@ -2383,8 +2383,6 @@ void LLKeyframeDataCache::dumpDiagInfo()
// keep track of totals
U32 total_size = 0;
char buf[1024]; /* Flawfinder: ignore */
LL_INFOS() << "-----------------------------------------------------" << LL_ENDL;
LL_INFOS() << " Global Motion Table (DEBUG only)" << LL_ENDL;
LL_INFOS() << "-----------------------------------------------------" << LL_ENDL;
......@@ -2406,8 +2404,7 @@ void LLKeyframeDataCache::dumpDiagInfo()
LL_INFOS() << "-----------------------------------------------------" << LL_ENDL;
LL_INFOS() << "Motions\tTotal Size" << LL_ENDL;
snprintf(buf, sizeof(buf), "%d\t\t%d bytes", (S32)sKeyframeDataMap.size(), total_size ); /* Flawfinder: ignore */
LL_INFOS() << buf << LL_ENDL;
LL_INFOS() << absl::StreamFormat("%d\t\t%d bytes", (S32)sKeyframeDataMap.size(), total_size) << LL_ENDL;
LL_INFOS() << "-----------------------------------------------------" << LL_ENDL;
}
......
......@@ -466,24 +466,24 @@ BOOL LLGestureStepWait::deserialize(LLDataPacker& dp)
std::vector<std::string> LLGestureStepWait::getLabel() const
{
std::vector<std::string> strings;
strings.push_back( "Wait" );
strings.emplace_back( "Wait" );
// std::string label("--- Wait: ");
if (mFlags & WAIT_FLAG_TIME)
{
char buffer[64]; /* Flawfinder: ignore */
snprintf(buffer, sizeof(buffer), "%.1f seconds", (double)mWaitSeconds); /* Flawfinder: ignore */
strings.push_back(buffer);
std::string str = absl::StrFormat("%.1f seconds", mWaitSeconds);
strings.push_back(std::move(str));
// label += buffer;
}
else if (mFlags & WAIT_FLAG_ALL_ANIM)
{
strings.push_back("until animations are done");
strings.emplace_back("until animations are done");
// label += "until animations are done";
}
else
{
strings.push_back("");
strings.emplace_back("");
}
return strings;
......
......@@ -232,7 +232,7 @@ namespace {
}
else
{
fprintf(stderr, "%s\n", message.c_str());
absl::FPrintF(stderr, "%s\n", message);
}
}
......@@ -245,7 +245,7 @@ namespace {
static std::string s_ansi_reset = createANSI("0"); // reset
// ANSI color code escape sequence, message, and reset in one fprintf call
// Default all message levels to bold so we can distinguish our own messages from those dumped by subprocesses and libraries.
fprintf(stderr, "%s%s%s\n%s", s_ansi_bold.c_str(), ansi_code.c_str(), message.c_str(), s_ansi_reset.c_str() );
absl::FPrintF(stderr, "%s%s%s\n%s", s_ansi_bold, ansi_code, message, s_ansi_reset);
}
static bool checkANSI(void)
......
......@@ -178,8 +178,7 @@ int LLFile::mkdir(const std::string& dirname, int perms)
{
#if LL_WINDOWS
// permissions are ignored on Windows
std::string utf8dirname = dirname;
std::wstring utf16dirname = ll_convert_string_to_wide(utf8dirname);
std::wstring utf16dirname = ll_convert_string_to_wide(dirname);
int rc = _wmkdir(utf16dirname.c_str());
#else
int rc = ::mkdir(dirname.c_str(), (mode_t)perms);
......@@ -201,8 +200,7 @@ int LLFile::rmdir(const std::string& dirname)
{
#if LL_WINDOWS
// permissions are ignored on Windows
std::string utf8dirname = dirname;
std::wstring utf16dirname = ll_convert_string_to_wide(utf8dirname);
std::wstring utf16dirname = ll_convert_string_to_wide(dirname);
int rc = _wrmdir(utf16dirname.c_str());
#else
int rc = ::rmdir(dirname.c_str());
......@@ -214,10 +212,8 @@ int LLFile::rmdir(const std::string& dirname)
LLFILE* LLFile::fopen(const std::string& filename, const char* mode) /* Flawfinder: ignore */
{
#if LL_WINDOWS
std::string utf8filename = filename;
std::string utf8mode = std::string(mode);
std::wstring utf16filename = ll_convert_string_to_wide(utf8filename);
std::wstring utf16mode = ll_convert_string_to_wide(utf8mode);
std::wstring utf16filename = ll_convert_string_to_wide(filename);
std::wstring utf16mode = ll_convert_string_to_wide(mode);
return _wfopen(utf16filename.c_str(),utf16mode.c_str());
#else
return ::fopen(filename.c_str(),mode); /* Flawfinder: ignore */
......@@ -227,10 +223,8 @@ LLFILE* LLFile::fopen(const std::string& filename, const char* mode) /* Flawfind
LLFILE* LLFile::_fsopen(const std::string& filename, const char* mode, int sharingFlag)
{
#if LL_WINDOWS
std::string utf8filename = filename;
std::string utf8mode = std::string(mode);
std::wstring utf16filename = ll_convert_string_to_wide(utf8filename);
std::wstring utf16mode = ll_convert_string_to_wide(utf8mode);
std::wstring utf16filename = ll_convert_string_to_wide(filename);
std::wstring utf16mode = ll_convert_string_to_wide(mode);
return _wfsopen(utf16filename.c_str(),utf16mode.c_str(),sharingFlag);
#else
llassert(0);//No corresponding function on non-windows
......@@ -252,8 +246,7 @@ int LLFile::close(LLFILE * file)
int LLFile::remove(const std::string& filename, int supress_error)
{
#if LL_WINDOWS
std::string utf8filename = filename;
std::wstring utf16filename = ll_convert_string_to_wide(utf8filename);
std::wstring utf16filename = ll_convert_string_to_wide(filename);
int rc = _wremove(utf16filename.c_str());
#else
int rc = ::remove(filename.c_str());
......@@ -264,10 +257,8 @@ int LLFile::remove(const std::string& filename, int supress_error)
int LLFile::rename(const std::string& filename, const std::string& newname, int supress_error)
{
#if LL_WINDOWS
std::string utf8filename = filename;
std::string utf8newname = newname;
std::wstring utf16filename = ll_convert_string_to_wide(utf8filename);
std::wstring utf16newname = ll_convert_string_to_wide(utf8newname);
std::wstring utf16filename = ll_convert_string_to_wide(filename);
std::wstring utf16newname = ll_convert_string_to_wide(newname);
int rc = _wrename(utf16filename.c_str(),utf16newname.c_str());
#else
int rc = ::rename(filename.c_str(),newname.c_str());
......@@ -309,8 +300,7 @@ bool LLFile::copy(const std::string& from, const std::string& to)
int LLFile::stat(const std::string& filename, llstat* filestatus)
{
#if LL_WINDOWS
std::string utf8filename = filename;
std::wstring utf16filename = ll_convert_string_to_wide(utf8filename);
std::wstring utf16filename = ll_convert_string_to_wide(filename);
int rc = _wstat(utf16filename.c_str(),filestatus);
#else
int rc = ::stat(filename.c_str(),filestatus);
......
......@@ -731,79 +731,60 @@ std::string utf8str_removeCRLF(const std::string& utf8str)
}
#if LL_WINDOWS
std::string ll_convert_wide_to_string(const wchar_t* in)
std::string ll_convert_wide_to_string(std::wstring_view in)
{
return ll_convert_wide_to_string(in, CP_UTF8);
}
std::string ll_convert_wide_to_string(const wchar_t* in, unsigned int code_page)
std::string ll_convert_wide_to_string(std::wstring_view in, unsigned int code_page)
{
std::string out;
if(in)
{
int len_in = wcslen(in);
int len_out = WideCharToMultiByte(
code_page,
0,
in,
len_in,
NULL,
0,
0,
0);
// We will need two more bytes for the double NULL ending
// created in WideCharToMultiByte().
char* pout = new char [len_out + 2];
memset(pout, 0, len_out + 2);
if(pout)
{
WideCharToMultiByte(
code_page,
0,
in,
len_in,
pout,
len_out,
0,
0);
out.assign(pout);
delete[] pout;
}
}
return out;
std::string out {};
if (in.length() > 0)
{
int len = WideCharToMultiByte(code_page, 0, in.data(), in.length(), NULL, 0, 0, 0);
if (len == 0)
{
return out;
}
out.resize(len);
WideCharToMultiByte(code_page, 0, in.data(), in.length(), out.data(), out.length(), 0, 0);
}
return out;
}
std::wstring ll_convert_string_to_wide(const std::string& in)
std::wstring ll_convert_string_to_wide(std::string_view in)
{
return ll_convert_string_to_wide(in, CP_UTF8);
}
std::wstring ll_convert_string_to_wide(const std::string& in, unsigned int code_page)
std::wstring ll_convert_string_to_wide(std::string_view in, unsigned int code_page)
{
// From review:
// We can preallocate a wide char buffer that is the same length (in wchar_t elements) as the utf8 input,
// plus one for a null terminator, and be guaranteed to not overflow.
std::wstring out{};
// Normally, I'd call that sort of thing premature optimization,
// but we *are* seeing string operations taking a bunch of time, especially when constructing widgets.
// int output_str_len = MultiByteToWideChar(code_page, 0, in.c_str(), in.length(), NULL, 0);
// reserve an output buffer that will be destroyed on exit, with a place
// to put NULL terminator
std::vector<wchar_t> w_out(in.length() + 1);
if (in.length() > 0)
{
// Calculate target buffer size (not including the zero terminator).
int len = MultiByteToWideChar(code_page, 0,
in.data(), in.size(), NULL, 0);
if (len == 0)
{
return out;
}
memset(&w_out[0], 0, w_out.size());
int real_output_str_len = MultiByteToWideChar(code_page, 0, in.c_str(), in.length(),
&w_out[0], w_out.size() - 1);
out.resize(len);
// No error checking. We already know, that the conversion will succeed.
MultiByteToWideChar(code_page, 0,
in.data(), in.size(), out.data(), out.size());
// Use out.data() in place of &out[0] for C++17
}
//looks like MultiByteToWideChar didn't add null terminator to converted string, see EXT-4858.
w_out[real_output_str_len] = 0;
return out;
// construct string<wchar_t> from our temporary output buffer
return {&w_out[0]};
}
LLWString ll_convert_wide_to_wstring(const std::wstring& in)
LLWString ll_convert_wide_to_wstring(std::wstring_view in)
{
// This function, like its converse, is a placeholder, encapsulating a
// guilty little hack: the only "official" way nat has found to convert
......@@ -815,16 +796,16 @@ LLWString ll_convert_wide_to_wstring(const std::wstring& in)
return { in.begin(), in.end() };
}
std::wstring ll_convert_wstring_to_wide(const LLWString& in)
std::wstring ll_convert_wstring_to_wide(LLWStringView in)
{
// See comments in ll_convert_wide_to_wstring()
return { in.begin(), in.end() };
}
std::string ll_convert_string_to_utf8_string(const std::string& in)
std::string ll_convert_string_to_utf8_string(std::string_view in)
{
auto w_mesg = ll_convert_string_to_wide(in, CP_ACP);
std::string out_utf8(ll_convert_wide_to_string(w_mesg.c_str(), CP_UTF8));
std::string out_utf8(ll_convert_wide_to_string(w_mesg, CP_UTF8));
return out_utf8;
}
......
......@@ -451,6 +451,7 @@ template<class T> std::string LLStringUtilBase<T>::sLocale;
typedef LLStringUtilBase<char> LLStringUtil;
typedef LLStringUtilBase<llwchar> LLWStringUtil;
typedef std::basic_string<llwchar> LLWString;
typedef std::basic_string_view<llwchar> LLWStringView;
//@ Use this where we want to disallow input in the form of "foo"
// This is used to catch places where english text is embedded in the code
......@@ -721,44 +722,36 @@ LL_COMMON_API std::string utf8str_removeCRLF(const std::string& utf8str);
*
* This replaces the unsafe W2A macro from ATL.
*/
LL_COMMON_API std::string ll_convert_wide_to_string(const wchar_t* in, unsigned int code_page);
LL_COMMON_API std::string ll_convert_wide_to_string(const wchar_t* in); // default CP_UTF8
inline std::string ll_convert_wide_to_string(const std::wstring& in, unsigned int code_page)
{
return ll_convert_wide_to_string(in.c_str(), code_page);
}
inline std::string ll_convert_wide_to_string(const std::wstring& in)
{
return ll_convert_wide_to_string(in.c_str());
}
LL_COMMON_API std::string ll_convert_wide_to_string(std::wstring_view in, unsigned int code_page);
LL_COMMON_API std::string ll_convert_wide_to_string(std::wstring_view in); // default CP_UTF8
ll_convert_alias(std::string, std::wstring, ll_convert_wide_to_string(in));
/**
* Converts a string to wide string.
*/
LL_COMMON_API std::wstring ll_convert_string_to_wide(const std::string& in,
unsigned int code_page);
LL_COMMON_API std::wstring ll_convert_string_to_wide(const std::string& in);
// default CP_UTF8
LL_COMMON_API std::wstring ll_convert_string_to_wide(std::string_view in,
unsigned int code_page);
// default CP_UTF8
LL_COMMON_API std::wstring ll_convert_string_to_wide(std::string_view in);
ll_convert_alias(std::wstring, std::string, ll_convert_string_to_wide(in));
/**
* Convert a Windows wide string to our LLWString
*/
LL_COMMON_API LLWString ll_convert_wide_to_wstring(const std::wstring& in);
LL_COMMON_API LLWString ll_convert_wide_to_wstring(std::wstring_view in);
ll_convert_alias(LLWString, std::wstring, ll_convert_wide_to_wstring(in));
/**
* Convert LLWString to Windows wide string
*/
LL_COMMON_API std::wstring ll_convert_wstring_to_wide(const LLWString& in);
LL_COMMON_API std::wstring ll_convert_wstring_to_wide(LLWStringView in);
ll_convert_alias(std::wstring, LLWString, ll_convert_wstring_to_wide(in));
/**
* Converts incoming string into utf8 string
*
*/
LL_COMMON_API std::string ll_convert_string_to_utf8_string(const std::string& in);
LL_COMMON_API std::string ll_convert_string_to_utf8_string(std::string_view in);
/// Get Windows message string for passed GetLastError() code
// VS 2013 doesn't let us forward-declare this template, which is what we
......
......@@ -434,7 +434,7 @@ LLUUID LLUUID::combine(const LLUUID &other) const
std::ostream& operator<<(std::ostream& s, const LLUUID &uuid)
{
std::string uuid_str;
char uuid_str[UUID_STR_SIZE];
uuid.toString(uuid_str);
s << uuid_str;
return s;
......
......@@ -65,4 +65,12 @@ namespace tut
auto str = absl::StrFormat("%s", TEST_ID);
ensure_equals(str, TEST_ID_STR);
}
template<> template<>
void uuid_object_t::test<4>()
{
char out_cstr[UUID_STR_SIZE] = {};
absl::SNPrintF(out_cstr, UUID_STR_SIZE, "%s", TEST_ID);
ensure_equals(out_cstr, TEST_ID_STR);
}
}
......@@ -66,15 +66,15 @@ std::string U64_to_str(U64 value)
if (part1)
{
res = llformat("%u%07u%07u",part1,part2,part3);
res = absl::StrFormat("%u%07u%07u",part1,part2,part3);
}
else if (part2)
{
res = llformat("%u%07u",part2,part3);
res = absl::StrFormat("%u%07u",part2,part3);
}
else
{
res = llformat("%u",part3);
res = absl::StrFormat("%u",part3);
}
return res;
}
......
......@@ -670,29 +670,24 @@ HttpStatus HttpOpRequest::prepareRequest(HttpService * service)
// There's a CURLOPT for this now...
if ((mReqOffset || mReqLength) && HOR_GET == mReqMethod)
{
static const char * const fmt1("Range: bytes=%lu-%lu");
static const char * const fmt2("Range: bytes=%lu-");
constexpr absl::string_view fmt1 = "Range: bytes=%lu-%lu";
constexpr absl::string_view fmt2 = "Range: bytes=%lu-";
char range_line[64];
#if LL_WINDOWS
_snprintf_s(range_line, sizeof(range_line), sizeof(range_line) - 1,
(mReqLength ? fmt1 : fmt2),
(unsigned long) mReqOffset, (unsigned long) (mReqOffset + mReqLength - 1));
#else
if ( mReqLength )
{
snprintf(range_line, sizeof(range_line),
absl::SNPrintF(range_line, sizeof(range_line),
fmt1,
(unsigned long) mReqOffset, (unsigned long) (mReqOffset + mReqLength - 1));
}
else
{
snprintf(range_line, sizeof(range_line),
absl::SNPrintF(range_line, sizeof(range_line),
fmt2,
(unsigned long) mReqOffset);
}
#endif // LL_WINDOWS
range_line[sizeof(range_line) - 1] = '\0';
mCurlHeaders = curl_slist_append(mCurlHeaders, range_line);
}
......
......@@ -455,11 +455,9 @@ bool WorkingSet::reload(LLCore::HttpRequest * hr, LLCore::HttpOptions::ptr_t & o
for (int i(0); i < to_do; ++i)
{
char buffer[1024];
#if defined(WIN32)
_snprintf_s(buffer, sizeof(buffer), sizeof(buffer) - 1, mUrl.c_str(), mAssets[mAt].mUuid.c_str());
#else
snprintf(buffer, sizeof(buffer), mUrl.c_str(), mAssets[mAt].mUuid.c_str());
#endif
absl::SNPrintF(buffer, sizeof(buffer), mUrl.c_str(), mAssets[mAt].mUuid.c_str());
int offset(mNoRange
? 0
: (mRandomRange ? ((unsigned long) rand()) % 1000000UL : mAssets[mAt].mOffset));
......
......@@ -2762,7 +2762,7 @@ void HttpRequestTestObjectType::test<22>()
for (int i(0); i < test_count; ++i)
{
char buffer[128];
snprintf(buffer, sizeof(buffer), "/bug2295/%d/", i);
absl::SNPrintF(buffer, sizeof(buffer), "/bug2295/%d/", i);
HttpHandle handle = req->requestGetByteRange(HttpRequest::DEFAULT_POLICY_ID,
0U,
url_base + buffer,
......@@ -2794,7 +2794,7 @@ void HttpRequestTestObjectType::test<22>()
for (int i(0); i < test2_count; ++i)
{
char buffer[128];
snprintf(buffer, sizeof(buffer), "/bug2295/00000012/%d/", i);
absl::SNPrintF(buffer, sizeof(buffer), "/bug2295/00000012/%d/", i);
HttpHandle handle = req->requestGetByteRange(HttpRequest::DEFAULT_POLICY_ID,
0U,
url_base + buffer,
......@@ -2826,7 +2826,7 @@ void HttpRequestTestObjectType::test<22>()
for (int i(0); i < test3_count; ++i)
{
char buffer[128];
snprintf(buffer, sizeof(buffer), "/bug2295/inv_cont_range/%d/", i);
absl::SNPrintF(buffer, sizeof(buffer), "/bug2295/inv_cont_range/%d/", i);
HttpHandle handle = req->requestGetByteRange(HttpRequest::DEFAULT_POLICY_ID,
0U,
url_base + buffer,
......
......@@ -229,14 +229,12 @@ BOOL LLInventoryObject::importLegacyStream(std::istream& input_stream)
BOOL LLInventoryObject::exportFile(LLFILE* fp, BOOL) const
{
std::string uuid_str;
fprintf(fp, "\tinv_object\t0\n\t{\n");
mUUID.toString(uuid_str);
fprintf(fp, "\t\tobj_id\t%s\n", uuid_str.c_str());
mParentUUID.toString(uuid_str);
fprintf(fp, "\t\tparent_id\t%s\n", uuid_str.c_str());
fprintf(fp, "\t\ttype\t%s\n", LLAssetType::lookup(mType));
fprintf(fp, "\t\tname\t%s|\n", mName.c_str());
fprintf(fp,"\t}\n");
absl::FPrintF(fp, "\tinv_object\t0\n\t{\n");
absl::FPrintF(fp, "\t\tobj_id\t%s\n", mUUID);
absl::FPrintF(fp, "\t\tparent_id\t%s\n", mParentUUID);
absl::FPrintF(fp, "\t\ttype\t%s\n", LLAssetType::lookup(mType));
absl::FPrintF(fp, "\t\tname\t%s|\n", mName);
absl::FPrintF(fp,"\t}\n");
return TRUE;
}
......@@ -759,12 +757,9 @@ BOOL LLInventoryItem::importFile(LLFILE* fp)
BOOL LLInventoryItem::exportFile(LLFILE* fp, BOOL include_asset_key) const
{
std::string uuid_str;
fprintf(fp, "\tinv_item\t0\n\t{\n");
mUUID.toString(uuid_str);
fprintf(fp, "\t\titem_id\t%s\n", uuid_str.c_str());
mParentUUID.toString(uuid_str);
fprintf(fp, "\t\tparent_id\t%s\n", uuid_str.c_str());
absl::FPrintF(fp, "\tinv_item\t0\n\t{\n");
absl::FPrintF(fp, "\t\titem_id\t%s\n", mUUID);
absl::FPrintF(fp, "\t\tparent_id\t%s\n", mParentUUID);
mPermissions.exportFile(fp);
// Check for permissions to see the asset id, and if so write it
......@@ -775,32 +770,29 @@ BOOL LLInventoryItem::exportFile(LLFILE* fp, BOOL include_asset_key) const
if(((mask & PERM_ITEM_UNRESTRICTED) == PERM_ITEM_UNRESTRICTED)
|| (mAssetUUID.isNull()))
{
mAssetUUID.toString(uuid_str);
fprintf(fp, "\t\tasset_id\t%s\n", uuid_str.c_str());
absl::FPrintF(fp, "\t\tasset_id\t%s\n", mAssetUUID);
}
else
{
LLUUID shadow_id(mAssetUUID);
LLXORCipher cipher(MAGIC_ID.mData, UUID_BYTES);
cipher.encrypt(shadow_id.mData, UUID_BYTES);
shadow_id.toString(uuid_str);
fprintf(fp, "\t\tshadow_id\t%s\n", uuid_str.c_str());
absl::FPrintF(fp, "\t\tshadow_id\t%s\n", shadow_id);
}
}
else
{
LLUUID::null.toString(uuid_str);
fprintf(fp, "\t\tasset_id\t%s\n", uuid_str.c_str());
absl::FPrintF(fp, "\t\tasset_id\t%s\n", LLUUID::null);
}
fprintf(fp, "\t\ttype\t%s\n", LLAssetType::lookup(mType));
absl::FPrintF(fp, "\t\ttype\t%s\n", LLAssetType::lookup(mType));
const std::string inv_type_str = LLInventoryType::lookup(mInventoryType);
if(!inv_type_str.empty()) fprintf(fp, "\t\tinv_type\t%s\n", inv_type_str.c_str());
fprintf(fp, "\t\tflags\t%08x\n", mFlags);
if(!inv_type_str.empty()) absl::FPrintF(fp, "\t\tinv_type\t%s\n", inv_type_str);
absl::FPrintF(fp, "\t\tflags\t%08x\n", mFlags);
mSaleInfo.exportFile(fp);
fprintf(fp, "\t\tname\t%s|\n", mName.c_str());
fprintf(fp, "\t\tdesc\t%s|\n", mDescription.c_str());
fprintf(fp, "\t\tcreation_date\t%d\n", (S32) mCreationDate);
fprintf(fp,"\t}\n");
absl::FPrintF(fp, "\t\tname\t%s|\n", mName);
absl::FPrintF(fp, "\t\tdesc\t%s|\n", mDescription);
absl::FPrintF(fp, "\t\tcreation_date\t%d\n", (S32) mCreationDate);
absl::FPrintF(fp,"\t}\n");
return TRUE;
}
......@@ -1004,9 +996,8 @@ BOOL LLInventoryItem::exportLegacyStream(std::ostream& output_stream, BOOL inclu
const std::string inv_type_str = LLInventoryType::lookup(mInventoryType);
if(!inv_type_str.empty())
output_stream << "\t\tinv_type\t" << inv_type_str << "\n";
std::string buffer;
buffer = llformat( "\t\tflags\t%08x\n", mFlags);
output_stream << buffer;
output_stream << absl::StreamFormat("\t\tflags\t%08x\n", mFlags);
mSaleInfo.exportLegacyStream(output_stream);
output_stream << "\t\tname\t" << mName.c_str() << "|\n";
output_stream << "\t\tdesc\t" << mDescription.c_str() << "|\n";
......@@ -1521,16 +1512,13 @@ BOOL LLInventoryCategory::importFile(LLFILE* fp)
BOOL LLInventoryCategory::exportFile(LLFILE* fp, BOOL) const
{
std::string uuid_str;
fprintf(fp, "\tinv_category\t0\n\t{\n");
mUUID.toString(uuid_str);
fprintf(fp, "\t\tcat_id\t%s\n", uuid_str.c_str());
mParentUUID.toString(uuid_str);
fprintf(fp, "\t\tparent_id\t%s\n", uuid_str.c_str());
fprintf(fp, "\t\ttype\t%s\n", LLAssetType::lookup(mType));
fprintf(fp, "\t\tpref_type\t%s\n", LLFolderType::lookup(mPreferredType).c_str());
fprintf(fp, "\t\tname\t%s|\n", mName.c_str());
fprintf(fp,"\t}\n");
absl::FPrintF(fp, "\tinv_category\t0\n\t{\n");
absl::FPrintF(fp, "\t\tcat_id\t%s\n", mUUID);
absl::FPrintF(fp, "\t\tparent_id\t%s\n", mParentUUID);
absl::FPrintF(fp, "\t\ttype\t%s\n", LLAssetType::lookup(mType));
absl::FPrintF(fp, "\t\tpref_type\t%s\n", LLFolderType::lookup(mPreferredType).c_str());
absl::FPrintF(fp, "\t\tname\t%s|\n", mName.c_str());
absl::FPrintF(fp,"\t}\n");
return TRUE;
}
......
......@@ -675,34 +675,25 @@ BOOL LLPermissions::importFile(LLFILE* fp)
BOOL LLPermissions::exportFile(LLFILE* fp) const
{
std::string uuid_str;
fprintf(fp, "\tpermissions 0\n");
fprintf(fp, "\t{\n");
absl::FPrintF(fp, "\tpermissions 0\n");
absl::FPrintF(fp, "\t{\n");
fprintf(fp, "\t\tbase_mask\t%08x\n", mMaskBase);
fprintf(fp, "\t\towner_mask\t%08x\n", mMaskOwner);
fprintf(fp, "\t\tgroup_mask\t%08x\n", mMaskGroup);
fprintf(fp, "\t\teveryone_mask\t%08x\n", mMaskEveryone);
fprintf(fp, "\t\tnext_owner_mask\t%08x\n", mMaskNextOwner);
absl::FPrintF(fp, "\t\tbase_mask\t%08x\n", mMaskBase);
absl::FPrintF(fp, "\t\towner_mask\t%08x\n", mMaskOwner);
absl::FPrintF(fp, "\t\tgroup_mask\t%08x\n", mMaskGroup);
absl::FPrintF(fp, "\t\teveryone_mask\t%08x\n", mMaskEveryone);
absl::FPrintF(fp, "\t\tnext_owner_mask\t%08x\n", mMaskNextOwner);
mCreator.toString(uuid_str);
fprintf(fp, "\t\tcreator_id\t%s\n", uuid_str.c_str());
mOwner.toString(uuid_str);
fprintf(fp, "\t\towner_id\t%s\n", uuid_str.c_str());
mLastOwner.toString(uuid_str);
fprintf(fp, "\t\tlast_owner_id\t%s\n", uuid_str.c_str());
mGroup.toString(uuid_str);
fprintf(fp, "\t\tgroup_id\t%s\n", uuid_str.c_str());
absl::FPrintF(fp, "\t\tcreator_id\t%s\n", mCreator);
absl::FPrintF(fp, "\t\towner_id\t%s\n", mOwner);
absl::FPrintF(fp, "\t\tlast_owner_id\t%s\n", mLastOwner);
absl::FPrintF(fp, "\t\tgroup_id\t%s\n", mGroup);
if(mIsGroupOwned)
{
fprintf(fp, "\t\tgroup_owned\t1\n");
absl::FPrintF(fp, "\t\tgroup_owned\t1\n");
}
fprintf(fp,"\t}\n");
absl::FPrintF(fp,"\t}\n");
return TRUE;
}
......@@ -814,17 +805,11 @@ BOOL LLPermissions::exportLegacyStream(std::ostream& output_stream) const
output_stream << "\tpermissions 0\n";
output_stream << "\t{\n";
std::string buffer;
buffer = llformat( "\t\tbase_mask\t%08x\n", mMaskBase);
output_stream << buffer;
buffer = llformat( "\t\towner_mask\t%08x\n", mMaskOwner);
output_stream << buffer;
buffer = llformat( "\t\tgroup_mask\t%08x\n", mMaskGroup);
output_stream << buffer;
buffer = llformat( "\t\teveryone_mask\t%08x\n", mMaskEveryone);
output_stream << buffer;
buffer = llformat( "\t\tnext_owner_mask\t%08x\n", mMaskNextOwner);
output_stream << buffer;
output_stream << absl::StreamFormat("\t\tbase_mask\t%08x\n", mMaskBase);
output_stream << absl::StreamFormat("\t\towner_mask\t%08x\n", mMaskOwner);
output_stream << absl::StreamFormat("\t\tgroup_mask\t%08x\n", mMaskGroup);
output_stream << absl::StreamFormat("\t\teveryone_mask\t%08x\n", mMaskEveryone);
output_stream << absl::StreamFormat("\t\tnext_owner_mask\t%08x\n", mMaskNextOwner);
mCreator.toString(uuid_str);
output_stream << "\t\tcreator_id\t" << uuid_str << "\n";
......
......@@ -81,10 +81,10 @@ U32 LLSaleInfo::getCRC32() const
BOOL LLSaleInfo::exportFile(LLFILE* fp) const
{
fprintf(fp, "\tsale_info\t0\n\t{\n");
fprintf(fp, "\t\tsale_type\t%s\n", lookup(mSaleType));
fprintf(fp, "\t\tsale_price\t%d\n", mSalePrice);
fprintf(fp,"\t}\n");
absl::FPrintF(fp, "\tsale_info\t0\n\t{\n");
absl::FPrintF(fp, "\t\tsale_type\t%s\n", lookup(mSaleType));
absl::FPrintF(fp, "\t\tsale_price\t%d\n", mSalePrice);
absl::FPrintF(fp,"\t}\n");
return TRUE;
}
......
......@@ -82,7 +82,7 @@ LLSettingsBase::LLSettingsBase(const LLSD setting) :
}
//=========================================================================
void LLSettingsBase::lerpSettings(const LLSettingsBase &other, F64 mix)
void LLSettingsBase::lerpSettings(const LLSettingsBase &other, BlendFactor mix)
{
mSettings = interpolateSDMap(mSettings, other.mSettings, other.getParameterMap(), mix);
setDirtyFlag(true);
......@@ -162,12 +162,12 @@ LLSD LLSettingsBase::combineSDMaps(const LLSD &settings, const LLSD &other) cons
return newSettings;
}
LLSD LLSettingsBase::interpolateSDMap(const LLSD &settings, const LLSD &other, const parammapping_t& defaults, F64 mix) const
LLSD LLSettingsBase::interpolateSDMap(const LLSD &settings, const LLSD &other, const parammapping_t& defaults, BlendFactor mix) const
{
LLSD newSettings;
stringset_t skip = getSkipInterpolateKeys();
stringset_t slerps = getSlerpKeys();
const stringset_t& skip = getSkipInterpolateKeys();
const stringset_t& slerps = getSlerpKeys();
llassert(mix >= 0.0f && mix <= 1.0f);
......@@ -336,7 +336,7 @@ LLSD LLSettingsBase::interpolateSDValue(const std::string& key_name, const LLSD
return new_value;
}
LLSettingsBase::stringset_t LLSettingsBase::getSkipInterpolateKeys() const
const LLSettingsBase::stringset_t& LLSettingsBase::getSkipInterpolateKeys() const
{
static stringset_t skipSet;
......@@ -349,6 +349,18 @@ LLSettingsBase::stringset_t LLSettingsBase::getSkipInterpolateKeys() const
return skipSet;
}
const LLSettingsBase::stringset_t& LLSettingsBase::getSlerpKeys() const
{
static stringset_t slerpKeys;
return slerpKeys;
}
const LLSettingsBase::parammapping_t& LLSettingsBase::getParameterMap() const
{
static parammapping_t paramMap;
return paramMap;
}
LLSD LLSettingsBase::getSettings() const
{
return mSettings;
......@@ -374,7 +386,7 @@ size_t LLSettingsBase::getHash() const
bool LLSettingsBase::validate()
{
validation_list_t validations = getValidationList();
const validation_list_t& validations = getValidationList();
if (!mSettings.has(SETTING_TYPE))
{
......@@ -395,7 +407,7 @@ bool LLSettingsBase::validate()
return result["success"].asBoolean();
}
LLSD LLSettingsBase::settingValidation(LLSD &settings, validation_list_t &validations, bool partial)
LLSD LLSettingsBase::settingValidation(LLSD &settings, const validation_list_t &validations, bool partial)
{
static Validator validateName(SETTING_NAME, false, LLSD::TypeString, boost::bind(&Validator::verifyStringLength, boost::placeholders::_1, 63));
static Validator validateId(SETTING_ID, false, LLSD::TypeUUID);
......@@ -513,7 +525,7 @@ LLSD LLSettingsBase::settingValidation(LLSD &settings, validation_list_t &valida
//=========================================================================
bool LLSettingsBase::Validator::verify(LLSD &data, U32 flags)
bool LLSettingsBase::Validator::verify(LLSD &data, U32 flags) const
{
if (!data.has(mName) || (data.has(mName) && data[mName].isUndefined()))
{
......
......@@ -33,6 +33,9 @@
#include <vector>
#include <boost/signals2.hpp>
#include "absl/container/flat_hash_set.h"
#include "absl/container/flat_hash_map.h"
#include "llsd.h"
#include "llsdutil.h"
#include "v2math.h"
......@@ -92,7 +95,7 @@ class LLSettingsBase :
};
// Contains settings' names (map key), related shader id-key and default
// value for revert in case we need to reset shader (no need to search each time)
typedef std::map<std::string, DefaultParam> parammapping_t;
typedef absl::flat_hash_map<std::string, DefaultParam> parammapping_t;
typedef PTR_NAMESPACE::shared_ptr<LLSettingsBase> ptr_t;
......@@ -284,7 +287,7 @@ class LLSettingsBase :
bool isRequired() const { return mRequired; }
LLSD::Type getType() const { return mType; }
bool verify(LLSD &data, U32 flags);
bool verify(LLSD &data, U32 flags) const;
// Some basic verifications
static bool verifyColor(LLSD &value);
......@@ -306,7 +309,7 @@ class LLSettingsBase :
};
typedef std::vector<Validator> validation_list_t;
static LLSD settingValidation(LLSD &settings, validation_list_t &validations, bool partial = false);
static LLSD settingValidation(LLSD &settings, const validation_list_t &validations, bool partial = false);
inline void setAssetId(LLUUID value)
{ // note that this skips setLLSD
......@@ -326,9 +329,7 @@ class LLSettingsBase :
LLSettingsBase();
LLSettingsBase(const LLSD setting);
static LLSD settingValidation(LLSD settings);
typedef std::set<std::string> stringset_t;
typedef absl::flat_hash_set<std::string> stringset_t;
// combining settings objects. Customize for specific setting types
virtual void lerpSettings(const LLSettingsBase &other, BlendFactor mix);
......@@ -345,18 +346,18 @@ class LLSettingsBase :
/// when lerping between settings, some may require special handling.
/// Get a list of these key to be skipped by the default settings lerp.
/// (handling should be performed in the override of lerpSettings.
virtual stringset_t getSkipInterpolateKeys() const;
virtual const stringset_t& getSkipInterpolateKeys() const;
// A list of settings that represent quaternions and should be slerped
// rather than lerped.
virtual stringset_t getSlerpKeys() const { return stringset_t(); }
virtual const stringset_t& getSlerpKeys() const;
virtual validation_list_t getValidationList() const = 0;
virtual const validation_list_t& getValidationList() const = 0;
// Apply any settings that need special handling.
virtual void applySpecial(void *, bool force = false) { };
virtual parammapping_t getParameterMap() const { return parammapping_t(); }
virtual const parammapping_t& getParameterMap() const;
LLSD mSettings;
bool mIsValid;
......
......@@ -543,7 +543,7 @@ namespace
std::string ftype = frame[LLSettingsBase::SETTING_TYPE];
if (ftype == "sky")
{
LLSettingsSky::validation_list_t valid_sky = LLSettingsSky::validationList();
const LLSettingsSky::validation_list_t& valid_sky = LLSettingsSky::validationList();
LLSD res_sky = LLSettingsBase::settingValidation(frame, valid_sky);
if (res_sky["success"].asInteger() == 0)
......@@ -556,7 +556,7 @@ namespace
}
else if (ftype == "water")
{
LLSettingsWater::validation_list_t valid_h2o = LLSettingsWater::validationList();
const LLSettingsWater::validation_list_t& valid_h2o = LLSettingsWater::validationList();
LLSD res_h2o = LLSettingsBase::settingValidation(frame, valid_h2o);
if (res_h2o["success"].asInteger() == 0)
{
......@@ -589,12 +589,12 @@ namespace
}
}
LLSettingsDay::validation_list_t LLSettingsDay::getValidationList() const
const LLSettingsDay::validation_list_t& LLSettingsDay::getValidationList() const
{
return LLSettingsDay::validationList();
}
LLSettingsDay::validation_list_t LLSettingsDay::validationList()
const LLSettingsDay::validation_list_t& LLSettingsDay::validationList()
{
static validation_list_t validation;
......
......@@ -124,8 +124,8 @@ class LLSettingsDay : public LLSettingsBase
bool replaceCycleTrack(S32 track, const CycleTrack_t &source);
bool isTrackEmpty(S32 track) const;
virtual validation_list_t getValidationList() const SETTINGS_OVERRIDE;
static validation_list_t validationList();
virtual const validation_list_t& getValidationList() const SETTINGS_OVERRIDE;
static const validation_list_t& validationList();
virtual LLSettingsBase::ptr_t buildDerivedClone() const SETTINGS_OVERRIDE { return buildClone(); }
......
......@@ -508,7 +508,7 @@ void LLSettingsSky::blend(const LLSettingsBase::ptr_t &end, F64 blendf)
setBlendFactor(blendf);
}
LLSettingsSky::stringset_t LLSettingsSky::getSkipInterpolateKeys() const
const LLSettingsSky::stringset_t& LLSettingsSky::getSkipInterpolateKeys() const
{
static stringset_t skipSet;
......@@ -524,7 +524,7 @@ LLSettingsSky::stringset_t LLSettingsSky::getSkipInterpolateKeys() const
return skipSet;
}
LLSettingsSky::stringset_t LLSettingsSky::getSlerpKeys() const
const LLSettingsSky::stringset_t& LLSettingsSky::getSlerpKeys() const
{
static stringset_t slepSet;
......@@ -537,12 +537,12 @@ LLSettingsSky::stringset_t LLSettingsSky::getSlerpKeys() const
return slepSet;
}
LLSettingsSky::validation_list_t LLSettingsSky::getValidationList() const
const LLSettingsSky::validation_list_t& LLSettingsSky::getValidationList() const
{
return LLSettingsSky::validationList();
}
LLSettingsSky::validation_list_t LLSettingsSky::validationList()
const LLSettingsSky::validation_list_t& LLSettingsSky::validationList()
{
static validation_list_t validation;
......