General beast update, fixes, optimizations, features:

* Clean ups, optimizations, and new File::commonDocumentsDirectory enum
* Replace sortArray with std::sort for performance
* More error tolerance in XML parser, speedups
* Refactor some byte-order mark detection code
* Add String::appendCharPointer overloads
* More XML parser optimisations and better error detection
* Misc performance tweaks
* Fixes for support of non utf8 strings
* Increased precision when storing strings in XmlElement
* Minor clean-ups
* Minor fix to XmlDocument
* Cleanups to CriticalSection and related synchronization primitives
* Fix DynamicArray unit test
This commit is contained in:
Vinnie Falco
2013-09-10 09:52:24 -07:00
parent 27307fca0c
commit 43e6d345e4
83 changed files with 433 additions and 687 deletions

View File

@@ -228,15 +228,10 @@ Some files contain portions of these external projects, licensed separately:
namespace beast namespace beast
{ {
class MemoryBlock;
class File;
class InputStream; class InputStream;
class OutputStream; class OutputStream;
class DynamicObject;
class FileInputStream; class FileInputStream;
class FileOutputStream; class FileOutputStream;
class XmlElement;
class JSONFormatter;
extern BEAST_API bool BEAST_CALLTYPE beast_isRunningUnderDebugger(); extern BEAST_API bool BEAST_CALLTYPE beast_isRunningUnderDebugger();
extern BEAST_API void BEAST_CALLTYPE logAssertion (char const* file, int line) noexcept; extern BEAST_API void BEAST_CALLTYPE logAssertion (char const* file, int line) noexcept;
@@ -266,7 +261,6 @@ extern BEAST_API void BEAST_CALLTYPE logAssertion (char const* file, int line) n
# include "containers/detail/removecv.h" # include "containers/detail/removecv.h"
#include "containers/detail/copyconst.h" #include "containers/detail/copyconst.h"
#include "system/PlatformDefs.h" #include "system/PlatformDefs.h"
#include "system/TargetPlatform.h" #include "system/TargetPlatform.h"
#include "diagnostic/beast_Throw.h" #include "diagnostic/beast_Throw.h"
@@ -279,24 +273,36 @@ extern BEAST_API void BEAST_CALLTYPE logAssertion (char const* file, int line) n
#include "containers/beast_LockFreeStack.h" #include "containers/beast_LockFreeStack.h"
#include "threads/beast_SpinDelay.h" #include "threads/beast_SpinDelay.h"
#include "memory/beast_StaticObject.h" #include "memory/beast_StaticObject.h"
#include "text/StringCharPointerType.h" #include "text/StringCharPointerType.h"
#include "text/StringFromNumber.h" #include "text/StringFromNumber.h"
#include "text/beast_String.h" #include "text/beast_String.h"
#include "time/beast_PerformedAtExit.h"
#include "diagnostic/beast_LeakChecked.h"
#include "time/beast_RelativeTime.h"
#include "time/beast_Time.h"
#include "memory/beast_HeapBlock.h"
#include "threads/beast_ScopedLock.h"
#include "threads/beast_CriticalSection.h"
#include "containers/beast_ElementComparator.h"
#include "containers/beast_ArrayAllocationBase.h"
#include "containers/beast_Array.h"
#include "misc/beast_Result.h"
#include "text/beast_StringArray.h"
#include "memory/beast_MemoryBlock.h"
#include "files/beast_File.h"
#include "time/beast_PerformanceCounter.h"
#include "memory/beast_MemoryAlignment.h" #include "memory/beast_MemoryAlignment.h"
#include "memory/beast_CacheLine.h" #include "memory/beast_CacheLine.h"
#include "threads/beast_CriticalSection.h"
#include "threads/beast_ReadWriteMutex.h" #include "threads/beast_ReadWriteMutex.h"
#include "threads/beast_SharedData.h" #include "threads/beast_SharedData.h"
#include "diagnostic/beast_SafeBool.h" #include "diagnostic/beast_SafeBool.h"
#include "time/beast_PerformedAtExit.h"
#include "diagnostic/beast_LeakChecked.h"
#include "threads/beast_WaitableEvent.h" #include "threads/beast_WaitableEvent.h"
#include "threads/beast_Thread.h" #include "threads/beast_Thread.h"
#include "threads/beast_SpinLock.h" #include "threads/beast_SpinLock.h"
#include "threads/beast_ThreadLocalValue.h" #include "threads/beast_ThreadLocalValue.h"
#include "thread/MutexTraits.h" #include "thread/MutexTraits.h"
#include "containers/beast_Array.h"
#include "text/beast_StringArray.h"
#include "thread/TrackedMutex.h" #include "thread/TrackedMutex.h"
#include "diagnostic/beast_FatalError.h" #include "diagnostic/beast_FatalError.h"
#include "diagnostic/beast_Error.h" #include "diagnostic/beast_Error.h"
@@ -313,14 +319,16 @@ extern BEAST_API void BEAST_CALLTYPE logAssertion (char const* file, int line) n
#include "functional/SharedFunction.h" #include "functional/SharedFunction.h"
#include "diagnostic/beast_ProtectedCall.h" #include "diagnostic/beast_ProtectedCall.h"
#include "containers/beast_AbstractFifo.h" #include "containers/beast_AbstractFifo.h"
#include "containers/beast_ArrayAllocationBase.h" #include "text/beast_Identifier.h"
#include "containers/beast_DynamicObject.h" #include "containers/beast_Variant.h"
#include "containers/beast_ElementComparator.h"
#include "maths/beast_Random.h"
#include "containers/beast_LinkedListPointer.h" #include "containers/beast_LinkedListPointer.h"
#include "containers/beast_LockFreeQueue.h"
#include "containers/beast_NamedValueSet.h" #include "containers/beast_NamedValueSet.h"
#include "containers/beast_DynamicObject.h"
#include "maths/beast_BigInteger.h"
#include "maths/beast_Random.h"
#include "containers/beast_LockFreeQueue.h"
#include "containers/beast_OwnedArray.h" #include "containers/beast_OwnedArray.h"
#include "text/beast_StringPairArray.h"
#include "containers/beast_PropertySet.h" #include "containers/beast_PropertySet.h"
#include "containers/beast_SharedObjectArray.h" #include "containers/beast_SharedObjectArray.h"
#include "containers/beast_ScopedValueSetter.h" #include "containers/beast_ScopedValueSetter.h"
@@ -329,13 +337,17 @@ extern BEAST_API void BEAST_CALLTYPE logAssertion (char const* file, int line) n
#include "containers/beast_SortedSet.h" #include "containers/beast_SortedSet.h"
#include "maths/beast_Range.h" #include "maths/beast_Range.h"
#include "containers/beast_SparseSet.h" #include "containers/beast_SparseSet.h"
#include "containers/beast_Variant.h"
# include "containers/DynamicList.h" # include "containers/DynamicList.h"
# include "containers/DynamicArray.h" # include "containers/DynamicArray.h"
#include "containers/HashMap.h" #include "containers/HashMap.h"
#include "memory/beast_ScopedPointer.h"
#include "files/beast_DirectoryIterator.h" #include "files/beast_DirectoryIterator.h"
#include "files/beast_File.h" #include "streams/beast_InputStream.h"
#include "files/beast_FileInputStream.h" #include "files/beast_FileInputStream.h"
#include "streams/beast_InputSource.h"
#include "streams/beast_FileInputSource.h"
#include "text/beast_NewLine.h"
#include "streams/beast_OutputStream.h"
#include "files/beast_FileOutputStream.h" #include "files/beast_FileOutputStream.h"
#include "files/beast_FileSearchPath.h" #include "files/beast_FileSearchPath.h"
#include "files/beast_MemoryMappedFile.h" #include "files/beast_MemoryMappedFile.h"
@@ -344,44 +356,33 @@ extern BEAST_API void BEAST_CALLTYPE logAssertion (char const* file, int line) n
#include "json/beast_JSON.h" #include "json/beast_JSON.h"
#include "logging/beast_FileLogger.h" #include "logging/beast_FileLogger.h"
#include "logging/beast_Logger.h" #include "logging/beast_Logger.h"
#include "maths/beast_BigInteger.h"
#include "maths/beast_Expression.h" #include "maths/beast_Expression.h"
#include "maths/beast_Interval.h" #include "maths/beast_Interval.h"
#include "maths/beast_MathsFunctions.h" #include "maths/beast_MathsFunctions.h"
#include "maths/beast_MurmurHash.h" #include "maths/beast_MurmurHash.h"
#include "memory/beast_ByteOrder.h" #include "memory/beast_ByteOrder.h"
#include "memory/beast_HeapBlock.h"
#include "memory/beast_Memory.h" #include "memory/beast_Memory.h"
#include "memory/beast_MemoryBlock.h"
#include "memory/beast_OptionalScopedPointer.h" #include "memory/beast_OptionalScopedPointer.h"
#include "memory/beast_ScopedPointer.h"
#include "memory/beast_SharedSingleton.h" #include "memory/beast_SharedSingleton.h"
#include "memory/beast_WeakReference.h" #include "memory/beast_WeakReference.h"
#include "memory/beast_RecycledObjectPool.h" #include "memory/beast_RecycledObjectPool.h"
#include "misc/beast_Main.h" #include "misc/beast_Main.h"
#include "misc/beast_Result.h"
#include "misc/beast_Uuid.h" #include "misc/beast_Uuid.h"
#include "misc/beast_WindowsRegistry.h" #include "misc/beast_WindowsRegistry.h"
#include "network/beast_IPAddress.h" #include "network/beast_IPAddress.h"
#include "network/beast_MACAddress.h" #include "network/beast_MACAddress.h"
#include "threads/beast_ReadWriteLock.h"
#include "network/beast_NamedPipe.h" #include "network/beast_NamedPipe.h"
#include "network/beast_Socket.h" #include "network/beast_Socket.h"
#include "network/beast_URL.h" #include "network/beast_URL.h"
#include "streams/beast_BufferedInputStream.h" #include "streams/beast_BufferedInputStream.h"
#include "streams/beast_FileInputSource.h"
#include "streams/beast_InputSource.h"
#include "streams/beast_InputStream.h"
#include "streams/beast_MemoryInputStream.h" #include "streams/beast_MemoryInputStream.h"
#include "streams/beast_MemoryOutputStream.h" #include "streams/beast_MemoryOutputStream.h"
#include "streams/beast_OutputStream.h"
#include "streams/beast_SubregionStream.h" #include "streams/beast_SubregionStream.h"
#include "system/SystemStats.h" #include "system/SystemStats.h"
#include "text/beast_Identifier.h"
#include "text/beast_LocalisedStrings.h" #include "text/beast_LocalisedStrings.h"
#include "text/beast_NewLine.h"
#include "diagnostic/beast_SemanticVersion.h" #include "diagnostic/beast_SemanticVersion.h"
#include "text/beast_StringPairArray.h"
#include "text/beast_StringPool.h" #include "text/beast_StringPool.h"
#include "text/beast_TextDiff.h" #include "text/beast_TextDiff.h"
#include "threads/beast_ChildProcess.h" #include "threads/beast_ChildProcess.h"
@@ -389,15 +390,10 @@ extern BEAST_API void BEAST_CALLTYPE logAssertion (char const* file, int line) n
#include "threads/beast_HighResolutionTimer.h" #include "threads/beast_HighResolutionTimer.h"
#include "threads/beast_InterProcessLock.h" #include "threads/beast_InterProcessLock.h"
#include "threads/beast_Process.h" #include "threads/beast_Process.h"
#include "threads/beast_ReadWriteLock.h"
#include "threads/beast_ScopedLock.h"
#include "threads/beast_ScopedReadLock.h" #include "threads/beast_ScopedReadLock.h"
#include "threads/beast_ScopedWriteLock.h" #include "threads/beast_ScopedWriteLock.h"
#include "threads/beast_ThreadPool.h" #include "threads/beast_ThreadPool.h"
#include "threads/beast_TimeSliceThread.h" #include "threads/beast_TimeSliceThread.h"
#include "time/beast_PerformanceCounter.h"
#include "time/beast_RelativeTime.h"
#include "time/beast_Time.h"
#include "diagnostic/beast_UnitTest.h" #include "diagnostic/beast_UnitTest.h"
#include "xml/beast_XmlDocument.h" #include "xml/beast_XmlDocument.h"
#include "xml/beast_XmlElement.h" #include "xml/beast_XmlElement.h"

View File

@@ -83,6 +83,7 @@ public:
beginTestCase (s); beginTestCase (s);
for (std::size_t i = 0; i < numberToMutate; ++i) for (std::size_t i = 0; i < numberToMutate; ++i)
v.push_back (T (String::fromNumber (i))); v.push_back (T (String::fromNumber (i)));
pass ();
s = "read [] (" + String::fromNumber <int> (numberToMutate) + ")"; s = "read [] (" + String::fromNumber <int> (numberToMutate) + ")";
beginTestCase (s); beginTestCase (s);
@@ -93,6 +94,7 @@ public:
beginTestCase (s); beginTestCase (s);
for (std::size_t i = 0; i < numberToMutate; ++i) for (std::size_t i = 0; i < numberToMutate; ++i)
v [i].msg = "+" + String::fromNumber (i); v [i].msg = "+" + String::fromNumber (i);
pass ();
s = "verify [] (" + String::fromNumber <int> (numberToMutate) + ")"; s = "verify [] (" + String::fromNumber <int> (numberToMutate) + ")";
beginTestCase (s); beginTestCase (s);
@@ -141,6 +143,7 @@ public:
step ++; step ++;
iter - v.rend (); iter - v.rend ();
} }
pass ();
} }
{ {
@@ -152,6 +155,7 @@ public:
step ++; step ++;
iter - v.crend (); iter - v.crend ();
} }
pass ();
} }
} }

View File

@@ -24,11 +24,6 @@
#ifndef BEAST_ARRAY_H_INCLUDED #ifndef BEAST_ARRAY_H_INCLUDED
#define BEAST_ARRAY_H_INCLUDED #define BEAST_ARRAY_H_INCLUDED
#include "beast_ArrayAllocationBase.h"
#include "beast_ElementComparator.h"
#include "../threads/beast_CriticalSection.h"
//============================================================================== //==============================================================================
/** /**
Holds a resizable array of primitive or copy-by-value objects. Holds a resizable array of primitive or copy-by-value objects.
@@ -788,7 +783,7 @@ public:
@param startIndex the index of the first element to remove @param startIndex the index of the first element to remove
@param numberToRemove how many elements should be removed @param numberToRemove how many elements should be removed
@see remove, removeValue @see remove, removeFirstMatchingValue, removeAllInstancesOf
*/ */
void removeRange (int startIndex, int numberToRemove) void removeRange (int startIndex, int numberToRemove)
{ {
@@ -816,7 +811,7 @@ public:
/** Removes the last n elements from the array. /** Removes the last n elements from the array.
@param howManyToRemove how many elements to remove from the end of the array @param howManyToRemove how many elements to remove from the end of the array
@see remove, removeValue, removeRange @see remove, removeFirstMatchingValue, removeAllInstancesOf, removeRange
*/ */
void removeLast (int howManyToRemove = 1) void removeLast (int howManyToRemove = 1)
{ {
@@ -835,7 +830,7 @@ public:
/** Removes any elements which are also in another array. /** Removes any elements which are also in another array.
@param otherArray the other array in which to look for elements to remove @param otherArray the other array in which to look for elements to remove
@see removeValuesNotIn, remove, removeValue, removeRange @see removeValuesNotIn, remove, removeFirstMatchingValue, removeAllInstancesOf, removeRange
*/ */
template <class OtherArrayType> template <class OtherArrayType>
void removeValuesIn (const OtherArrayType& otherArray) void removeValuesIn (const OtherArrayType& otherArray)
@@ -863,7 +858,7 @@ public:
Only elements which occur in this other array will be retained. Only elements which occur in this other array will be retained.
@param otherArray the array in which to look for elements NOT to remove @param otherArray the array in which to look for elements NOT to remove
@see removeValuesIn, remove, removeValue, removeRange @see removeValuesIn, remove, removeFirstMatchingValue, removeAllInstancesOf, removeRange
*/ */
template <class OtherArrayType> template <class OtherArrayType>
void removeValuesNotIn (const OtherArrayType& otherArray) void removeValuesNotIn (const OtherArrayType& otherArray)

View File

@@ -24,9 +24,6 @@
#ifndef BEAST_ARRAYALLOCATIONBASE_H_INCLUDED #ifndef BEAST_ARRAYALLOCATIONBASE_H_INCLUDED
#define BEAST_ARRAYALLOCATIONBASE_H_INCLUDED #define BEAST_ARRAYALLOCATIONBASE_H_INCLUDED
#include "../memory/beast_HeapBlock.h"
//============================================================================== //==============================================================================
/** /**
Implements some basic array storage allocation functions. Implements some basic array storage allocation functions.

View File

@@ -24,9 +24,6 @@
#ifndef BEAST_DYNAMICOBJECT_H_INCLUDED #ifndef BEAST_DYNAMICOBJECT_H_INCLUDED
#define BEAST_DYNAMICOBJECT_H_INCLUDED #define BEAST_DYNAMICOBJECT_H_INCLUDED
#include "beast_NamedValueSet.h"
//============================================================================== //==============================================================================
/** /**
Represents a dynamically implemented object. Represents a dynamically implemented object.

View File

@@ -24,6 +24,26 @@
#ifndef BEAST_ELEMENTCOMPARATOR_H_INCLUDED #ifndef BEAST_ELEMENTCOMPARATOR_H_INCLUDED
#define BEAST_ELEMENTCOMPARATOR_H_INCLUDED #define BEAST_ELEMENTCOMPARATOR_H_INCLUDED
#ifndef DOXYGEN
/** This is an internal helper class which converts a beast ElementComparator style
class (using a "compareElements" method) into a class that's compatible with
std::sort (i.e. using an operator() to compare the elements)
*/
template <typename ElementComparator>
struct SortFunctionConverter
{
SortFunctionConverter (ElementComparator& e) : comparator (e) {}
template <typename Type>
bool operator() (Type a, Type b) { return comparator.compareElements (a, b) < 0; }
private:
ElementComparator& comparator;
SortFunctionConverter& operator= (const SortFunctionConverter&);
};
#endif
//============================================================================== //==============================================================================
/** /**
@@ -60,117 +80,12 @@ static void sortArray (ElementComparator& comparator,
int lastElement, int lastElement,
const bool retainOrderOfEquivalentItems) const bool retainOrderOfEquivalentItems)
{ {
(void) comparator; // if you pass in an object with a static compareElements() method, this SortFunctionConverter<ElementComparator> converter (comparator);
// avoids getting warning messages about the parameter being unused
if (lastElement > firstElement)
{
if (retainOrderOfEquivalentItems) if (retainOrderOfEquivalentItems)
{ std::stable_sort (array + firstElement, array + lastElement + 1, converter);
for (int i = firstElement; i < lastElement; ++i)
{
if (comparator.compareElements (array[i], array [i + 1]) > 0)
{
std::swap (array[i], array[i + 1]);
if (i > firstElement)
i -= 2;
}
}
}
else else
{ std::sort (array + firstElement, array + lastElement + 1, converter);
int fromStack[30], toStack[30];
int stackIndex = 0;
for (;;)
{
const int size = (lastElement - firstElement) + 1;
if (size <= 8)
{
int j = lastElement;
int maxIndex;
while (j > firstElement)
{
maxIndex = firstElement;
for (int k = firstElement + 1; k <= j; ++k)
if (comparator.compareElements (array[k], array [maxIndex]) > 0)
maxIndex = k;
std::swap (array[j], array[maxIndex]);
--j;
}
}
else
{
const int mid = firstElement + (size >> 1);
std::swap (array[mid], array[firstElement]);
int i = firstElement;
int j = lastElement + 1;
for (;;)
{
while (++i <= lastElement
&& comparator.compareElements (array[i], array [firstElement]) <= 0)
{}
while (--j > firstElement
&& comparator.compareElements (array[j], array [firstElement]) >= 0)
{}
if (j < i)
break;
std::swap (array[i], array[j]);
}
std::swap (array[j], array[firstElement]);
if (j - 1 - firstElement >= lastElement - i)
{
if (firstElement + 1 < j)
{
fromStack [stackIndex] = firstElement;
toStack [stackIndex] = j - 1;
++stackIndex;
}
if (i < lastElement)
{
firstElement = i;
continue;
}
}
else
{
if (i < lastElement)
{
fromStack [stackIndex] = i;
toStack [stackIndex] = lastElement;
++stackIndex;
}
if (firstElement + 1 < j)
{
lastElement = j - 1;
continue;
}
}
}
if (--stackIndex < 0)
break;
bassert (stackIndex < numElementsInArray (fromStack));
firstElement = fromStack [stackIndex];
lastElement = toStack [stackIndex];
}
}
}
} }
@@ -270,5 +185,5 @@ public:
} }
}; };
#endif
#endif // BEAST_ELEMENTCOMPARATOR_H_INCLUDED

View File

@@ -24,8 +24,6 @@
#ifndef BEAST_NAMEDVALUESET_H_INCLUDED #ifndef BEAST_NAMEDVALUESET_H_INCLUDED
#define BEAST_NAMEDVALUESET_H_INCLUDED #define BEAST_NAMEDVALUESET_H_INCLUDED
#include "beast_Variant.h"
#include "../containers/beast_LinkedListPointer.h"
class XmlElement; class XmlElement;
#ifndef DOXYGEN #ifndef DOXYGEN
class JSONFormatter; class JSONFormatter;

View File

@@ -24,11 +24,6 @@
#ifndef BEAST_PROPERTYSET_H_INCLUDED #ifndef BEAST_PROPERTYSET_H_INCLUDED
#define BEAST_PROPERTYSET_H_INCLUDED #define BEAST_PROPERTYSET_H_INCLUDED
#include "../text/beast_StringPairArray.h"
#include "../xml/beast_XmlElement.h"
#include "../containers/beast_Variant.h"
//============================================================================== //==============================================================================
/** /**
A set of named property values, which can be strings, integers, floating point, etc. A set of named property values, which can be strings, integers, floating point, etc.

View File

@@ -24,11 +24,6 @@
#ifndef BEAST_SHAREDOBJECTARRAY_H_INCLUDED #ifndef BEAST_SHAREDOBJECTARRAY_H_INCLUDED
#define BEAST_SHAREDOBJECTARRAY_H_INCLUDED #define BEAST_SHAREDOBJECTARRAY_H_INCLUDED
#include "beast_ArrayAllocationBase.h"
#include "beast_ElementComparator.h"
#include "../threads/beast_CriticalSection.h"
//============================================================================== //==============================================================================
/** /**
Holds a list of objects derived from SharedObject. Holds a list of objects derived from SharedObject.

View File

@@ -24,15 +24,11 @@
#ifndef BEAST_SORTEDSET_H_INCLUDED #ifndef BEAST_SORTEDSET_H_INCLUDED
#define BEAST_SORTEDSET_H_INCLUDED #define BEAST_SORTEDSET_H_INCLUDED
#include "beast_ArrayAllocationBase.h"
#include "../threads/beast_CriticalSection.h"
#if BEAST_MSVC #if BEAST_MSVC
#pragma warning (push) #pragma warning (push)
#pragma warning (disable: 4512) #pragma warning (disable: 4512)
#endif #endif
//============================================================================== //==============================================================================
/** /**
Holds a set of unique primitive objects, such as ints or doubles. Holds a set of unique primitive objects, such as ints or doubles.
@@ -492,4 +488,5 @@ private:
#pragma warning (pop) #pragma warning (pop)
#endif #endif
#endif // BEAST_SORTEDSET_H_INCLUDED #endif

View File

@@ -24,11 +24,6 @@
#ifndef BEAST_VARIANT_H_INCLUDED #ifndef BEAST_VARIANT_H_INCLUDED
#define BEAST_VARIANT_H_INCLUDED #define BEAST_VARIANT_H_INCLUDED
#include "../text/beast_Identifier.h"
#include "../streams/beast_OutputStream.h"
#include "../streams/beast_InputStream.h"
#include "../containers/beast_Array.h"
#ifndef DOXYGEN #ifndef DOXYGEN
class SharedObject; class SharedObject;
class DynamicObject; class DynamicObject;

View File

@@ -24,10 +24,6 @@
#ifndef BEAST_DIRECTORYITERATOR_H_INCLUDED #ifndef BEAST_DIRECTORYITERATOR_H_INCLUDED
#define BEAST_DIRECTORYITERATOR_H_INCLUDED #define BEAST_DIRECTORYITERATOR_H_INCLUDED
#include "beast_File.h"
#include "../memory/beast_ScopedPointer.h"
//============================================================================== //==============================================================================
/** /**
Searches through a the files in a directory, returning each file that is found. Searches through a the files in a directory, returning each file that is found.

View File

@@ -57,10 +57,6 @@ File::File (const File& other)
{ {
} }
File::~File() noexcept
{
}
File File::createFileWithoutCheckingPath (const String& path) noexcept File File::createFileWithoutCheckingPath (const String& path) noexcept
{ {
File f; File f;

View File

@@ -24,16 +24,6 @@
#ifndef BEAST_FILE_H_INCLUDED #ifndef BEAST_FILE_H_INCLUDED
#define BEAST_FILE_H_INCLUDED #define BEAST_FILE_H_INCLUDED
#include "../containers/beast_Array.h"
#include "../time/beast_Time.h"
#include "../text/beast_StringArray.h"
#include "../memory/beast_MemoryBlock.h"
#include "../memory/beast_ScopedPointer.h"
#include "../misc/beast_Result.h"
class FileInputStream;
class FileOutputStream;
//============================================================================== //==============================================================================
/** /**
Represents a local file or directory. Represents a local file or directory.
@@ -46,14 +36,14 @@ class FileOutputStream;
@see FileInputStream, FileOutputStream @see FileInputStream, FileOutputStream
*/ */
class BEAST_API File : LeakChecked <File> class BEAST_API File
{ {
public: public:
//============================================================================== //==============================================================================
/** Creates an (invalid) file object. /** Creates an (invalid) file object.
The file is initially set to an empty path, so getFullPath() will return The file is initially set to an empty path, so getFullPath() will return
an empty string, and comparing the file to File::nonexistent() will return an empty string, and comparing the file to File::nonexistent will return
true. true.
You can use its operator= method to point it at a proper file. You can use its operator= method to point it at a proper file.
@@ -70,13 +60,13 @@ public:
On the Mac/Linux, the path can include "~" notation for referring to On the Mac/Linux, the path can include "~" notation for referring to
user home directories. user home directories.
*/ */
File (const String& path); File (const String& absolutePath);
/** Creates a copy of another file object. */ /** Creates a copy of another file object. */
File (const File& other); File (const File&);
/** Destructor. */ /** Destructor. */
~File() noexcept; ~File() noexcept {}
/** Sets the file based on an absolute pathname. /** Sets the file based on an absolute pathname.
@@ -88,14 +78,14 @@ public:
On the Mac/Linux, the path can include "~" notation for referring to On the Mac/Linux, the path can include "~" notation for referring to
user home directories. user home directories.
*/ */
File& operator= (const String& newFilePath); File& operator= (const String& newAbsolutePath);
/** Copies from another file object. */ /** Copies from another file object. */
File& operator= (const File& otherFile); File& operator= (const File& otherFile);
#if BEAST_COMPILER_SUPPORTS_MOVE_SEMANTICS #if BEAST_COMPILER_SUPPORTS_MOVE_SEMANTICS
File (File&& otherFile) noexcept; File (File&&) noexcept;
File& operator= (File&& otherFile) noexcept; File& operator= (File&&) noexcept;
#endif #endif
//============================================================================== //==============================================================================
@@ -200,8 +190,7 @@ public:
@param extensionToTest the extension to look for - it doesn't matter whether or @param extensionToTest the extension to look for - it doesn't matter whether or
not this string has a dot at the start, so ".wav" and "wav" not this string has a dot at the start, so ".wav" and "wav"
will have the same effect. The comparison used is will have the same effect. To compare with multiple extensions, this
case-insensitve. To compare with multiple extensions, this
parameter can contain multiple strings, separated by semi-colons - parameter can contain multiple strings, separated by semi-colons -
so, for example: hasFileExtension (".jpeg;png;gif") would return so, for example: hasFileExtension (".jpeg;png;gif") would return
true if the file has any of those three extensions. true if the file has any of those three extensions.
@@ -323,13 +312,13 @@ public:
//============================================================================== //==============================================================================
/** Compares the pathnames for two files. */ /** Compares the pathnames for two files. */
bool operator== (const File& otherFile) const; bool operator== (const File&) const;
/** Compares the pathnames for two files. */ /** Compares the pathnames for two files. */
bool operator!= (const File& otherFile) const; bool operator!= (const File&) const;
/** Compares the pathnames for two files. */ /** Compares the pathnames for two files. */
bool operator< (const File& otherFile) const; bool operator< (const File&) const;
/** Compares the pathnames for two files. */ /** Compares the pathnames for two files. */
bool operator> (const File& otherFile) const; bool operator> (const File&) const;
//============================================================================== //==============================================================================
/** Checks whether a file can be created or written to. /** Checks whether a file can be created or written to.
@@ -767,6 +756,15 @@ public:
/** The folder that contains the user's desktop objects. */ /** The folder that contains the user's desktop objects. */
userDesktopDirectory, userDesktopDirectory,
/** The most likely place where a user might store their music files. */
userMusicDirectory,
/** The most likely place where a user might store their movie files. */
userMoviesDirectory,
/** The most likely place where a user might store their picture files. */
userPicturesDirectory,
/** The folder in which applications store their persistent user-specific settings. /** The folder in which applications store their persistent user-specific settings.
On Windows, this might be "\Documents and Settings\username\Application Data". On Windows, this might be "\Documents and Settings\username\Application Data".
On the Mac, it might be "~/Library". If you're going to store your settings in here, On the Mac, it might be "~/Library". If you're going to store your settings in here,
@@ -784,6 +782,13 @@ public:
*/ */
commonApplicationDataDirectory, commonApplicationDataDirectory,
/** A place to put documents which are shared by all users of the machine.
On Windows this may be somewhere like "C:\Users\Public\Documents", on OSX it
will be something like "/Users/Shared". Other OSes may have no such concept
though, so be careful.
*/
commonDocumentsDirectory,
/** The folder that should be used for temporary files. /** The folder that should be used for temporary files.
Always delete them when you're finished, to keep the user's computer tidy! Always delete them when you're finished, to keep the user's computer tidy!
*/ */
@@ -826,16 +831,7 @@ public:
So on windows, this would be something like "c:\program files", on the So on windows, this would be something like "c:\program files", on the
Mac "/Applications", or "/usr" on linux. Mac "/Applications", or "/usr" on linux.
*/ */
globalApplicationsDirectory, globalApplicationsDirectory
/** The most likely place where a user might store their music files. */
userMusicDirectory,
/** The most likely place where a user might store their movie files. */
userMoviesDirectory,
/** The most likely place where a user might store their picture files. */
userPicturesDirectory
}; };
/** Finds the location of a special type of file or directory, such as a home folder or /** Finds the location of a special type of file or directory, such as a home folder or
@@ -880,19 +876,20 @@ public:
static const String separatorString; static const String separatorString;
//============================================================================== //==============================================================================
/** Removes illegal characters from a filename. /** Returns a version of a filename with any illegal characters removed.
This will return a copy of the given string after removing characters This will return a copy of the given string after removing characters
that are not allowed in a legal filename, and possibly shortening the that are not allowed in a legal filename, and possibly shortening the
string if it's too long. string if it's too long.
Because this will remove slashes, don't use it on an absolute pathname. Because this will remove slashes, don't use it on an absolute pathname - use
createLegalPathName() for that.
@see createLegalPathName @see createLegalPathName
*/ */
static String createLegalFileName (const String& fileNameToFix); static String createLegalFileName (const String& fileNameToFix);
/** Removes illegal characters from a pathname. /** Returns a version of a path with any illegal characters removed.
Similar to createLegalFileName(), but this won't remove slashes, so can Similar to createLegalFileName(), but this won't remove slashes, so can
be used on a complete pathname. be used on a complete pathname.
@@ -912,7 +909,7 @@ public:
Best to avoid this unless you really know what you're doing. Best to avoid this unless you really know what you're doing.
*/ */
static File createFileWithoutCheckingPath (const String& path) noexcept; static File createFileWithoutCheckingPath (const String& absolutePath) noexcept;
/** Adds a separator character to the end of a path if it doesn't already have one. */ /** Adds a separator character to the end of a path if it doesn't already have one. */
static String addTrailingSeparator (const String& path); static String addTrailingSeparator (const String& path);
@@ -951,4 +948,5 @@ private:
bool setFileReadOnlyInternal (bool) const; bool setFileReadOnlyInternal (bool) const;
}; };
#endif // BEAST_FILE_H_INCLUDED #endif

View File

@@ -24,10 +24,6 @@
#ifndef BEAST_FILEINPUTSTREAM_H_INCLUDED #ifndef BEAST_FILEINPUTSTREAM_H_INCLUDED
#define BEAST_FILEINPUTSTREAM_H_INCLUDED #define BEAST_FILEINPUTSTREAM_H_INCLUDED
#include "beast_File.h"
#include "../streams/beast_InputStream.h"
//============================================================================== //==============================================================================
/** /**
An input stream that reads from a local file. An input stream that reads from a local file.

View File

@@ -24,9 +24,6 @@
#ifndef BEAST_FILEOUTPUTSTREAM_H_INCLUDED #ifndef BEAST_FILEOUTPUTSTREAM_H_INCLUDED
#define BEAST_FILEOUTPUTSTREAM_H_INCLUDED #define BEAST_FILEOUTPUTSTREAM_H_INCLUDED
#include "beast_File.h"
#include "../streams/beast_OutputStream.h"
//============================================================================== //==============================================================================
/** /**
An output stream that writes into a local file. An output stream that writes into a local file.

View File

@@ -24,10 +24,6 @@
#ifndef BEAST_FILESEARCHPATH_H_INCLUDED #ifndef BEAST_FILESEARCHPATH_H_INCLUDED
#define BEAST_FILESEARCHPATH_H_INCLUDED #define BEAST_FILESEARCHPATH_H_INCLUDED
#include "beast_File.h"
#include "../text/beast_StringArray.h"
//============================================================================== //==============================================================================
/** /**
Encapsulates a set of folders that make up a search path. Encapsulates a set of folders that make up a search path.

View File

@@ -24,7 +24,6 @@
#ifndef BEAST_MEMORYMAPPEDFILE_H_INCLUDED #ifndef BEAST_MEMORYMAPPEDFILE_H_INCLUDED
#define BEAST_MEMORYMAPPEDFILE_H_INCLUDED #define BEAST_MEMORYMAPPEDFILE_H_INCLUDED
#include "beast_File.h"
//============================================================================== //==============================================================================
/** /**

View File

@@ -20,8 +20,6 @@
#ifndef BEAST_RANDOMACCESSFILE_H_INCLUDED #ifndef BEAST_RANDOMACCESSFILE_H_INCLUDED
#define BEAST_RANDOMACCESSFILE_H_INCLUDED #define BEAST_RANDOMACCESSFILE_H_INCLUDED
#include "../misc/beast_Result.h"
/** Provides random access reading and writing to an operating system file. /** Provides random access reading and writing to an operating system file.
This class wraps the underlying native operating system routines for This class wraps the underlying native operating system routines for

View File

@@ -24,9 +24,6 @@
#ifndef BEAST_TEMPORARYFILE_H_INCLUDED #ifndef BEAST_TEMPORARYFILE_H_INCLUDED
#define BEAST_TEMPORARYFILE_H_INCLUDED #define BEAST_TEMPORARYFILE_H_INCLUDED
#include "beast_File.h"
//============================================================================== //==============================================================================
/** /**
Manages a temporary file, which will be deleted when this object is deleted. Manages a temporary file, which will be deleted when this object is deleted.

View File

@@ -311,7 +311,7 @@ private:
buffer.appendUTF8Char (c); buffer.appendUTF8Char (c);
} }
result = buffer.toString(); result = buffer.toUTF8 ();
return Result::ok(); return Result::ok();
} }
}; };
@@ -521,7 +521,7 @@ String JSON::toString (const var& data, const bool allOnOneLine)
{ {
MemoryOutputStream mo (1024); MemoryOutputStream mo (1024);
JSONFormatter::write (mo, data, 0, allOnOneLine); JSONFormatter::write (mo, data, 0, allOnOneLine);
return mo.toString(); return mo.toUTF8 ();
} }
void JSON::writeToStream (OutputStream& output, const var& data, const bool allOnOneLine) void JSON::writeToStream (OutputStream& output, const var& data, const bool allOnOneLine)

View File

@@ -24,13 +24,10 @@
#ifndef BEAST_JSON_H_INCLUDED #ifndef BEAST_JSON_H_INCLUDED
#define BEAST_JSON_H_INCLUDED #define BEAST_JSON_H_INCLUDED
#include "../misc/beast_Result.h"
#include "../containers/beast_Variant.h"
class InputStream; class InputStream;
class OutputStream; class OutputStream;
class File; class File;
//============================================================================== //==============================================================================
/** /**
Contains static methods for converting JSON-formatted text to and from var objects. Contains static methods for converting JSON-formatted text to and from var objects.

View File

@@ -24,11 +24,6 @@
#ifndef BEAST_FILELOGGER_H_INCLUDED #ifndef BEAST_FILELOGGER_H_INCLUDED
#define BEAST_FILELOGGER_H_INCLUDED #define BEAST_FILELOGGER_H_INCLUDED
#include "beast_Logger.h"
#include "../files/beast_File.h"
#include "../memory/beast_ScopedPointer.h"
//============================================================================== //==============================================================================
/** /**
A simple implementation of a Logger that writes to a file. A simple implementation of a Logger that writes to a file.

View File

@@ -24,9 +24,6 @@
#ifndef BEAST_LOGGER_H_INCLUDED #ifndef BEAST_LOGGER_H_INCLUDED
#define BEAST_LOGGER_H_INCLUDED #define BEAST_LOGGER_H_INCLUDED
#include "../text/beast_String.h"
//============================================================================== //==============================================================================
/** /**
Acts as an application-wide logging class. Acts as an application-wide logging class.

View File

@@ -951,7 +951,9 @@ String BigInteger::toString (const int base, const int minimumNumCharacters) con
void BigInteger::parseString (const String& text, const int base) void BigInteger::parseString (const String& text, const int base)
{ {
clear(); clear();
String::CharPointerType t (text.getCharPointer()); String::CharPointerType t (text.getCharPointer().findEndOfWhitespace ());
setNegative (*t == (beast_wchar) '-');
if (base == 2 || base == 8 || base == 16) if (base == 2 || base == 8 || base == 16)
{ {
@@ -992,8 +994,6 @@ void BigInteger::parseString (const String& text, const int base)
} }
} }
} }
setNegative (text.trimStart().startsWithChar ('-'));
} }
MemoryBlock BigInteger::toMemoryBlock() const MemoryBlock BigInteger::toMemoryBlock() const

View File

@@ -24,11 +24,6 @@
#ifndef BEAST_BIGINTEGER_H_INCLUDED #ifndef BEAST_BIGINTEGER_H_INCLUDED
#define BEAST_BIGINTEGER_H_INCLUDED #define BEAST_BIGINTEGER_H_INCLUDED
#include "../text/beast_String.h"
#include "../memory/beast_HeapBlock.h"
class MemoryBlock;
//============================================================================== //==============================================================================
/** /**
An arbitrarily large integer class. An arbitrarily large integer class.

View File

@@ -24,10 +24,6 @@
#ifndef BEAST_EXPRESSION_H_INCLUDED #ifndef BEAST_EXPRESSION_H_INCLUDED
#define BEAST_EXPRESSION_H_INCLUDED #define BEAST_EXPRESSION_H_INCLUDED
#include "../containers/beast_Array.h"
#include "../memory/beast_ScopedPointer.h"
//============================================================================== //==============================================================================
/** /**
A class for dynamically evaluating simple numeric expressions. A class for dynamically evaluating simple numeric expressions.

View File

@@ -24,9 +24,6 @@
#ifndef BEAST_RANDOM_H_INCLUDED #ifndef BEAST_RANDOM_H_INCLUDED
#define BEAST_RANDOM_H_INCLUDED #define BEAST_RANDOM_H_INCLUDED
#include "beast_BigInteger.h"
//============================================================================== //==============================================================================
/** /**
A random number generator. A random number generator.

View File

@@ -347,7 +347,8 @@ void MemoryBlock::loadFromHexString (const String& hex)
} }
//============================================================================== //==============================================================================
const char* const MemoryBlock::encodingTable = ".ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+";
static char const* const base64EncodingTable = ".ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+";
String MemoryBlock::toBase64Encoding() const String MemoryBlock::toBase64Encoding() const
{ {
@@ -362,7 +363,7 @@ String MemoryBlock::toBase64Encoding() const
d.write ('.'); d.write ('.');
for (size_t i = 0; i < numChars; ++i) for (size_t i = 0; i < numChars; ++i)
d.write ((beast_wchar) (uint8) encodingTable [getBitRange (i * 6, 6)]); d.write ((beast_wchar) (uint8) base64EncodingTable [getBitRange (i * 6, 6)]);
d.writeNull(); d.writeNull();
return destString; return destString;
@@ -391,7 +392,7 @@ bool MemoryBlock::fromBase64Encoding (const String& s)
for (int j = 0; j < 64; ++j) for (int j = 0; j < 64; ++j)
{ {
if (encodingTable[j] == c) if (base64EncodingTable[j] == c)
{ {
setBitRange ((size_t) pos, 6, j); setBitRange ((size_t) pos, 6, j);
pos += 6; pos += 6;

View File

@@ -24,10 +24,6 @@
#ifndef BEAST_MEMORYBLOCK_H_INCLUDED #ifndef BEAST_MEMORYBLOCK_H_INCLUDED
#define BEAST_MEMORYBLOCK_H_INCLUDED #define BEAST_MEMORYBLOCK_H_INCLUDED
#include "../text/beast_String.h"
#include "../memory/beast_HeapBlock.h"
//============================================================================== //==============================================================================
/** /**
A class to hold a resizable block of raw data. A class to hold a resizable block of raw data.
@@ -266,8 +262,7 @@ private:
//============================================================================== //==============================================================================
HeapBlock <char> data; HeapBlock <char> data;
size_t size; size_t size;
static const char* const encodingTable;
}; };
#endif
#endif // BEAST_MEMORYBLOCK_H_INCLUDED

View File

@@ -24,9 +24,6 @@
#ifndef BEAST_OPTIONALSCOPEDPOINTER_H_INCLUDED #ifndef BEAST_OPTIONALSCOPEDPOINTER_H_INCLUDED
#define BEAST_OPTIONALSCOPEDPOINTER_H_INCLUDED #define BEAST_OPTIONALSCOPEDPOINTER_H_INCLUDED
#include "beast_ScopedPointer.h"
//============================================================================== //==============================================================================
/** /**
Holds a pointer to an object which can optionally be deleted when this pointer Holds a pointer to an object which can optionally be deleted when this pointer

View File

@@ -24,8 +24,6 @@
#ifndef BEAST_RESULT_H_INCLUDED #ifndef BEAST_RESULT_H_INCLUDED
#define BEAST_RESULT_H_INCLUDED #define BEAST_RESULT_H_INCLUDED
#include "../text/beast_String.h"
/** Represents the 'success' or 'failure' of an operation, and holds an associated /** Represents the 'success' or 'failure' of an operation, and holds an associated
error message to describe the error when there's a failure. error message to describe the error when there's a failure.

View File

@@ -24,9 +24,6 @@
#ifndef BEAST_UUID_H_INCLUDED #ifndef BEAST_UUID_H_INCLUDED
#define BEAST_UUID_H_INCLUDED #define BEAST_UUID_H_INCLUDED
#include "../text/beast_String.h"
//============================================================================== //==============================================================================
/** /**
A universally unique 128-bit identifier. A universally unique 128-bit identifier.

View File

@@ -103,6 +103,7 @@ File File::getSpecialLocation (const SpecialLocationType type)
case userMoviesDirectory: case userMoviesDirectory:
case userPicturesDirectory: case userPicturesDirectory:
case userApplicationDataDirectory: case userApplicationDataDirectory:
case commonDocumentsDirectory:
case userDesktopDirectory: case userDesktopDirectory:
return File (android.appDataDir); return File (android.appDataDir);
@@ -113,7 +114,6 @@ File File::getSpecialLocation (const SpecialLocationType type)
return File ("/system/app"); return File ("/system/app");
case tempDirectory: case tempDirectory:
//return File (AndroidStatsHelpers::getSystemProperty ("java.io.tmpdir"));
return File (android.appDataDir).getChildFile (".temp"); return File (android.appDataDir).getChildFile (".temp");
case invokedExecutableFile: case invokedExecutableFile:

View File

@@ -162,12 +162,11 @@ File File::getSpecialLocation (const SpecialLocationType type)
{ {
const char* homeDir = getenv ("HOME"); const char* homeDir = getenv ("HOME");
if (homeDir == nullptr) if (const char* homeDir = getenv ("HOME"))
{ return File (CharPointer_UTF8 (homeDir));
struct passwd* const pw = getpwuid (getuid());
if (pw != nullptr) if (struct passwd* const pw = getpwuid (getuid()))
homeDir = pw->pw_dir; return File (CharPointer_UTF8 (pw->pw_dir));
}
return File (CharPointer_UTF8 (homeDir)); return File (CharPointer_UTF8 (homeDir));
} }
@@ -178,6 +177,7 @@ File File::getSpecialLocation (const SpecialLocationType type)
case userPicturesDirectory: return resolveXDGFolder ("XDG_PICTURES_DIR", "~"); case userPicturesDirectory: return resolveXDGFolder ("XDG_PICTURES_DIR", "~");
case userDesktopDirectory: return resolveXDGFolder ("XDG_DESKTOP_DIR", "~/Desktop"); case userDesktopDirectory: return resolveXDGFolder ("XDG_DESKTOP_DIR", "~/Desktop");
case userApplicationDataDirectory: return File ("~"); case userApplicationDataDirectory: return File ("~");
case commonDocumentsDirectory:
case commonApplicationDataDirectory: return File ("/var"); case commonApplicationDataDirectory: return File ("/var");
case globalApplicationsDirectory: return File ("/usr"); case globalApplicationsDirectory: return File ("/usr");

View File

@@ -208,6 +208,7 @@ File File::getSpecialLocation (const SpecialLocationType type)
case userPicturesDirectory: resultPath = "~/Pictures"; break; case userPicturesDirectory: resultPath = "~/Pictures"; break;
case userApplicationDataDirectory: resultPath = "~/Library"; break; case userApplicationDataDirectory: resultPath = "~/Library"; break;
case commonApplicationDataDirectory: resultPath = "/Library"; break; case commonApplicationDataDirectory: resultPath = "/Library"; break;
case commonDocumentsDirectory: resultPath = "/Users/Shared"; break;
case globalApplicationsDirectory: resultPath = "/Applications"; break; case globalApplicationsDirectory: resultPath = "/Applications"; break;
case invokedExecutableFile: case invokedExecutableFile:

View File

@@ -29,29 +29,14 @@ CriticalSection::CriticalSection() noexcept
#if ! BEAST_ANDROID #if ! BEAST_ANDROID
pthread_mutexattr_setprotocol (&atts, PTHREAD_PRIO_INHERIT); pthread_mutexattr_setprotocol (&atts, PTHREAD_PRIO_INHERIT);
#endif #endif
pthread_mutex_init (&internal, &atts); pthread_mutex_init (&mutex, &atts);
} pthread_mutexattr_destroy (&atts);
CriticalSection::~CriticalSection() noexcept
{
pthread_mutex_destroy (&internal);
}
void CriticalSection::enter() const noexcept
{
pthread_mutex_lock (&internal);
}
bool CriticalSection::tryEnter() const noexcept
{
return pthread_mutex_trylock (&internal) == 0;
}
void CriticalSection::exit() const noexcept
{
pthread_mutex_unlock (&internal);
} }
CriticalSection::~CriticalSection() noexcept { pthread_mutex_destroy (&mutex); }
void CriticalSection::enter() const noexcept { pthread_mutex_lock (&mutex); }
bool CriticalSection::tryEnter() const noexcept { return pthread_mutex_trylock (&mutex) == 0; }
void CriticalSection::exit() const noexcept { pthread_mutex_unlock (&mutex); }
//============================================================================== //==============================================================================
WaitableEvent::WaitableEvent (const bool useManualReset, bool initiallySignaled) noexcept WaitableEvent::WaitableEvent (const bool useManualReset, bool initiallySignaled) noexcept

View File

@@ -670,6 +670,7 @@ File BEAST_CALLTYPE File::getSpecialLocation (const SpecialLocationType type)
case userDesktopDirectory: csidlType = CSIDL_DESKTOP; break; case userDesktopDirectory: csidlType = CSIDL_DESKTOP; break;
case userApplicationDataDirectory: csidlType = CSIDL_APPDATA; break; case userApplicationDataDirectory: csidlType = CSIDL_APPDATA; break;
case commonApplicationDataDirectory: csidlType = CSIDL_COMMON_APPDATA; break; case commonApplicationDataDirectory: csidlType = CSIDL_COMMON_APPDATA; break;
case commonDocumentsDirectory: csidlType = CSIDL_COMMON_DOCUMENTS; break;
case globalApplicationsDirectory: csidlType = CSIDL_PROGRAM_FILES; break; case globalApplicationsDirectory: csidlType = CSIDL_PROGRAM_FILES; break;
case userMusicDirectory: csidlType = 0x0d; /*CSIDL_MYMUSIC*/ break; case userMusicDirectory: csidlType = 0x0d; /*CSIDL_MYMUSIC*/ break;
case userMoviesDirectory: csidlType = 0x0e; /*CSIDL_MYVIDEO*/ break; case userMoviesDirectory: csidlType = 0x0e; /*CSIDL_MYVIDEO*/ break;

View File

@@ -23,6 +23,13 @@
HWND beast_messageWindowHandle = 0; // (this is used by other parts of the codebase) HWND beast_messageWindowHandle = 0; // (this is used by other parts of the codebase)
void* getUser32Function (const char* functionName)
{
HMODULE module = GetModuleHandleA ("user32.dll");
bassert (module != 0);
return (void*) GetProcAddress (module, functionName);
}
//============================================================================== //==============================================================================
#if ! BEAST_USE_INTRINSICS #if ! BEAST_USE_INTRINSICS
// In newer compilers, the inline versions of these are used (in beast_Atomic.h), but in // In newer compilers, the inline versions of these are used (in beast_Atomic.h), but in
@@ -47,64 +54,37 @@ __int64 beast_InterlockedCompareExchange64 (volatile __int64* value, __int64 new
#endif #endif
//============================================================================== //==============================================================================
CriticalSection::CriticalSection() noexcept CriticalSection::CriticalSection() noexcept
{ {
// (just to check the MS haven't changed this structure and broken things...) // (just to check the MS haven't changed this structure and broken things...)
#if BEAST_VC7_OR_EARLIER #if BEAST_VC7_OR_EARLIER
static_bassert (sizeof (CRITICAL_SECTION) <= 24); static_bassert (sizeof (CRITICAL_SECTION) <= 24);
#else #else
static_bassert (sizeof (CRITICAL_SECTION) <= sizeof (internal)); static_bassert (sizeof (CRITICAL_SECTION) <= sizeof (section));
#endif #endif
InitializeCriticalSection ((CRITICAL_SECTION*) internal); InitializeCriticalSection ((CRITICAL_SECTION*) section);
} }
CriticalSection::~CriticalSection() noexcept CriticalSection::~CriticalSection() noexcept { DeleteCriticalSection ((CRITICAL_SECTION*) section); }
{ void CriticalSection::enter() const noexcept { EnterCriticalSection ((CRITICAL_SECTION*) section); }
DeleteCriticalSection ((CRITICAL_SECTION*) internal); bool CriticalSection::tryEnter() const noexcept { return TryEnterCriticalSection ((CRITICAL_SECTION*) section) != FALSE; }
} void CriticalSection::exit() const noexcept { LeaveCriticalSection ((CRITICAL_SECTION*) section); }
void CriticalSection::enter() const noexcept
{
EnterCriticalSection ((CRITICAL_SECTION*) internal);
}
bool CriticalSection::tryEnter() const noexcept
{
return TryEnterCriticalSection ((CRITICAL_SECTION*) internal) != FALSE;
}
void CriticalSection::exit() const noexcept
{
LeaveCriticalSection ((CRITICAL_SECTION*) internal);
}
//============================================================================== //==============================================================================
WaitableEvent::WaitableEvent (const bool manualReset, bool initiallySignaled) noexcept WaitableEvent::WaitableEvent (const bool manualReset, bool initiallySignaled) noexcept
: internal (CreateEvent (0, manualReset ? TRUE : FALSE, FALSE, 0)) : handle (CreateEvent (0, manualReset ? TRUE : FALSE, initiallySignaled ? TRUE : FALSE, 0)) {}
{
if (initiallySignaled)
signal ();
}
WaitableEvent::~WaitableEvent() noexcept WaitableEvent::~WaitableEvent() noexcept { CloseHandle (handle); }
{
CloseHandle (internal);
}
bool WaitableEvent::wait (const int timeOutMillisecs) const noexcept void WaitableEvent::signal() const noexcept { SetEvent (handle); }
{ void WaitableEvent::reset() const noexcept { ResetEvent (handle); }
return WaitForSingleObject (internal, (DWORD) timeOutMillisecs) == WAIT_OBJECT_0;
}
void WaitableEvent::signal() const noexcept bool WaitableEvent::wait (const int timeOutMs) const noexcept
{ {
SetEvent (internal); return WaitForSingleObject (handle, (DWORD) timeOutMs) == WAIT_OBJECT_0;
}
void WaitableEvent::reset() const noexcept
{
ResetEvent (internal);
} }
//============================================================================== //==============================================================================

View File

@@ -24,9 +24,6 @@
#ifndef BEAST_MACADDRESS_H_INCLUDED #ifndef BEAST_MACADDRESS_H_INCLUDED
#define BEAST_MACADDRESS_H_INCLUDED #define BEAST_MACADDRESS_H_INCLUDED
#include "../containers/beast_Array.h"
//============================================================================== //==============================================================================
/** /**
A wrapper for a streaming (TCP) socket. A wrapper for a streaming (TCP) socket.

View File

@@ -24,8 +24,6 @@
#ifndef BEAST_NAMEDPIPE_H_INCLUDED #ifndef BEAST_NAMEDPIPE_H_INCLUDED
#define BEAST_NAMEDPIPE_H_INCLUDED #define BEAST_NAMEDPIPE_H_INCLUDED
#include "../threads/beast_ReadWriteLock.h"
//============================================================================== //==============================================================================
/** /**
A cross-process pipe that can have data written to and read from it. A cross-process pipe that can have data written to and read from it.

View File

@@ -24,9 +24,6 @@
#ifndef BEAST_SOCKET_H_INCLUDED #ifndef BEAST_SOCKET_H_INCLUDED
#define BEAST_SOCKET_H_INCLUDED #define BEAST_SOCKET_H_INCLUDED
#include "../text/beast_String.h"
//============================================================================== //==============================================================================
/** /**
A wrapper for a streaming (TCP) socket. A wrapper for a streaming (TCP) socket.

View File

@@ -24,8 +24,6 @@
#ifndef BEAST_URL_H_INCLUDED #ifndef BEAST_URL_H_INCLUDED
#define BEAST_URL_H_INCLUDED #define BEAST_URL_H_INCLUDED
#include "../text/beast_StringPairArray.h"
#include "../files/beast_File.h"
class InputStream; class InputStream;
class XmlElement; class XmlElement;

View File

@@ -24,11 +24,6 @@
#ifndef BEAST_BUFFEREDINPUTSTREAM_H_INCLUDED #ifndef BEAST_BUFFEREDINPUTSTREAM_H_INCLUDED
#define BEAST_BUFFEREDINPUTSTREAM_H_INCLUDED #define BEAST_BUFFEREDINPUTSTREAM_H_INCLUDED
#include "beast_InputStream.h"
#include "../memory/beast_OptionalScopedPointer.h"
#include "../memory/beast_HeapBlock.h"
//============================================================================== //==============================================================================
/** Wraps another input stream, and reads from it using an intermediate buffer /** Wraps another input stream, and reads from it using an intermediate buffer

View File

@@ -24,10 +24,6 @@
#ifndef BEAST_FILEINPUTSOURCE_H_INCLUDED #ifndef BEAST_FILEINPUTSOURCE_H_INCLUDED
#define BEAST_FILEINPUTSOURCE_H_INCLUDED #define BEAST_FILEINPUTSOURCE_H_INCLUDED
#include "beast_InputSource.h"
#include "../files/beast_File.h"
//============================================================================== //==============================================================================
/** /**
A type of InputSource that represents a normal file. A type of InputSource that represents a normal file.

View File

@@ -24,8 +24,6 @@
#ifndef BEAST_INPUTSOURCE_H_INCLUDED #ifndef BEAST_INPUTSOURCE_H_INCLUDED
#define BEAST_INPUTSOURCE_H_INCLUDED #define BEAST_INPUTSOURCE_H_INCLUDED
#include "beast_InputStream.h"
//============================================================================== //==============================================================================
/** /**
A lightweight object that can create a stream to read some kind of resource. A lightweight object that can create a stream to read some kind of resource.

View File

@@ -192,7 +192,8 @@ String InputStream::readString()
} }
} }
return String::fromUTF8 (data, (int) i); return String (CharPointer_UTF8 (data),
CharPointer_UTF8 (data + i));
} }
String InputStream::readNextLine() String InputStream::readNextLine()

View File

@@ -24,10 +24,8 @@
#ifndef BEAST_INPUTSTREAM_H_INCLUDED #ifndef BEAST_INPUTSTREAM_H_INCLUDED
#define BEAST_INPUTSTREAM_H_INCLUDED #define BEAST_INPUTSTREAM_H_INCLUDED
#include "../text/beast_String.h"
class MemoryBlock; class MemoryBlock;
//============================================================================== //==============================================================================
/** The base class for streams that read data. /** The base class for streams that read data.

View File

@@ -24,10 +24,6 @@
#ifndef BEAST_MEMORYINPUTSTREAM_H_INCLUDED #ifndef BEAST_MEMORYINPUTSTREAM_H_INCLUDED
#define BEAST_MEMORYINPUTSTREAM_H_INCLUDED #define BEAST_MEMORYINPUTSTREAM_H_INCLUDED
#include "beast_InputStream.h"
#include "../memory/beast_HeapBlock.h"
//============================================================================== //==============================================================================
/** /**
Allows a block of data to be accessed as a stream. Allows a block of data to be accessed as a stream.

View File

@@ -24,10 +24,6 @@
#ifndef BEAST_MEMORYOUTPUTSTREAM_H_INCLUDED #ifndef BEAST_MEMORYOUTPUTSTREAM_H_INCLUDED
#define BEAST_MEMORYOUTPUTSTREAM_H_INCLUDED #define BEAST_MEMORYOUTPUTSTREAM_H_INCLUDED
#include "beast_OutputStream.h"
#include "../memory/beast_MemoryBlock.h"
#include "../memory/beast_ScopedPointer.h"
//============================================================================== //==============================================================================
/** /**
Writes data to an internal memory buffer, which grows as required. Writes data to an internal memory buffer, which grows as required.

View File

@@ -24,13 +24,10 @@
#ifndef BEAST_OUTPUTSTREAM_H_INCLUDED #ifndef BEAST_OUTPUTSTREAM_H_INCLUDED
#define BEAST_OUTPUTSTREAM_H_INCLUDED #define BEAST_OUTPUTSTREAM_H_INCLUDED
#include "../text/beast_String.h"
#include "../text/beast_NewLine.h"
class InputStream; class InputStream;
class MemoryBlock; class MemoryBlock;
class File; class File;
//============================================================================== //==============================================================================
/** /**
The base class for streams that write data to some kind of destination. The base class for streams that write data to some kind of destination.

View File

@@ -24,10 +24,6 @@
#ifndef BEAST_SUBREGIONSTREAM_H_INCLUDED #ifndef BEAST_SUBREGIONSTREAM_H_INCLUDED
#define BEAST_SUBREGIONSTREAM_H_INCLUDED #define BEAST_SUBREGIONSTREAM_H_INCLUDED
#include "beast_InputStream.h"
#include "../memory/beast_OptionalScopedPointer.h"
//============================================================================== //==============================================================================
/** Wraps another input stream, and reads from a specific part of it. /** Wraps another input stream, and reads from a specific part of it.

View File

@@ -478,6 +478,30 @@ public:
byteOrderMarkLE2 = 0xfe byteOrderMarkLE2 = 0xfe
}; };
/** Returns true if the first pair of bytes in this pointer are the UTF16 byte-order mark (big endian).
The pointer must not be null, and must contain at least two valid bytes.
*/
static bool isByteOrderMarkBigEndian (const void* possibleByteOrder) noexcept
{
bassert (possibleByteOrder != nullptr);
const uint8* const c = static_cast<const uint8*> (possibleByteOrder);
return c[0] == (uint8) byteOrderMarkBE1
&& c[1] == (uint8) byteOrderMarkBE2;
}
/** Returns true if the first pair of bytes in this pointer are the UTF16 byte-order mark (little endian).
The pointer must not be null, and must contain at least two valid bytes.
*/
static bool isByteOrderMarkLittleEndian (const void* possibleByteOrder) noexcept
{
bassert (possibleByteOrder != nullptr);
const uint8* const c = static_cast<const uint8*> (possibleByteOrder);
return c[0] == (uint8) byteOrderMarkLE1
&& c[1] == (uint8) byteOrderMarkLE2;
}
private: private:
CharType* data; CharType* data;
@@ -492,5 +516,4 @@ private:
} }
}; };
#endif // BEAST_CHARPOINTER_UTF16_H_INCLUDED #endif // BEAST_CHARPOINTER_UTF16_H_INCLUDED

View File

@@ -545,7 +545,7 @@ public:
return CharPointer_UTF8 (reinterpret_cast <Atomic<CharType*>&> (data).exchange (newValue.data)); return CharPointer_UTF8 (reinterpret_cast <Atomic<CharType*>&> (data).exchange (newValue.data));
} }
/** These values are the byte-order-mark (BOM) values for a UTF-8 stream. */ /** These values are the byte-order mark (BOM) values for a UTF-8 stream. */
enum enum
{ {
byteOrderMark1 = 0xef, byteOrderMark1 = 0xef,
@@ -553,8 +553,22 @@ public:
byteOrderMark3 = 0xbf byteOrderMark3 = 0xbf
}; };
/** Returns true if the first three bytes in this pointer are the UTF8 byte-order mark (BOM).
The pointer must not be null, and must point to at least 3 valid bytes.
*/
static bool isByteOrderMark (const void* possibleByteOrder) noexcept
{
bassert (possibleByteOrder != nullptr);
const uint8* const c = static_cast<const uint8*> (possibleByteOrder);
return c[0] == (uint8) byteOrderMark1
&& c[1] == (uint8) byteOrderMark2
&& c[2] == (uint8) byteOrderMark3;
}
private: private:
CharType* data; CharType* data;
}; };
#endif // BEAST_CHARPOINTER_UTF8_H_INCLUDED #endif

View File

@@ -24,9 +24,6 @@
#ifndef BEAST_LOCALISEDSTRINGS_H_INCLUDED #ifndef BEAST_LOCALISEDSTRINGS_H_INCLUDED
#define BEAST_LOCALISEDSTRINGS_H_INCLUDED #define BEAST_LOCALISEDSTRINGS_H_INCLUDED
#include "beast_StringPairArray.h"
#include "../files/beast_File.h"
//============================================================================== //==============================================================================
/** /**
Used to convert strings to localised foreign-language versions. Used to convert strings to localised foreign-language versions.

View File

@@ -481,6 +481,31 @@ void String::append (const String& textToAppend, size_t maxCharsToTake)
appendCharPointer (textToAppend.text, maxCharsToTake); appendCharPointer (textToAppend.text, maxCharsToTake);
} }
void String::appendCharPointer (const CharPointerType textToAppend)
{
appendCharPointer (textToAppend, textToAppend.findTerminatingNull());
}
void String::appendCharPointer (const CharPointerType startOfTextToAppend,
const CharPointerType endOfTextToAppend)
{
bassert (startOfTextToAppend.getAddress() != nullptr && endOfTextToAppend.getAddress() != nullptr);
const int extraBytesNeeded = getAddressDifference (endOfTextToAppend.getAddress(),
startOfTextToAppend.getAddress());
bassert (extraBytesNeeded >= 0);
if (extraBytesNeeded > 0)
{
const size_t byteOffsetOfNull = getByteOffsetOfEnd();
preallocateBytes (byteOffsetOfNull + (size_t) extraBytesNeeded);
CharPointerType::CharType* const newStringStart = addBytesToPointer (text.getAddress(), (int) byteOffsetOfNull);
memcpy (newStringStart, startOfTextToAppend.getAddress(), extraBytesNeeded);
CharPointerType (addBytesToPointer (newStringStart, extraBytesNeeded)).writeNull();
}
}
String& String::operator+= (const wchar_t* const t) String& String::operator+= (const wchar_t* const t)
{ {
appendCharPointer (castToCharPointer_wchar_t (t)); appendCharPointer (castToCharPointer_wchar_t (t));
@@ -1778,9 +1803,9 @@ int String::getHexValue32() const noexcept { return HexConverter<int> ::st
int64 String::getHexValue64() const noexcept { return HexConverter<int64>::stringToHex (text); } int64 String::getHexValue64() const noexcept { return HexConverter<int64>::stringToHex (text); }
//============================================================================== //==============================================================================
String String::createStringFromData (const void* const data_, const int size) String String::createStringFromData (const void* const unknownData, const int size)
{ {
const uint8* const data = static_cast <const uint8*> (data_); const uint8* const data = static_cast<const uint8*> (unknownData);
if (size <= 0 || data == nullptr) if (size <= 0 || data == nullptr)
return empty; return empty;
@@ -1788,17 +1813,16 @@ String String::createStringFromData (const void* const data_, const int size)
if (size == 1) if (size == 1)
return charToString ((beast_wchar) data[0]); return charToString ((beast_wchar) data[0]);
if ((data[0] == (uint8) CharPointer_UTF16::byteOrderMarkBE1 && data[1] == (uint8) CharPointer_UTF16::byteOrderMarkBE2) if (CharPointer_UTF16::isByteOrderMarkBigEndian (data)
|| (data[0] == (uint8) CharPointer_UTF16::byteOrderMarkLE1 && data[1] == (uint8) CharPointer_UTF16::byteOrderMarkLE2)) || CharPointer_UTF16::isByteOrderMarkLittleEndian (data))
{ {
const bool bigEndian = (data[0] == (uint8) CharPointer_UTF16::byteOrderMarkBE1);
const int numChars = size / 2 - 1; const int numChars = size / 2 - 1;
StringCreationHelper builder ((size_t) numChars); StringCreationHelper builder ((size_t) numChars);
const uint16* const src = (const uint16*) (data + 2); const uint16* const src = (const uint16*) (data + 2);
if (bigEndian) if (CharPointer_UTF16::isByteOrderMarkBigEndian (data))
{ {
for (int i = 0; i < numChars; ++i) for (int i = 0; i < numChars; ++i)
builder.write ((beast_wchar) ByteOrder::swapIfLittleEndian (src[i])); builder.write ((beast_wchar) ByteOrder::swapIfLittleEndian (src[i]));
@@ -1814,16 +1838,12 @@ String String::createStringFromData (const void* const data_, const int size)
} }
const uint8* start = data; const uint8* start = data;
const uint8* end = data + size;
if (size >= 3 if (size >= 3 && CharPointer_UTF8::isByteOrderMark (data))
&& data[0] == (uint8) CharPointer_UTF8::byteOrderMark1
&& data[1] == (uint8) CharPointer_UTF8::byteOrderMark2
&& data[2] == (uint8) CharPointer_UTF8::byteOrderMark3)
start += 3; start += 3;
return String (CharPointer_UTF8 ((const char*) start), return String (CharPointer_UTF8 ((const char*) start),
CharPointer_UTF8 ((const char*) end)); CharPointer_UTF8 ((const char*) (data + size)));
} }
//============================================================================== //==============================================================================

View File

@@ -200,6 +200,17 @@ public:
*/ */
void append (const String& textToAppend, size_t maxCharsToTake); void append (const String& textToAppend, size_t maxCharsToTake);
/** Appends a string to the end of this one.
@param startOfTextToAppend the start of the string to add. This must not be a nullptr
@param endOfTextToAppend the end of the string to add. This must not be a nullptr
*/
void appendCharPointer (const CharPointerType startOfTextToAppend,
const CharPointerType endOfTextToAppend);
/** Appends a string to the end of this one. */
void appendCharPointer (const CharPointerType textToAppend);
/** Appends a string to the end of this one. /** Appends a string to the end of this one.
@param textToAppend the string to add @param textToAppend the string to add

View File

@@ -24,10 +24,6 @@
#ifndef BEAST_STRINGARRAY_H_INCLUDED #ifndef BEAST_STRINGARRAY_H_INCLUDED
#define BEAST_STRINGARRAY_H_INCLUDED #define BEAST_STRINGARRAY_H_INCLUDED
#include "beast_String.h"
#include "../containers/beast_Array.h"
//============================================================================== //==============================================================================
/** /**
A special array for holding a list of strings. A special array for holding a list of strings.

View File

@@ -24,9 +24,6 @@
#ifndef BEAST_STRINGPAIRARRAY_H_INCLUDED #ifndef BEAST_STRINGPAIRARRAY_H_INCLUDED
#define BEAST_STRINGPAIRARRAY_H_INCLUDED #define BEAST_STRINGPAIRARRAY_H_INCLUDED
#include "beast_StringArray.h"
//============================================================================== //==============================================================================
/** /**
A container for holding a set of strings which are keyed by another string. A container for holding a set of strings which are keyed by another string.

View File

@@ -24,10 +24,6 @@
#ifndef BEAST_STRINGPOOL_H_INCLUDED #ifndef BEAST_STRINGPOOL_H_INCLUDED
#define BEAST_STRINGPOOL_H_INCLUDED #define BEAST_STRINGPOOL_H_INCLUDED
#include "beast_String.h"
#include "../containers/beast_Array.h"
//============================================================================== //==============================================================================
/** /**
A StringPool holds a set of shared strings, which reduces storage overheads and improves A StringPool holds a set of shared strings, which reduces storage overheads and improves

View File

@@ -24,9 +24,6 @@
#ifndef BEAST_CRITICALSECTION_H_INCLUDED #ifndef BEAST_CRITICALSECTION_H_INCLUDED
#define BEAST_CRITICALSECTION_H_INCLUDED #define BEAST_CRITICALSECTION_H_INCLUDED
#include "beast_ScopedLock.h"
//============================================================================== //==============================================================================
/** /**
A re-entrant mutex. A re-entrant mutex.
@@ -114,20 +111,19 @@ public:
private: private:
//============================================================================== //==============================================================================
#if BEAST_WINDOWS #if BEAST_WINDOWS
// To avoid including windows.h in the public BEAST headers, we'll just allocate a // To avoid including windows.h in the public Beast headers, we'll just allocate
// block of memory here that's big enough to be used internally as a windows critical // a block of memory here that's big enough to be used internally as a windows
// section structure. // CRITICAL_SECTION structure.
#if BEAST_64BIT #if BEAST_64BIT
uint8 internal [44]; uint8 section[44];
#else #else
uint8 internal [24]; uint8 section[24];
#endif #endif
#else #else
mutable pthread_mutex_t internal; mutable pthread_mutex_t mutex;
#endif #endif
}; };
//============================================================================== //==============================================================================
/** /**
A class that can be used in place of a real CriticalSection object, but which A class that can be used in place of a real CriticalSection object, but which

View File

@@ -24,10 +24,6 @@
#ifndef BEAST_INTERPROCESSLOCK_H_INCLUDED #ifndef BEAST_INTERPROCESSLOCK_H_INCLUDED
#define BEAST_INTERPROCESSLOCK_H_INCLUDED #define BEAST_INTERPROCESSLOCK_H_INCLUDED
#include "../text/beast_String.h"
#include "../memory/beast_ScopedPointer.h"
//============================================================================== //==============================================================================
/** /**
Acts as a critical section which processes can use to block each other. Acts as a critical section which processes can use to block each other.

View File

@@ -24,9 +24,6 @@
#ifndef BEAST_PROCESS_H_INCLUDED #ifndef BEAST_PROCESS_H_INCLUDED
#define BEAST_PROCESS_H_INCLUDED #define BEAST_PROCESS_H_INCLUDED
#include "../text/beast_String.h"
//============================================================================== //==============================================================================
/** Represents the current executable's process. /** Represents the current executable's process.

View File

@@ -24,13 +24,6 @@
#ifndef BEAST_READWRITELOCK_H_INCLUDED #ifndef BEAST_READWRITELOCK_H_INCLUDED
#define BEAST_READWRITELOCK_H_INCLUDED #define BEAST_READWRITELOCK_H_INCLUDED
#include "beast_CriticalSection.h"
#include "beast_SpinLock.h"
#include "beast_WaitableEvent.h"
#include "beast_Thread.h"
#include "../containers/beast_Array.h"
//============================================================================== //==============================================================================
/** /**
A critical section that allows multiple simultaneous readers. A critical section that allows multiple simultaneous readers.

View File

@@ -24,9 +24,6 @@
#ifndef BEAST_SCOPEDREADLOCK_H_INCLUDED #ifndef BEAST_SCOPEDREADLOCK_H_INCLUDED
#define BEAST_SCOPEDREADLOCK_H_INCLUDED #define BEAST_SCOPEDREADLOCK_H_INCLUDED
#include "beast_ReadWriteLock.h"
//============================================================================== //==============================================================================
/** /**
Automatically locks and unlocks a ReadWriteLock object. Automatically locks and unlocks a ReadWriteLock object.

View File

@@ -24,9 +24,6 @@
#ifndef BEAST_SCOPEDWRITELOCK_H_INCLUDED #ifndef BEAST_SCOPEDWRITELOCK_H_INCLUDED
#define BEAST_SCOPEDWRITELOCK_H_INCLUDED #define BEAST_SCOPEDWRITELOCK_H_INCLUDED
#include "beast_ReadWriteLock.h"
//============================================================================== //==============================================================================
/** /**
Automatically locks and unlocks a ReadWriteLock object. Automatically locks and unlocks a ReadWriteLock object.

View File

@@ -24,9 +24,6 @@
#ifndef BEAST_SPINLOCK_H_INCLUDED #ifndef BEAST_SPINLOCK_H_INCLUDED
#define BEAST_SPINLOCK_H_INCLUDED #define BEAST_SPINLOCK_H_INCLUDED
#include "beast_ScopedLock.h"
//============================================================================== //==============================================================================
/** /**
A simple spin-lock class that can be used as a simple, low-overhead mutex for A simple spin-lock class that can be used as a simple, low-overhead mutex for

View File

@@ -24,10 +24,6 @@
#ifndef BEAST_THREAD_H_INCLUDED #ifndef BEAST_THREAD_H_INCLUDED
#define BEAST_THREAD_H_INCLUDED #define BEAST_THREAD_H_INCLUDED
#include "beast_WaitableEvent.h"
#include "beast_CriticalSection.h"
//============================================================================== //==============================================================================
/** /**
Encapsulates a thread. Encapsulates a thread.

View File

@@ -24,14 +24,9 @@
#ifndef BEAST_THREADPOOL_H_INCLUDED #ifndef BEAST_THREADPOOL_H_INCLUDED
#define BEAST_THREADPOOL_H_INCLUDED #define BEAST_THREADPOOL_H_INCLUDED
#include "beast_Thread.h"
#include "../text/beast_StringArray.h"
#include "../containers/beast_Array.h"
#include "../containers/beast_OwnedArray.h"
class ThreadPool; class ThreadPool;
class ThreadPoolThread; class ThreadPoolThread;
//============================================================================== //==============================================================================
/** /**
A task that is executed by a ThreadPool object. A task that is executed by a ThreadPool object.

View File

@@ -24,12 +24,8 @@
#ifndef BEAST_TIMESLICETHREAD_H_INCLUDED #ifndef BEAST_TIMESLICETHREAD_H_INCLUDED
#define BEAST_TIMESLICETHREAD_H_INCLUDED #define BEAST_TIMESLICETHREAD_H_INCLUDED
#include "beast_Thread.h"
#include "../containers/beast_Array.h"
#include "../time/beast_Time.h"
class TimeSliceThread; class TimeSliceThread;
//============================================================================== //==============================================================================
/** /**
Used by the TimeSliceThread class. Used by the TimeSliceThread class.

View File

@@ -24,9 +24,6 @@
#ifndef BEAST_WAITABLEEVENT_H_INCLUDED #ifndef BEAST_WAITABLEEVENT_H_INCLUDED
#define BEAST_WAITABLEEVENT_H_INCLUDED #define BEAST_WAITABLEEVENT_H_INCLUDED
#include "../text/beast_String.h"
//============================================================================== //==============================================================================
/** /**
Allows threads to wait for events triggered by other threads. Allows threads to wait for events triggered by other threads.
@@ -103,7 +100,7 @@ public:
private: private:
//============================================================================== //==============================================================================
#if BEAST_WINDOWS #if BEAST_WINDOWS
void* internal; void* handle;
#else #else
mutable pthread_cond_t condition; mutable pthread_cond_t condition;
mutable pthread_mutex_t mutex; mutable pthread_mutex_t mutex;

View File

@@ -24,9 +24,6 @@
#ifndef BEAST_PERFORMANCECOUNTER_H_INCLUDED #ifndef BEAST_PERFORMANCECOUNTER_H_INCLUDED
#define BEAST_PERFORMANCECOUNTER_H_INCLUDED #define BEAST_PERFORMANCECOUNTER_H_INCLUDED
#include "../files/beast_File.h"
//============================================================================== //==============================================================================
/** A timer for measuring performance of code and dumping the results to a file. /** A timer for measuring performance of code and dumping the results to a file.

View File

@@ -24,9 +24,6 @@
#ifndef BEAST_RELATIVETIME_H_INCLUDED #ifndef BEAST_RELATIVETIME_H_INCLUDED
#define BEAST_RELATIVETIME_H_INCLUDED #define BEAST_RELATIVETIME_H_INCLUDED
#include "../text/beast_String.h"
//============================================================================== //==============================================================================
/** A relative measure of time. /** A relative measure of time.

View File

@@ -24,9 +24,6 @@
#ifndef BEAST_TIME_H_INCLUDED #ifndef BEAST_TIME_H_INCLUDED
#define BEAST_TIME_H_INCLUDED #define BEAST_TIME_H_INCLUDED
#include "beast_RelativeTime.h"
//============================================================================== //==============================================================================
/** /**
Holds an absolute date and time. Holds an absolute date and time.

View File

@@ -24,12 +24,18 @@
XmlDocument::XmlDocument (const String& documentText) XmlDocument::XmlDocument (const String& documentText)
: originalText (documentText), : originalText (documentText),
input (nullptr), input (nullptr),
outOfData (false),
errorOccurred (false),
needToLoadDTD (false),
ignoreEmptyTextElements (true) ignoreEmptyTextElements (true)
{ {
} }
XmlDocument::XmlDocument (const File& file) XmlDocument::XmlDocument (const File& file)
: input (nullptr), : input (nullptr),
outOfData (false),
errorOccurred (false),
needToLoadDTD (false),
ignoreEmptyTextElements (true), ignoreEmptyTextElements (true),
inputSource (new FileInputSource (file)) inputSource (new FileInputSource (file))
{ {
@@ -77,7 +83,8 @@ namespace XmlIdentifierChars
: isIdentifierCharSlow (c); : isIdentifierCharSlow (c);
} }
/*static void generateIdentifierCharConstants() /*
static void generateIdentifierCharConstants()
{ {
uint32 n[8] = { 0 }; uint32 n[8] = { 0 };
for (int i = 0; i < 256; ++i) for (int i = 0; i < 256; ++i)
@@ -89,14 +96,21 @@ namespace XmlIdentifierChars
s << "0x" << String::toHexString ((int) n[i]) << ", "; s << "0x" << String::toHexString ((int) n[i]) << ", ";
DBG (s); DBG (s);
}*/ }
*/
static String::CharPointerType findEndOfToken (String::CharPointerType p)
{
while (isIdentifierChar (*p))
++p;
return p;
}
} }
XmlElement* XmlDocument::getDocumentElement (const bool onlyReadOuterDocumentElement) XmlElement* XmlDocument::getDocumentElement (const bool onlyReadOuterDocumentElement)
{ {
String textToParse (originalText); if (originalText.isEmpty() && inputSource != nullptr)
if (textToParse.isEmpty() && inputSource != nullptr)
{ {
ScopedPointer<InputStream> in (inputSource->createInputStream()); ScopedPointer<InputStream> in (inputSource->createInputStream());
@@ -104,41 +118,34 @@ XmlElement* XmlDocument::getDocumentElement (const bool onlyReadOuterDocumentEle
{ {
MemoryOutputStream data; MemoryOutputStream data;
data.writeFromInputStream (*in, onlyReadOuterDocumentElement ? 8192 : -1); data.writeFromInputStream (*in, onlyReadOuterDocumentElement ? 8192 : -1);
textToParse = data.toString();
if (! onlyReadOuterDocumentElement) #if BEAST_STRING_UTF_TYPE == 8
originalText = textToParse; if (data.getDataSize() > 2)
}
}
input = textToParse.getCharPointer();
lastError = String::empty;
errorOccurred = false;
outOfData = false;
needToLoadDTD = true;
if (textToParse.isEmpty())
{ {
lastError = "not enough input"; data.writeByte (0);
const char* text = static_cast<const char*> (data.getData());
if (CharPointer_UTF16::isByteOrderMarkBigEndian (text)
|| CharPointer_UTF16::isByteOrderMarkLittleEndian (text))
{
originalText = data.toString();
} }
else else
{ {
skipHeader(); if (CharPointer_UTF8::isByteOrderMark (text))
text += 3;
if (input.getAddress() != nullptr) // parse the input buffer directly to avoid copying it all to a string..
{ return parseDocumentElement (String::CharPointerType (text), onlyReadOuterDocumentElement);
ScopedPointer <XmlElement> result (readNextElement (! onlyReadOuterDocumentElement));
if (! errorOccurred)
return result.release();
} }
else }
{ #else
lastError = "incorrect xml header"; originalText = data.toString();
#endif
} }
} }
return nullptr; return parseDocumentElement (originalText.getCharPointer(), onlyReadOuterDocumentElement);
} }
const String& XmlDocument::getLastParseError() const noexcept const String& XmlDocument::getLastParseError() const noexcept
@@ -178,30 +185,53 @@ beast_wchar XmlDocument::readNextChar() noexcept
return c; return c;
} }
int XmlDocument::findNextTokenLength() noexcept XmlElement* XmlDocument::parseDocumentElement (String::CharPointerType textToParse,
const bool onlyReadOuterDocumentElement)
{ {
int len = 0; input = textToParse;
beast_wchar c = *input; errorOccurred = false;
outOfData = false;
needToLoadDTD = true;
while (XmlIdentifierChars::isIdentifierChar (c)) if (textToParse.isEmpty())
c = input [++len]; {
lastError = "not enough input";
}
else if (! parseHeader())
{
lastError = "malformed header";
}
else if (! parseDTD())
{
lastError = "malformed DTD";
}
else
{
lastError = String::empty;
return len; ScopedPointer<XmlElement> result (readNextElement (! onlyReadOuterDocumentElement));
if (! errorOccurred)
return result.release();
} }
void XmlDocument::skipHeader() return nullptr;
{ }
const int headerStart = input.indexOf (CharPointer_UTF8 ("<?xml"));
if (headerStart >= 0) bool XmlDocument::parseHeader()
{ {
const int headerEnd = (input + headerStart).indexOf (CharPointer_UTF8 ("?>")); skipNextWhiteSpace();
if (headerEnd < 0)
return; if (CharacterFunctions::compareUpTo (input, CharPointer_ASCII ("<?xml"), 5) == 0)
{
const String::CharPointerType headerEnd (CharacterFunctions::find (input, CharPointer_ASCII ("?>")));
if (headerEnd.isEmpty())
return false;
#if BEAST_DEBUG #if BEAST_DEBUG
const String header (input + headerStart, (size_t) (headerEnd - headerStart)); const String encoding (String (input, headerEnd)
const String encoding (header.fromFirstOccurrenceOf ("encoding", false, true) .fromFirstOccurrenceOf ("encoding", false, true)
.fromFirstOccurrenceOf ("=", false, false) .fromFirstOccurrenceOf ("=", false, false)
.fromFirstOccurrenceOf ("\"", false, false) .fromFirstOccurrenceOf ("\"", false, false)
.upToFirstOccurrenceOf ("\"", false, false).trim()); .upToFirstOccurrenceOf ("\"", false, false).trim());
@@ -216,26 +246,26 @@ void XmlDocument::skipHeader()
bassert (encoding.isEmpty() || encoding.startsWithIgnoreCase ("utf-")); bassert (encoding.isEmpty() || encoding.startsWithIgnoreCase ("utf-"));
#endif #endif
input += headerEnd + 2; input = headerEnd + 2;
skipNextWhiteSpace();
} }
skipNextWhiteSpace(); return true;
}
const int docTypeIndex = input.indexOf (CharPointer_UTF8 ("<!DOCTYPE")); bool XmlDocument::parseDTD()
if (docTypeIndex < 0) {
return; if (CharacterFunctions::compareUpTo (input, CharPointer_ASCII ("<!DOCTYPE"), 9) == 0)
{
input += 9;
const String::CharPointerType dtdStart (input);
input += docTypeIndex + 9; for (int n = 1; n > 0;)
const String::CharPointerType docType (input);
int n = 1;
while (n > 0)
{ {
const beast_wchar c = readNextChar(); const beast_wchar c = readNextChar();
if (outOfData) if (outOfData)
return; return false;
if (c == '<') if (c == '<')
++n; ++n;
@@ -243,31 +273,32 @@ void XmlDocument::skipHeader()
--n; --n;
} }
dtdText = String (docType, (size_t) (input.getAddress() - (docType.getAddress() + 1))).trim(); dtdText = String (dtdStart, input - 1).trim();
}
return true;
} }
void XmlDocument::skipNextWhiteSpace() void XmlDocument::skipNextWhiteSpace()
{ {
for (;;) for (;;)
{ {
beast_wchar c = *input; input = input.findEndOfWhitespace();
while (CharacterFunctions::isWhitespace (c)) if (input.isEmpty())
c = *++input;
if (c == 0)
{ {
outOfData = true; outOfData = true;
break; break;
} }
else if (c == '<')
if (*input == '<')
{ {
if (input[1] == '!' if (input[1] == '!'
&& input[2] == '-' && input[2] == '-'
&& input[3] == '-') && input[3] == '-')
{ {
input += 4; input += 4;
const int closeComment = input.indexOf (CharPointer_UTF8 ("-->")); const int closeComment = input.indexOf (CharPointer_ASCII ("-->"));
if (closeComment < 0) if (closeComment < 0)
{ {
@@ -278,10 +309,11 @@ void XmlDocument::skipNextWhiteSpace()
input += closeComment + 3; input += closeComment + 3;
continue; continue;
} }
else if (input[1] == '?')
if (input[1] == '?')
{ {
input += 2; input += 2;
const int closeBracket = input.indexOf (CharPointer_UTF8 ("?>")); const int closeBracket = input.indexOf (CharPointer_ASCII ("?>"));
if (closeBracket < 0) if (closeBracket < 0)
{ {
@@ -318,7 +350,6 @@ void XmlDocument::readQuotedString (String& result)
else else
{ {
const String::CharPointerType start (input); const String::CharPointerType start (input);
size_t numChars = 0;
for (;;) for (;;)
{ {
@@ -326,13 +357,13 @@ void XmlDocument::readQuotedString (String& result)
if (character == quote) if (character == quote)
{ {
result.appendCharPointer (start, numChars); result.appendCharPointer (start, input);
++input; ++input;
return; return;
} }
else if (character == '&') else if (character == '&')
{ {
result.appendCharPointer (start, numChars); result.appendCharPointer (start, input);
break; break;
} }
else if (character == 0) else if (character == 0)
@@ -343,7 +374,6 @@ void XmlDocument::readQuotedString (String& result)
} }
++input; ++input;
++numChars;
} }
} }
} }
@@ -357,28 +387,26 @@ XmlElement* XmlDocument::readNextElement (const bool alsoParseSubElements)
if (outOfData) if (outOfData)
return nullptr; return nullptr;
const int openBracket = input.indexOf ((beast_wchar) '<'); if (*input == '<')
if (openBracket >= 0)
{ {
input += openBracket + 1; ++input;
int tagLen = findNextTokenLength(); String::CharPointerType endOfToken (XmlIdentifierChars::findEndOfToken (input));
if (tagLen == 0) if (endOfToken == input)
{ {
// no tag name - but allow for a gap after the '<' before giving an error // no tag name - but allow for a gap after the '<' before giving an error
skipNextWhiteSpace(); skipNextWhiteSpace();
tagLen = findNextTokenLength(); endOfToken = XmlIdentifierChars::findEndOfToken (input);
if (tagLen == 0) if (endOfToken == input)
{ {
setLastError ("tag name missing", false); setLastError ("tag name missing", false);
return node; return node;
} }
} }
node = new XmlElement (String (input, (size_t) tagLen)); node = new XmlElement (String (input, endOfToken));
input += tagLen; input = endOfToken;
LinkedListPointer<XmlElement::XmlAttributeNode>::Appender attributeAppender (node->attributes); LinkedListPointer<XmlElement::XmlAttributeNode>::Appender attributeAppender (node->attributes);
// look for attributes // look for attributes
@@ -409,12 +437,12 @@ XmlElement* XmlDocument::readNextElement (const bool alsoParseSubElements)
// get an attribute.. // get an attribute..
if (XmlIdentifierChars::isIdentifierChar (c)) if (XmlIdentifierChars::isIdentifierChar (c))
{ {
const int attNameLen = findNextTokenLength(); String::CharPointerType attNameEnd (XmlIdentifierChars::findEndOfToken (input));
if (attNameLen > 0) if (attNameEnd != input)
{ {
const String::CharPointerType attNameStart (input); const String::CharPointerType attNameStart (input);
input += attNameLen; input = attNameEnd;
skipNextWhiteSpace(); skipNextWhiteSpace();
@@ -427,7 +455,7 @@ XmlElement* XmlDocument::readNextElement (const bool alsoParseSubElements)
if (nextChar == '"' || nextChar == '\'') if (nextChar == '"' || nextChar == '\'')
{ {
XmlElement::XmlAttributeNode* const newAtt XmlElement::XmlAttributeNode* const newAtt
= new XmlElement::XmlAttributeNode (String (attNameStart, (size_t) attNameLen), = new XmlElement::XmlAttributeNode (String (attNameStart, attNameEnd),
String::empty); String::empty);
readQuotedString (newAtt->value); readQuotedString (newAtt->value);
@@ -435,6 +463,12 @@ XmlElement* XmlDocument::readNextElement (const bool alsoParseSubElements)
continue; continue;
} }
} }
else
{
setLastError ("expected '=' after attribute '"
+ String (attNameStart, attNameEnd) + "'", false);
return node;
}
} }
} }
else else
@@ -467,7 +501,9 @@ void XmlDocument::readChildElements (XmlElement* parent)
if (*input == '<') if (*input == '<')
{ {
if (input[1] == '/') const beast_wchar c1 = input[1];
if (c1 == '/')
{ {
// our close tag.. // our close tag..
const int closeTag = input.indexOf ((beast_wchar) '>'); const int closeTag = input.indexOf ((beast_wchar) '>');
@@ -477,41 +513,33 @@ void XmlDocument::readChildElements (XmlElement* parent)
break; break;
} }
else if (input[1] == '!'
&& input[2] == '[' if (c1 == '!' && CharacterFunctions::compareUpTo (input + 2, CharPointer_ASCII ("[CDATA["), 7) == 0)
&& input[3] == 'C'
&& input[4] == 'D'
&& input[5] == 'A'
&& input[6] == 'T'
&& input[7] == 'A'
&& input[8] == '[')
{ {
input += 9; input += 9;
const String::CharPointerType inputStart (input); const String::CharPointerType inputStart (input);
size_t len = 0;
for (;;) for (;;)
{ {
if (*input == 0) const beast_wchar c0 = *input;
if (c0 == 0)
{ {
setLastError ("unterminated CDATA section", false); setLastError ("unterminated CDATA section", false);
outOfData = true; outOfData = true;
break; break;
} }
else if (input[0] == ']' else if (c0 == ']'
&& input[1] == ']' && input[1] == ']'
&& input[2] == '>') && input[2] == '>')
{ {
childAppender.append (XmlElement::createTextElement (String (inputStart, input)));
input += 3; input += 3;
break; break;
} }
++input; ++input;
++len;
} }
childAppender.append (XmlElement::createTextElement (String (inputStart, len)));
} }
else else
{ {
@@ -575,17 +603,15 @@ void XmlDocument::readChildElements (XmlElement* parent)
else else
{ {
const String::CharPointerType start (input); const String::CharPointerType start (input);
size_t len = 0;
for (;;) for (;;)
{ {
const beast_wchar nextChar = *input; const beast_wchar nextChar = *input;
if (nextChar == '<' || nextChar == '&') if (nextChar == '<' || nextChar == '&')
{
break; break;
}
else if (nextChar == 0) if (nextChar == 0)
{ {
setLastError ("unmatched tags", false); setLastError ("unmatched tags", false);
outOfData = true; outOfData = true;
@@ -593,47 +619,44 @@ void XmlDocument::readChildElements (XmlElement* parent)
} }
++input; ++input;
++len;
} }
textElementContent.appendCharPointer (start, len); textElementContent.appendCharPointer (start, input);
} }
} }
if ((! ignoreEmptyTextElements) || textElementContent.containsNonWhitespaceChars()) if ((! ignoreEmptyTextElements) || textElementContent.containsNonWhitespaceChars())
{
childAppender.append (XmlElement::createTextElement (textElementContent)); childAppender.append (XmlElement::createTextElement (textElementContent));
} }
} }
} }
}
void XmlDocument::readEntity (String& result) void XmlDocument::readEntity (String& result)
{ {
// skip over the ampersand // skip over the ampersand
++input; ++input;
if (input.compareIgnoreCaseUpTo (CharPointer_UTF8 ("amp;"), 4) == 0) if (input.compareIgnoreCaseUpTo (CharPointer_ASCII ("amp;"), 4) == 0)
{ {
input += 4; input += 4;
result += '&'; result += '&';
} }
else if (input.compareIgnoreCaseUpTo (CharPointer_UTF8 ("quot;"), 5) == 0) else if (input.compareIgnoreCaseUpTo (CharPointer_ASCII ("quot;"), 5) == 0)
{ {
input += 5; input += 5;
result += '"'; result += '"';
} }
else if (input.compareIgnoreCaseUpTo (CharPointer_UTF8 ("apos;"), 5) == 0) else if (input.compareIgnoreCaseUpTo (CharPointer_ASCII ("apos;"), 5) == 0)
{ {
input += 5; input += 5;
result += '\''; result += '\'';
} }
else if (input.compareIgnoreCaseUpTo (CharPointer_UTF8 ("lt;"), 3) == 0) else if (input.compareIgnoreCaseUpTo (CharPointer_ASCII ("lt;"), 3) == 0)
{ {
input += 3; input += 3;
result += '<'; result += '<';
} }
else if (input.compareIgnoreCaseUpTo (CharPointer_UTF8 ("gt;"), 3) == 0) else if (input.compareIgnoreCaseUpTo (CharPointer_ASCII ("gt;"), 3) == 0)
{ {
input += 3; input += 3;
result += '>'; result += '>';

View File

@@ -24,13 +24,6 @@
#ifndef BEAST_XMLDOCUMENT_H_INCLUDED #ifndef BEAST_XMLDOCUMENT_H_INCLUDED
#define BEAST_XMLDOCUMENT_H_INCLUDED #define BEAST_XMLDOCUMENT_H_INCLUDED
#include "beast_XmlElement.h"
#include "../text/beast_StringArray.h"
#include "../files/beast_File.h"
#include "../memory/beast_ScopedPointer.h"
class InputSource;
//============================================================================== //==============================================================================
/** /**
Parses a text-based XML document and creates an XmlElement object from it. Parses a text-based XML document and creates an XmlElement object from it.
@@ -150,6 +143,22 @@ public:
//============================================================================== //==============================================================================
private: private:
XmlElement* parseDocumentElement (String::CharPointerType, bool outer);
void setLastError (const String& desc, bool carryOn);
bool parseHeader();
bool parseDTD();
void skipNextWhiteSpace();
beast_wchar readNextChar() noexcept;
XmlElement* readNextElement (bool alsoParseSubElements);
void readChildElements (XmlElement* parent);
void readQuotedString (String& result);
void readEntity (String& result);
String getFileContents (const String& filename) const;
String expandEntity (const String& entity);
String expandExternalEntity (const String& entity);
String getParameterEntity (const String& entity);
String originalText; String originalText;
String::CharPointerType input; String::CharPointerType input;
bool outOfData, errorOccurred; bool outOfData, errorOccurred;
@@ -158,22 +167,7 @@ private:
StringArray tokenisedDTD; StringArray tokenisedDTD;
bool needToLoadDTD, ignoreEmptyTextElements; bool needToLoadDTD, ignoreEmptyTextElements;
ScopedPointer <InputSource> inputSource; ScopedPointer <InputSource> inputSource;
void setLastError (const String& desc, bool carryOn);
void skipHeader();
void skipNextWhiteSpace();
beast_wchar readNextChar() noexcept;
XmlElement* readNextElement (bool alsoParseSubElements);
void readChildElements (XmlElement* parent);
int findNextTokenLength() noexcept;
void readQuotedString (String& result);
void readEntity (String& result);
String getFileContents (const String& filename) const;
String expandEntity (const String& entity);
String expandExternalEntity (const String& entity);
String getParameterEntity (const String& entity);
}; };
#endif
#endif // BEAST_XMLDOCUMENT_H_INCLUDED

View File

@@ -465,10 +465,7 @@ bool XmlElement::getBoolAttribute (const String& attributeName, const bool defau
{ {
if (att->hasName (attributeName)) if (att->hasName (attributeName))
{ {
beast_wchar firstChar = att->value[0]; const beast_wchar firstChar = *(att->value.getCharPointer().findEndOfWhitespace());
if (CharacterFunctions::isWhitespace (firstChar))
firstChar = att->value.trimStart() [0];
return firstChar == '1' return firstChar == '1'
|| firstChar == 't' || firstChar == 't'
@@ -526,7 +523,7 @@ void XmlElement::setAttribute (const String& attributeName, const int number)
void XmlElement::setAttribute (const String& attributeName, const double number) void XmlElement::setAttribute (const String& attributeName, const double number)
{ {
setAttribute (attributeName, String (number)); setAttribute (attributeName, String (number, 20));
} }
void XmlElement::removeAttribute (const String& attributeName) noexcept void XmlElement::removeAttribute (const String& attributeName) noexcept
@@ -786,7 +783,7 @@ String XmlElement::getAllSubText() const
for (const XmlElement* child = firstChildElement; child != nullptr; child = child->nextListItem) for (const XmlElement* child = firstChildElement; child != nullptr; child = child->nextListItem)
mem << child->getAllSubText(); mem << child->getAllSubText();
return mem.toString(); return mem.toUTF8();
} }
String XmlElement::getChildElementAllSubText (const String& childTagName, String XmlElement::getChildElementAllSubText (const String& childTagName,

View File

@@ -24,12 +24,6 @@
#ifndef BEAST_XMLELEMENT_H_INCLUDED #ifndef BEAST_XMLELEMENT_H_INCLUDED
#define BEAST_XMLELEMENT_H_INCLUDED #define BEAST_XMLELEMENT_H_INCLUDED
#include "../text/beast_String.h"
#include "../streams/beast_OutputStream.h"
#include "../files/beast_File.h"
#include "../containers/beast_LinkedListPointer.h"
//============================================================================== //==============================================================================
/** A handy macro to make it easy to iterate all the child elements in an XmlElement. /** A handy macro to make it easy to iterate all the child elements in an XmlElement.

View File

@@ -29,11 +29,6 @@
#ifndef BEAST_GZIPCOMPRESSOROUTPUTSTREAM_H_INCLUDED #ifndef BEAST_GZIPCOMPRESSOROUTPUTSTREAM_H_INCLUDED
#define BEAST_GZIPCOMPRESSOROUTPUTSTREAM_H_INCLUDED #define BEAST_GZIPCOMPRESSOROUTPUTSTREAM_H_INCLUDED
#include "../streams/beast_OutputStream.h"
#include "../memory/beast_OptionalScopedPointer.h"
#include "../memory/beast_HeapBlock.h"
//============================================================================== //==============================================================================
/** /**
A stream which uses zlib to compress the data written into it. A stream which uses zlib to compress the data written into it.

View File

@@ -29,11 +29,6 @@
#ifndef BEAST_GZIPDECOMPRESSORINPUTSTREAM_H_INCLUDED #ifndef BEAST_GZIPDECOMPRESSORINPUTSTREAM_H_INCLUDED
#define BEAST_GZIPDECOMPRESSORINPUTSTREAM_H_INCLUDED #define BEAST_GZIPDECOMPRESSORINPUTSTREAM_H_INCLUDED
#include "../streams/beast_InputStream.h"
#include "../memory/beast_OptionalScopedPointer.h"
#include "../memory/beast_HeapBlock.h"
//============================================================================== //==============================================================================
/** /**
This stream will decompress a source-stream using zlib. This stream will decompress a source-stream using zlib.

View File

@@ -29,12 +29,6 @@
#ifndef BEAST_ZIPFILE_H_INCLUDED #ifndef BEAST_ZIPFILE_H_INCLUDED
#define BEAST_ZIPFILE_H_INCLUDED #define BEAST_ZIPFILE_H_INCLUDED
#include "../files/beast_File.h"
#include "../streams/beast_InputSource.h"
#include "../threads/beast_CriticalSection.h"
#include "../containers/beast_OwnedArray.h"
//============================================================================== //==============================================================================
/** /**
Decodes a ZIP file from a stream. Decodes a ZIP file from a stream.

View File

@@ -96,7 +96,7 @@ struct type_conversion <Time>
{ {
if (ind == i_null) if (ind == i_null)
{ {
// jassertfalse // bassertfalse
result = Time(0); result = Time(0);
} }
else else

View File

@@ -68,7 +68,7 @@ const Error sqliteError(const char* sourceFileName,
int sqliteErrorCode) int sqliteErrorCode)
{ {
/* /*
jassert (sqliteErrorCode != SQLITE_ROW && bassert (sqliteErrorCode != SQLITE_ROW &&
sqliteErrorCode != SQLITE_DONE); sqliteErrorCode != SQLITE_DONE);
*/ */