Shuffled LL_COMMON_API around in spots to match v2
Added llformat_to_utf8 Added LLProcessLauncher::getExecutable() LLStringTableEntry() ctor and dtor definitions moved from .h to .cpp (should be safe)
This commit is contained in:
@@ -46,4 +46,18 @@
|
|||||||
*/
|
*/
|
||||||
typedef boost::tokenizer<boost::char_separator<char> > boost_tokenizer;
|
typedef boost::tokenizer<boost::char_separator<char> > boost_tokenizer;
|
||||||
|
|
||||||
|
// Useful combiner for boost signals that return a bool (e.g. validation)
|
||||||
|
// returns false if any of the callbacks return false
|
||||||
|
struct boost_boolean_combiner
|
||||||
|
{
|
||||||
|
typedef bool result_type;
|
||||||
|
template<typename InputIterator>
|
||||||
|
bool operator()(InputIterator first, InputIterator last) const
|
||||||
|
{
|
||||||
|
bool res = true;
|
||||||
|
while (first != last)
|
||||||
|
res &= *first++;
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
};
|
||||||
#endif // LL_LLBOOST_H
|
#endif // LL_LLBOOST_H
|
||||||
|
|||||||
@@ -179,7 +179,7 @@ namespace LLError
|
|||||||
{ return s; }
|
{ return s; }
|
||||||
// used to indicate the end of a message
|
// used to indicate the end of a message
|
||||||
|
|
||||||
class NoClassInfo { };
|
class LL_COMMON_API NoClassInfo { };
|
||||||
// used to indicate no class info known for logging
|
// used to indicate no class info known for logging
|
||||||
|
|
||||||
//LLCallStacks keeps track of call stacks and output the call stacks to log file
|
//LLCallStacks keeps track of call stacks and output the call stacks to log file
|
||||||
|
|||||||
@@ -34,7 +34,7 @@
|
|||||||
#ifndef LL_LLERRORLEGACY_H
|
#ifndef LL_LLERRORLEGACY_H
|
||||||
#define LL_LLERRORLEGACY_H
|
#define LL_LLERRORLEGACY_H
|
||||||
|
|
||||||
|
#include "llpreprocessor.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
LEGACY -- DO NOT USE THIS STUFF ANYMORE
|
LEGACY -- DO NOT USE THIS STUFF ANYMORE
|
||||||
|
|||||||
@@ -233,7 +233,7 @@ public:
|
|||||||
* and should only be used for config files and the like -- not in a
|
* and should only be used for config files and the like -- not in a
|
||||||
* loop.
|
* loop.
|
||||||
*/
|
*/
|
||||||
std::streamsize llifstream_size(llifstream& fstr);
|
std::streamsize LL_COMMON_API llifstream_size(llifstream& fstr);
|
||||||
std::streamsize llofstream_size(llofstream& fstr);
|
std::streamsize LL_COMMON_API llofstream_size(llofstream& fstr);
|
||||||
|
|
||||||
#endif // not LL_LLFILE_H
|
#endif // not LL_LLFILE_H
|
||||||
|
|||||||
@@ -37,17 +37,41 @@
|
|||||||
|
|
||||||
#include <cstdarg>
|
#include <cstdarg>
|
||||||
|
|
||||||
std::string llformat(const char *fmt, ...)
|
// common used function with va_list argument
|
||||||
|
// wrapper for vsnprintf to be called from llformatXXX functions.
|
||||||
|
static void va_format(std::string& out, const char *fmt, va_list va)
|
||||||
{
|
{
|
||||||
char tstr[1024]; /* Flawfinder: ignore */
|
char tstr[1024]; /* Flawfinder: ignore */
|
||||||
va_list va;
|
|
||||||
va_start(va, fmt);
|
|
||||||
#if LL_WINDOWS
|
#if LL_WINDOWS
|
||||||
_vsnprintf(tstr, 1024, fmt, va);
|
_vsnprintf(tstr, 1024, fmt, va);
|
||||||
#else
|
#else
|
||||||
vsnprintf(tstr, 1024, fmt, va); /* Flawfinder: ignore */
|
vsnprintf(tstr, 1024, fmt, va); /* Flawfinder: ignore */
|
||||||
#endif
|
#endif
|
||||||
va_end(va);
|
out.assign(tstr);
|
||||||
tstr[1023] = '\0';
|
|
||||||
return std::string(tstr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string llformat(const char *fmt, ...)
|
||||||
|
{
|
||||||
|
std::string res;
|
||||||
|
va_list va;
|
||||||
|
va_start(va, fmt);
|
||||||
|
va_format(res, fmt, va);
|
||||||
|
va_end(va);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string llformat_to_utf8(const char *fmt, ...)
|
||||||
|
{
|
||||||
|
std::string res;
|
||||||
|
va_list va;
|
||||||
|
va_start(va, fmt);
|
||||||
|
va_format(res, fmt, va);
|
||||||
|
va_end(va);
|
||||||
|
|
||||||
|
#if LL_WINDOWS
|
||||||
|
// made converting to utf8. See EXT-8318.
|
||||||
|
res = ll_convert_string_to_utf8_string(res);
|
||||||
|
#endif
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -40,6 +40,9 @@
|
|||||||
// *NOTE: buffer limited to 1024, (but vsnprintf prevents overrun)
|
// *NOTE: buffer limited to 1024, (but vsnprintf prevents overrun)
|
||||||
// should perhaps be replaced with boost::format.
|
// should perhaps be replaced with boost::format.
|
||||||
|
|
||||||
LL_COMMON_API std::string llformat(const char *fmt, ...);
|
std::string LL_COMMON_API llformat(const char *fmt, ...);
|
||||||
|
|
||||||
|
// the same version as above but ensures that returned string is in utf8 on windows
|
||||||
|
// to enable correct converting utf8_to_wstring.
|
||||||
|
std::string LL_COMMON_API llformat_to_utf8(const char *fmt, ...);
|
||||||
#endif // LL_LLFORMAT_H
|
#endif // LL_LLFORMAT_H
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ documentation and/or software.
|
|||||||
#include "llmd5.h"
|
#include "llmd5.h"
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <iostream>
|
#include <iostream> // cerr
|
||||||
|
|
||||||
// how many bytes to grab at a time when checking files
|
// how many bytes to grab at a time when checking files
|
||||||
const int LLMD5::BLOCK_LEN = 4096;
|
const int LLMD5::BLOCK_LEN = 4096;
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ void LLMetricsImpl::recordEventDetails(const std::string& location,
|
|||||||
metrics["location"] = location;
|
metrics["location"] = location;
|
||||||
metrics["stats"] = stats;
|
metrics["stats"] = stats;
|
||||||
|
|
||||||
llinfos << "LLMETRICS: " << LLSDNotationStreamer(metrics) << llendl;
|
llinfos << "LLMETRICS: " << (LLSDNotationStreamer(metrics)) << llendl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Store this:
|
// Store this:
|
||||||
|
|||||||
@@ -64,6 +64,11 @@ void LLProcessLauncher::setWorkingDirectory(const std::string &dir)
|
|||||||
mWorkingDir = dir;
|
mWorkingDir = dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const std::string& LLProcessLauncher::getExecutable() const
|
||||||
|
{
|
||||||
|
return mExecutable;
|
||||||
|
}
|
||||||
|
|
||||||
void LLProcessLauncher::clearArguments()
|
void LLProcessLauncher::clearArguments()
|
||||||
{
|
{
|
||||||
mLaunchArguments.clear();
|
mLaunchArguments.clear();
|
||||||
|
|||||||
@@ -53,6 +53,8 @@ public:
|
|||||||
void setExecutable(const std::string &executable);
|
void setExecutable(const std::string &executable);
|
||||||
void setWorkingDirectory(const std::string &dir);
|
void setWorkingDirectory(const std::string &dir);
|
||||||
|
|
||||||
|
const std::string& getExecutable() const;
|
||||||
|
|
||||||
void clearArguments();
|
void clearArguments();
|
||||||
void addArgument(const std::string &arg);
|
void addArgument(const std::string &arg);
|
||||||
void addArgument(const char *arg);
|
void addArgument(const char *arg);
|
||||||
|
|||||||
@@ -65,32 +65,32 @@
|
|||||||
/**
|
/**
|
||||||
*@brief Generate a float from [0, RAND_MAX).
|
*@brief Generate a float from [0, RAND_MAX).
|
||||||
*/
|
*/
|
||||||
LL_COMMON_API S32 ll_rand();
|
S32 LL_COMMON_API ll_rand();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*@brief Generate a float from [0, val) or (val, 0].
|
*@brief Generate a float from [0, val) or (val, 0].
|
||||||
*/
|
*/
|
||||||
LL_COMMON_API S32 ll_rand(S32 val);
|
S32 LL_COMMON_API ll_rand(S32 val);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*@brief Generate a float from [0, 1.0).
|
*@brief Generate a float from [0, 1.0).
|
||||||
*/
|
*/
|
||||||
LL_COMMON_API F32 ll_frand();
|
F32 LL_COMMON_API ll_frand();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*@brief Generate a float from [0, val) or (val, 0].
|
*@brief Generate a float from [0, val) or (val, 0].
|
||||||
*/
|
*/
|
||||||
LL_COMMON_API F32 ll_frand(F32 val);
|
F32 LL_COMMON_API ll_frand(F32 val);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*@brief Generate a double from [0, 1.0).
|
*@brief Generate a double from [0, 1.0).
|
||||||
*/
|
*/
|
||||||
LL_COMMON_API F64 ll_drand();
|
F64 LL_COMMON_API ll_drand();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*@brief Generate a double from [0, val) or (val, 0].
|
*@brief Generate a double from [0, val) or (val, 0].
|
||||||
*/
|
*/
|
||||||
LL_COMMON_API F64 ll_drand(F64 val);
|
F64 LL_COMMON_API ll_drand(F64 val);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief typedefs for good boost lagged fibonacci.
|
* @brief typedefs for good boost lagged fibonacci.
|
||||||
|
|||||||
@@ -436,7 +436,7 @@ void get_keyword_and_value(std::string& keyword,
|
|||||||
while (line_index < line_size)
|
while (line_index < line_size)
|
||||||
{
|
{
|
||||||
c = line[line_index];
|
c = line[line_index];
|
||||||
if (!isspace(c))
|
if (!LLStringOps::isSpace(c))
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -448,7 +448,7 @@ void get_keyword_and_value(std::string& keyword,
|
|||||||
while (line_index < line_size)
|
while (line_index < line_size)
|
||||||
{
|
{
|
||||||
c = line[line_index];
|
c = line[line_index];
|
||||||
if (isspace(c) || '\r' == c || '\n' == c)
|
if (LLStringOps::isSpace(c) || '\r' == c || '\n' == c)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,6 +38,23 @@
|
|||||||
|
|
||||||
LLStringTable gStringTable(32768);
|
LLStringTable gStringTable(32768);
|
||||||
|
|
||||||
|
LLStringTableEntry::LLStringTableEntry(const char *str)
|
||||||
|
: mString(NULL), mCount(1)
|
||||||
|
{
|
||||||
|
// Copy string
|
||||||
|
U32 length = (U32)strlen(str) + 1; /*Flawfinder: ignore*/
|
||||||
|
length = llmin(length, MAX_STRINGS_LENGTH);
|
||||||
|
mString = new char[length];
|
||||||
|
strncpy(mString, str, length); /*Flawfinder: ignore*/
|
||||||
|
mString[length - 1] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
LLStringTableEntry::~LLStringTableEntry()
|
||||||
|
{
|
||||||
|
delete [] mString;
|
||||||
|
mCount = 0;
|
||||||
|
}
|
||||||
|
|
||||||
LLStringTable::LLStringTable(int tablesize)
|
LLStringTable::LLStringTable(int tablesize)
|
||||||
: mUniqueEntries(0)
|
: mUniqueEntries(0)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -49,11 +49,11 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if STRING_TABLE_HASH_MAP
|
#if STRING_TABLE_HASH_MAP
|
||||||
#if LL_WINDOWS
|
# if LL_WINDOWS
|
||||||
#include <hash_map>
|
# include <hash_map>
|
||||||
#else
|
# else
|
||||||
#include <ext/hash_map>
|
# include <ext/hash_map>
|
||||||
#endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const U32 MAX_STRINGS_LENGTH = 256;
|
const U32 MAX_STRINGS_LENGTH = 256;
|
||||||
@@ -61,21 +61,9 @@ const U32 MAX_STRINGS_LENGTH = 256;
|
|||||||
class LL_COMMON_API LLStringTableEntry
|
class LL_COMMON_API LLStringTableEntry
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
LLStringTableEntry(const char *str)
|
LLStringTableEntry(const char *str);
|
||||||
: mString(NULL), mCount(1)
|
~LLStringTableEntry();
|
||||||
{
|
|
||||||
// Copy string
|
|
||||||
U32 length = (U32)strlen(str) + 1; /*Flawfinder: ignore*/
|
|
||||||
length = llmin(length, MAX_STRINGS_LENGTH);
|
|
||||||
mString = new char[length];
|
|
||||||
strncpy(mString, str, length); /*Flawfinder: ignore*/
|
|
||||||
mString[length - 1] = 0;
|
|
||||||
}
|
|
||||||
~LLStringTableEntry()
|
|
||||||
{
|
|
||||||
delete [] mString;
|
|
||||||
mCount = 0;
|
|
||||||
}
|
|
||||||
void incCount() { mCount++; }
|
void incCount() { mCount++; }
|
||||||
BOOL decCount() { return --mCount; }
|
BOOL decCount() { return --mCount; }
|
||||||
|
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ extern int errno;
|
|||||||
|
|
||||||
|
|
||||||
static const S32 CPUINFO_BUFFER_SIZE = 16383;
|
static const S32 CPUINFO_BUFFER_SIZE = 16383;
|
||||||
LL_COMMON_API LLCPUInfo gSysCPU;
|
LLCPUInfo gSysCPU;
|
||||||
|
|
||||||
#if LL_WINDOWS
|
#if LL_WINDOWS
|
||||||
#ifndef DLLVERSIONINFO
|
#ifndef DLLVERSIONINFO
|
||||||
|
|||||||
@@ -131,10 +131,10 @@ LL_COMMON_API std::ostream& operator<<(std::ostream& s, const LLCPUInfo& info);
|
|||||||
LL_COMMON_API std::ostream& operator<<(std::ostream& s, const LLMemoryInfo& info);
|
LL_COMMON_API std::ostream& operator<<(std::ostream& s, const LLMemoryInfo& info);
|
||||||
|
|
||||||
// gunzip srcfile into dstfile. Returns FALSE on error.
|
// gunzip srcfile into dstfile. Returns FALSE on error.
|
||||||
LL_COMMON_API BOOL gunzip_file(const std::string& srcfile, const std::string& dstfile);
|
BOOL LL_COMMON_API gunzip_file(const std::string& srcfile, const std::string& dstfile);
|
||||||
// gzip srcfile into dstfile. Returns FALSE on error.
|
// gzip srcfile into dstfile. Returns FALSE on error.
|
||||||
LL_COMMON_API BOOL gzip_file(const std::string& srcfile, const std::string& dstfile);
|
BOOL LL_COMMON_API gzip_file(const std::string& srcfile, const std::string& dstfile);
|
||||||
|
|
||||||
LL_COMMON_API extern LLCPUInfo gSysCPU;
|
extern LL_COMMON_API LLCPUInfo gSysCPU;
|
||||||
|
|
||||||
#endif // LL_LLSYS_H
|
#endif // LL_LLSYS_H
|
||||||
|
|||||||
@@ -908,8 +908,7 @@ mParent(parent)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
LLNotificationChannelPtr p = LLNotifications::instance().getChannel(parent);
|
LLNotificationChannelPtr p = LLNotifications::instance().getChannel(parent);
|
||||||
LLStandardSignal::slot_type f = boost::bind(&LLNotificationChannelBase::updateItem, this, _1);
|
p->connectChanged(boost::bind(&LLNotificationChannelBase::updateItem, this, _1));
|
||||||
p->connectChanged(f);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1010,16 +1009,18 @@ bool LLNotifications::uniqueFilter(LLNotificationPtr pNotif)
|
|||||||
|
|
||||||
bool LLNotifications::uniqueHandler(const LLSD& payload)
|
bool LLNotifications::uniqueHandler(const LLSD& payload)
|
||||||
{
|
{
|
||||||
|
std::string cmd = payload["sigtype"];
|
||||||
|
|
||||||
LLNotificationPtr pNotif = LLNotifications::instance().find(payload["id"].asUUID());
|
LLNotificationPtr pNotif = LLNotifications::instance().find(payload["id"].asUUID());
|
||||||
if (pNotif && pNotif->hasUniquenessConstraints())
|
if (pNotif && pNotif->hasUniquenessConstraints())
|
||||||
{
|
{
|
||||||
if (payload["sigtype"].asString() == "add")
|
if (cmd == "add")
|
||||||
{
|
{
|
||||||
// not a duplicate according to uniqueness criteria, so we keep it
|
// not a duplicate according to uniqueness criteria, so we keep it
|
||||||
// and store it for future uniqueness checks
|
// and store it for future uniqueness checks
|
||||||
mUniqueNotifications.insert(std::make_pair(pNotif->getName(), pNotif));
|
mUniqueNotifications.insert(std::make_pair(pNotif->getName(), pNotif));
|
||||||
}
|
}
|
||||||
else if (payload["sigtype"].asString() == "delete")
|
else if (cmd == "delete")
|
||||||
{
|
{
|
||||||
mUniqueNotifications.erase(pNotif->getName());
|
mUniqueNotifications.erase(pNotif->getName());
|
||||||
}
|
}
|
||||||
@@ -1425,6 +1426,8 @@ LLNotificationPtr LLNotifications::add(const LLNotification::Params& p)
|
|||||||
|
|
||||||
void LLNotifications::add(const LLNotificationPtr pNotif)
|
void LLNotifications::add(const LLNotificationPtr pNotif)
|
||||||
{
|
{
|
||||||
|
if (pNotif == NULL) return;
|
||||||
|
|
||||||
// first see if we already have it -- if so, that's a problem
|
// first see if we already have it -- if so, that's a problem
|
||||||
LLNotificationSet::iterator it=mItems.find(pNotif);
|
LLNotificationSet::iterator it=mItems.find(pNotif);
|
||||||
if (it != mItems.end())
|
if (it != mItems.end())
|
||||||
@@ -1437,6 +1440,8 @@ void LLNotifications::add(const LLNotificationPtr pNotif)
|
|||||||
|
|
||||||
void LLNotifications::cancel(LLNotificationPtr pNotif)
|
void LLNotifications::cancel(LLNotificationPtr pNotif)
|
||||||
{
|
{
|
||||||
|
if (pNotif == NULL || pNotif->isCancelled()) return;
|
||||||
|
|
||||||
LLNotificationSet::iterator it=mItems.find(pNotif);
|
LLNotificationSet::iterator it=mItems.find(pNotif);
|
||||||
if (it == mItems.end())
|
if (it == mItems.end())
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user