diff options
author | Aaron Brashears <aaronb@lindenlab.com> | 2007-10-04 16:31:48 +0000 |
---|---|---|
committer | Aaron Brashears <aaronb@lindenlab.com> | 2007-10-04 16:31:48 +0000 |
commit | 4942a7b77917f9a163453ecdd040993965672cc0 (patch) | |
tree | 3dd01f5e182d2eea2e34528cebe749d948a477fc /indra/llcommon | |
parent | 9fc7049151a16e3722c6ce90899e3c7b63161615 (diff) |
Result of svn merge -r70873:71086 svn+ssh://svn/svn/linden/branches/enable-exceptions into release.
Diffstat (limited to 'indra/llcommon')
-rw-r--r-- | indra/llcommon/ctype_workaround.h | 2 | ||||
-rw-r--r-- | indra/llcommon/linden_common.h | 34 | ||||
-rw-r--r-- | indra/llcommon/llassettype.cpp | 2 | ||||
-rw-r--r-- | indra/llcommon/llcriticaldamp.cpp | 1 | ||||
-rw-r--r-- | indra/llcommon/lldlinked.h | 2 | ||||
-rw-r--r-- | indra/llcommon/llerror.cpp | 27 | ||||
-rw-r--r-- | indra/llcommon/llfasttimer.h | 2 | ||||
-rw-r--r-- | indra/llcommon/llfile.h | 7 | ||||
-rw-r--r-- | indra/llcommon/llformat.cpp | 2 | ||||
-rw-r--r-- | indra/llcommon/llformat.h | 2 | ||||
-rw-r--r-- | indra/llcommon/llmap.h | 4 | ||||
-rw-r--r-- | indra/llcommon/llprocessor.cpp | 4 | ||||
-rw-r--r-- | indra/llcommon/llsd.cpp | 3 | ||||
-rw-r--r-- | indra/llcommon/llstl.h | 6 | ||||
-rw-r--r-- | indra/llcommon/llstring.cpp | 20 | ||||
-rw-r--r-- | indra/llcommon/llstring.h | 73 | ||||
-rw-r--r-- | indra/llcommon/llsys.cpp | 2 | ||||
-rw-r--r-- | indra/llcommon/lltimer.cpp | 3 | ||||
-rw-r--r-- | indra/llcommon/lltimer.h | 5 | ||||
-rw-r--r-- | indra/llcommon/stdtypes.h | 3 | ||||
-rw-r--r-- | indra/llcommon/timing.h | 3 |
21 files changed, 72 insertions, 135 deletions
diff --git a/indra/llcommon/ctype_workaround.h b/indra/llcommon/ctype_workaround.h index 8c52b0290c..5b095c8c19 100644 --- a/indra/llcommon/ctype_workaround.h +++ b/indra/llcommon/ctype_workaround.h @@ -18,7 +18,7 @@ * -- Leviathan 20060113 */ -#include <ctype.h> +#include <cctype> __const unsigned short int *__ctype_b; __const __int32_t *__ctype_tolower; diff --git a/indra/llcommon/linden_common.h b/indra/llcommon/linden_common.h index 5826bc917d..73dfc53c61 100644 --- a/indra/llcommon/linden_common.h +++ b/indra/llcommon/linden_common.h @@ -11,34 +11,42 @@ #include "llpreprocessor.h" -#include <string.h> -#include <math.h> -#include <stdio.h> -#include <stdlib.h> +#include <cstring> +#include <cfloat> +#include <climits> +#include <cmath> +#include <cstdarg> +#include <cstdio> +#include <cstdlib> +#include <ctime> +#include <iostream> +#include <fstream> // Work around stupid Microsoft STL warning #ifdef LL_WINDOWS #pragma warning (disable : 4702) // warning C4702: unreachable code #endif // LL_WINDOWS -#include <iostream> -#include <fstream> +#include <algorithm> +#include <list> +#include <map> #include <vector> #include <string> -#include "llfile.h" +#ifdef LL_WINDOWS +#pragma warning (3 : 4702) // we like level 3, not 4 +#endif // LL_WINDOWS + +// Linden only libs in alpha-order other than stdtypes.h #include "stdtypes.h" #include "lldefs.h" #include "llerror.h" #include "llextendedstatus.h" +#include "llfasttimer.h" +#include "llfile.h" #include "llformat.h" #include "llstring.h" -#include "lltimer.h" -#include "llfasttimer.h" #include "llsys.h" - -#ifdef LL_WINDOWS -#pragma warning (3 : 4702) // we like level 3, not 4 -#endif // LL_WINDOWS +#include "lltimer.h" #endif diff --git a/indra/llcommon/llassettype.cpp b/indra/llcommon/llassettype.cpp index b5378943ca..4b37f0d188 100644 --- a/indra/llcommon/llassettype.cpp +++ b/indra/llcommon/llassettype.cpp @@ -10,8 +10,6 @@ #include "llassettype.h" -#include <time.h> - #include "llstring.h" #include "lltimer.h" diff --git a/indra/llcommon/llcriticaldamp.cpp b/indra/llcommon/llcriticaldamp.cpp index ee7dfecdaa..1757f16c99 100644 --- a/indra/llcommon/llcriticaldamp.cpp +++ b/indra/llcommon/llcriticaldamp.cpp @@ -7,7 +7,6 @@ */ #include "linden_common.h" -#include <math.h> #include "llcriticaldamp.h" diff --git a/indra/llcommon/lldlinked.h b/indra/llcommon/lldlinked.h index 54087848d9..1e5ddfd1a4 100644 --- a/indra/llcommon/lldlinked.h +++ b/indra/llcommon/lldlinked.h @@ -8,8 +8,6 @@ #ifndef LL_LLDLINKED_H #define LL_LLDLINKED_H -#include <stdlib.h> - template <class Type> class LLDLinked { LLDLinked* mNextp; diff --git a/indra/llcommon/llerror.cpp b/indra/llcommon/llerror.cpp index 90ea72f24c..98972950b7 100644 --- a/indra/llcommon/llerror.cpp +++ b/indra/llcommon/llerror.cpp @@ -12,33 +12,28 @@ #include "llerror.h" #include "llerrorcontrol.h" -#include "llapp.h" -#include "llapr.h" -#include "llfile.h" -#include "llfixedbuffer.h" -#include "lllivefile.h" -#include "llsd.h" -#include "llsdserialize.h" -#include "llstl.h" - -#include <algorithm> #include <cctype> -#include <map> +#ifdef __GNUC__ +#include <cxxabi.h> +#endif #include <sstream> #if !LL_WINDOWS -#include <stdio.h> #include <syslog.h> #endif -#include <time.h> #if LL_WINDOWS #include <windows.h> #endif #include <vector> +#include "llapp.h" +#include "llapr.h" +#include "llfile.h" +#include "llfixedbuffer.h" +#include "lllivefile.h" +#include "llsd.h" +#include "llsdserialize.h" +#include "llstl.h" -#ifdef __GNUC__ -#include <cxxabi.h> -#endif namespace { #if !LL_WINDOWS diff --git a/indra/llcommon/llfasttimer.h b/indra/llcommon/llfasttimer.h index 3e88784d3c..648c4bab4e 100644 --- a/indra/llcommon/llfasttimer.h +++ b/indra/llcommon/llfasttimer.h @@ -9,8 +9,6 @@ #ifndef LL_LLFASTTIMER_H #define LL_LLFASTTIMER_H -#include "lltimer.h" - #define FAST_TIMER_ON 1 U64 get_cpu_clock_count(); diff --git a/indra/llcommon/llfile.h b/indra/llcommon/llfile.h index 605918cd29..77bd20e274 100644 --- a/indra/llcommon/llfile.h +++ b/indra/llcommon/llfile.h @@ -17,12 +17,6 @@ * Attempts to mostly mirror the POSIX style IO functions. */ -#include <string> -#include <stdio.h> -#include <sys/stat.h> -#include <fstream> -#include "stdtypes.h" - typedef FILE LLFILE; #ifdef LL_WINDOWS @@ -36,6 +30,7 @@ typedef FILE LLFILE; // windows version of stat function and stat data structure are called _stat typedef struct _stat llstat; #else +#include <sys/stat.h> typedef struct stat llstat; #endif diff --git a/indra/llcommon/llformat.cpp b/indra/llcommon/llformat.cpp index 0c2a6d3b1e..9bfdb14446 100644 --- a/indra/llcommon/llformat.cpp +++ b/indra/llcommon/llformat.cpp @@ -11,7 +11,7 @@ #include "llformat.h" -#include <stdarg.h> +#include <cstdarg> std::string llformat(const char *fmt, ...) { diff --git a/indra/llcommon/llformat.h b/indra/llcommon/llformat.h index 7079656b72..31ee3194d3 100644 --- a/indra/llcommon/llformat.h +++ b/indra/llcommon/llformat.h @@ -10,8 +10,6 @@ #ifndef LL_LLFORMAT_H #define LL_LLFORMAT_H -#include <string> - // Use as follows: // llinfos << llformat("Test:%d (%.2f %.2f)", idx, x, y) << llendl; // diff --git a/indra/llcommon/llmap.h b/indra/llcommon/llmap.h index fc958421da..97af9f5ec9 100644 --- a/indra/llcommon/llmap.h +++ b/indra/llcommon/llmap.h @@ -9,10 +9,6 @@ #ifndef LL_LLMAP_H #define LL_LLMAP_H -#include <stdio.h> -#include <utility> -#include <map> - // llmap uses the fast stl library code in a manner consistant with LLSkipMap, et. al. template<class INDEX_TYPE, class MAPPED_TYPE> class LLMap diff --git a/indra/llcommon/llprocessor.cpp b/indra/llcommon/llprocessor.cpp index c8c565a05b..c676a37a5e 100644 --- a/indra/llcommon/llprocessor.cpp +++ b/indra/llcommon/llprocessor.cpp @@ -28,9 +28,7 @@ #include "processor.h" -#include <stdio.h> -#include <string.h> -#include <memory.h> +#include <memory> #if LL_WINDOWS # define WIN32_LEAN_AND_MEAN diff --git a/indra/llcommon/llsd.cpp b/indra/llcommon/llsd.cpp index 2fb9a0ab9c..aa52255704 100644 --- a/indra/llcommon/llsd.cpp +++ b/indra/llcommon/llsd.cpp @@ -9,9 +9,6 @@ #include "linden_common.h" #include "llsd.h" -#include <sstream> -#include <math.h> - #include "llerror.h" #include "../llmath/llmath.h" #include "llformat.h" diff --git a/indra/llcommon/llstl.h b/indra/llcommon/llstl.h index 8a32a04fc2..541f1a9c81 100644 --- a/indra/llcommon/llstl.h +++ b/indra/llcommon/llstl.h @@ -10,15 +10,9 @@ #define LL_LLSTL_H #include <functional> -#include <algorithm> -#include <map> -#include <vector> #include <set> #include <deque> -#include <stdio.h> -#include <stdarg.h> - // Use to compare the first element only of a pair // e.g. typedef std::set<std::pair<int, Data*>, compare_pair<int, Data*> > some_pair_set_t; template <typename T1, typename T2> diff --git a/indra/llcommon/llstring.cpp b/indra/llcommon/llstring.cpp index 0b799b94ae..2d7c903341 100644 --- a/indra/llcommon/llstring.cpp +++ b/indra/llcommon/llstring.cpp @@ -35,6 +35,26 @@ U8 hex_as_nybble(char hex) } +bool _read_file_into_string(std::string& str, const char* filename) +{ + llifstream ifs(filename, llifstream::binary); + if (!ifs.is_open()) + { + llinfos << "Unable to open file" << filename << llendl; + return false; + } + + std::ostringstream oss; + + oss << ifs.rdbuf(); + str = oss.str(); + ifs.close(); + return true; +} + + + + // See http://www.unicode.org/Public/BETA/CVTUTF-1-2/ConvertUTF.c // for the Unicode implementation - this doesn't match because it was written before finding // it. diff --git a/indra/llcommon/llstring.h b/indra/llcommon/llstring.h index 3005155b19..b922b2f8e5 100644 --- a/indra/llcommon/llstring.h +++ b/indra/llcommon/llstring.h @@ -9,17 +9,6 @@ #ifndef LL_LLSTRING_H #define LL_LLSTRING_H -#include "stdtypes.h" -#include "llerror.h" -#include "llfile.h" -#include <algorithm> -#include <map> -#include <stdio.h> -#include <ctype.h> -#include <stdlib.h> -#include <errno.h> -#include <math.h> -#include <stdarg.h> /* for vsnprintf */ #if LL_LINUX || LL_SOLARIS #include <wctype.h> #include <wchar.h> @@ -260,9 +249,6 @@ public: */ static void _makeASCII(std::basic_string<T>& string); - static BOOL read(std::basic_string<T>& string, const char* filename); /*Flawfinder: ignore*/ - static BOOL write(std::basic_string<T>& string, const char* filename); - // Conversion to other data types static BOOL convertToBOOL(const std::basic_string<T>& string, BOOL& value); static BOOL convertToU8(const std::basic_string<T>& string, U8& value); @@ -353,6 +339,16 @@ std::string ll_safe_string(const char* in); */ U8 hex_as_nybble(char hex); +/** + * @brief read the contents of a file into a string. + * + * Since this function has no concept of character encoding, most + * anything you do with this method ill-advised. Please avoid. + * @param str [out] The string which will have. + * @param filename The full name of the file to read. + * @return Returns true on success. If false, str is unmodified. + */ +bool _read_file_into_string(std::string& str, const char* filename); /** * Unicode support @@ -913,8 +909,6 @@ void LLStringBase<T>::replaceNonstandardASCII( std::basic_string<T>& string, T r template<class T> void LLStringBase<T>::replaceTabsWithSpaces( std::basic_string<T>& str, size_type spaces_per_tab ) { - llassert( spaces_per_tab >= 0 ); - const T TAB = '\t'; const T SPACE = ' '; @@ -1017,11 +1011,10 @@ void LLStringBase<T>::copy( T* dst, const T* src, size_type dst_size ) template<class T> void LLStringBase<T>::copyInto(std::basic_string<T>& dst, const std::basic_string<T>& src, size_type offset) { - llassert( offset <= dst.length() ); - - // special case - append to end of string and avoid expensive (when strings are large) string manipulations if ( offset == dst.length() ) { + // special case - append to end of string and avoid expensive + // (when strings are large) string manipulations dst += src; } else @@ -1050,48 +1043,6 @@ BOOL LLStringBase<T>::isHead( const std::basic_string<T>& string, const T* s ) } } -//static -template<class T> -BOOL LLStringBase<T>::read(std::basic_string<T>& string, const char* filename) /*Flawfinder: ignore*/ -{ - llifstream ifs(filename, llifstream::binary); - if (!ifs.is_open()) - { - llinfos << "Unable to open file" << filename << llendl; - return FALSE; - } - - std::basic_ostringstream<T> oss; - - oss << ifs.rdbuf(); - - string = oss.str(); - - ifs.close(); - return TRUE; -} - -//static -template<class T> -BOOL LLStringBase<T>::write(std::basic_string<T>& string, const char* filename) -{ -#if LL_LINUX || LL_SOLARIS - printf("STUBBED: LLStringBase<T>::write at %s:%d\n", __FILE__, __LINE__); -#else - llofstream ofs(filename, llofstream::binary); - if (!ofs.is_open()) - { - llinfos << "Unable to open file" << filename << llendl; - return FALSE; - } - - ofs << string; - - ofs.close(); -#endif - return TRUE; -} - template<class T> BOOL LLStringBase<T>::convertToBOOL(const std::basic_string<T>& string, BOOL& value) { diff --git a/indra/llcommon/llsys.cpp b/indra/llcommon/llsys.cpp index b1b92ae277..86ec4c0d61 100644 --- a/indra/llcommon/llsys.cpp +++ b/indra/llcommon/llsys.cpp @@ -24,10 +24,12 @@ # include <winsock2.h> # include <windows.h> #elif LL_DARWIN +# include <errno.h> # include <sys/sysctl.h> # include <sys/utsname.h> # include <stdint.h> #elif LL_LINUX +# include <errno.h> # include <sys/utsname.h> # include <unistd.h> # include <sys/sysinfo.h> diff --git a/indra/llcommon/lltimer.cpp b/indra/llcommon/lltimer.cpp index 73e73b9c44..013fab0965 100644 --- a/indra/llcommon/lltimer.cpp +++ b/indra/llcommon/lltimer.cpp @@ -16,13 +16,10 @@ # define WIN32_LEAN_AND_MEAN # include <winsock2.h> # include <windows.h> -# include <time.h> #elif LL_LINUX || LL_SOLARIS -# include <time.h> # include <sys/time.h> # include <sched.h> #elif LL_DARWIN -# include <time.h> # include <sys/time.h> #else # error "architecture not supported" diff --git a/indra/llcommon/lltimer.h b/indra/llcommon/lltimer.h index 6f67e19c48..e6ea032514 100644 --- a/indra/llcommon/lltimer.h +++ b/indra/llcommon/lltimer.h @@ -10,12 +10,9 @@ #define LL_TIMER_H #if LL_LINUX || LL_DARWIN -# include <time.h> -# include <sys/time.h> +#include <sys/time.h> #endif -#include <list> - // units conversions #ifndef USEC_PER_SEC const U32 USEC_PER_SEC = 1000000; diff --git a/indra/llcommon/stdtypes.h b/indra/llcommon/stdtypes.h index ccb843061d..bc069f009d 100644 --- a/indra/llcommon/stdtypes.h +++ b/indra/llcommon/stdtypes.h @@ -8,9 +8,6 @@ #ifndef LL_STDTYPES_H #define LL_STDTYPES_H -#include <limits.h> -#include <float.h> - typedef signed char S8; typedef unsigned char U8; typedef signed short S16; diff --git a/indra/llcommon/timing.h b/indra/llcommon/timing.h index 8952bc3b52..53e7a62a85 100644 --- a/indra/llcommon/timing.h +++ b/indra/llcommon/timing.h @@ -9,10 +9,9 @@ #ifndef LL_TIMING_H #define LL_TIMING_H -#include <time.h> #if LL_LINUX || LL_DARWIN || LL_SOLARIS -# include <sys/time.h> +#include <sys/time.h> #endif |