juce_core.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352
  1. /*
  2. ==============================================================================
  3. This file is part of the juce_core module of the JUCE library.
  4. Copyright (c) 2015 - ROLI Ltd.
  5. Permission to use, copy, modify, and/or distribute this software for any purpose with
  6. or without fee is hereby granted, provided that the above copyright notice and this
  7. permission notice appear in all copies.
  8. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
  9. TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
  10. NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  11. DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
  12. IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  13. CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  14. ------------------------------------------------------------------------------
  15. NOTE! This permissive ISC license applies ONLY to files within the juce_core module!
  16. All other JUCE modules are covered by a dual GPL/commercial license, so if you are
  17. using any other modules, be sure to check that you also comply with their license.
  18. For more details, visit www.juce.com
  19. ==============================================================================
  20. */
  21. /*******************************************************************************
  22. The block below describes the properties of this module, and is read by
  23. the Projucer to automatically generate project code that uses it.
  24. For details about the syntax and how to create or use a module, see the
  25. JUCE Module Format.txt file.
  26. BEGIN_JUCE_MODULE_DECLARATION
  27. ID: juce_core
  28. vendor: juce
  29. version: 4.2.1
  30. name: JUCE core classes
  31. description: The essential set of basic JUCE classes, as required by all the other JUCE modules. Includes text, container, memory, threading and i/o functionality.
  32. website: http://www.juce.com/juce
  33. license: GPL/Commercial
  34. dependencies:
  35. OSXFrameworks: Cocoa IOKit
  36. iOSFrameworks: Foundation
  37. linuxLibs: rt dl pthread
  38. mingwLibs: uuid wsock32 wininet version ole32 ws2_32 oleaut32 imm32 comdlg32 shlwapi rpcrt4 winmm
  39. END_JUCE_MODULE_DECLARATION
  40. *******************************************************************************/
  41. #ifndef JUCE_CORE_H_INCLUDED
  42. #define JUCE_CORE_H_INCLUDED
  43. //==============================================================================
  44. #ifdef _MSC_VER
  45. #pragma warning (push)
  46. // Disable warnings for long class names, padding, and undefined preprocessor definitions.
  47. #pragma warning (disable: 4251 4786 4668 4820)
  48. #ifdef __INTEL_COMPILER
  49. #pragma warning (disable: 1125)
  50. #endif
  51. #endif
  52. #include "system/juce_TargetPlatform.h"
  53. //==============================================================================
  54. /** Config: JUCE_FORCE_DEBUG
  55. Normally, JUCE_DEBUG is set to 1 or 0 based on compiler and project settings,
  56. but if you define this value, you can override this to force it to be true or false.
  57. */
  58. #ifndef JUCE_FORCE_DEBUG
  59. //#define JUCE_FORCE_DEBUG 0
  60. #endif
  61. //==============================================================================
  62. /** Config: JUCE_LOG_ASSERTIONS
  63. If this flag is enabled, the jassert and jassertfalse macros will always use Logger::writeToLog()
  64. to write a message when an assertion happens.
  65. Enabling it will also leave this turned on in release builds. When it's disabled,
  66. however, the jassert and jassertfalse macros will not be compiled in a
  67. release build.
  68. @see jassert, jassertfalse, Logger
  69. */
  70. #ifndef JUCE_LOG_ASSERTIONS
  71. #if JUCE_ANDROID
  72. #define JUCE_LOG_ASSERTIONS 1
  73. #else
  74. #define JUCE_LOG_ASSERTIONS 0
  75. #endif
  76. #endif
  77. //==============================================================================
  78. /** Config: JUCE_CHECK_MEMORY_LEAKS
  79. Enables a memory-leak check for certain objects when the app terminates. See the LeakedObjectDetector
  80. class and the JUCE_LEAK_DETECTOR macro for more details about enabling leak checking for specific classes.
  81. */
  82. #if JUCE_DEBUG && ! defined (JUCE_CHECK_MEMORY_LEAKS)
  83. #define JUCE_CHECK_MEMORY_LEAKS 1
  84. #endif
  85. //==============================================================================
  86. /** Config: JUCE_DONT_AUTOLINK_TO_WIN32_LIBRARIES
  87. In a Visual C++ build, this can be used to stop the required system libs being
  88. automatically added to the link stage.
  89. */
  90. #ifndef JUCE_DONT_AUTOLINK_TO_WIN32_LIBRARIES
  91. #define JUCE_DONT_AUTOLINK_TO_WIN32_LIBRARIES 0
  92. #endif
  93. /** Config: JUCE_INCLUDE_ZLIB_CODE
  94. This can be used to disable Juce's embedded 3rd-party zlib code.
  95. You might need to tweak this if you're linking to an external zlib library in your app,
  96. but for normal apps, this option should be left alone.
  97. If you disable this, you might also want to set a value for JUCE_ZLIB_INCLUDE_PATH, to
  98. specify the path where your zlib headers live.
  99. */
  100. #ifndef JUCE_INCLUDE_ZLIB_CODE
  101. #define JUCE_INCLUDE_ZLIB_CODE 1
  102. #endif
  103. #ifndef JUCE_ZLIB_INCLUDE_PATH
  104. #define JUCE_ZLIB_INCLUDE_PATH <zlib.h>
  105. #endif
  106. /** Config: JUCE_USE_CURL
  107. Enables http/https support via libcurl (Linux only). Enabling this will add an additional
  108. run-time dynmic dependency to libcurl.
  109. If you disable this then https/ssl support will not be available on linux.
  110. */
  111. #ifndef JUCE_USE_CURL
  112. #define JUCE_USE_CURL 0
  113. #endif
  114. /* Config: JUCE_CATCH_UNHANDLED_EXCEPTIONS
  115. If enabled, this will add some exception-catching code to forward unhandled exceptions
  116. to your JUCEApplicationBase::unhandledException() callback.
  117. */
  118. #ifndef JUCE_CATCH_UNHANDLED_EXCEPTIONS
  119. //#define JUCE_CATCH_UNHANDLED_EXCEPTIONS 1
  120. #endif
  121. #ifndef JUCE_STRING_UTF_TYPE
  122. #define JUCE_STRING_UTF_TYPE 8
  123. #endif
  124. //==============================================================================
  125. //==============================================================================
  126. #if JUCE_CORE_INCLUDE_NATIVE_HEADERS
  127. #include "native/juce_BasicNativeHeaders.h"
  128. #endif
  129. #include "system/juce_StandardHeader.h"
  130. namespace juce
  131. {
  132. class StringRef;
  133. class MemoryBlock;
  134. class File;
  135. class InputStream;
  136. class OutputStream;
  137. class DynamicObject;
  138. class FileInputStream;
  139. class FileOutputStream;
  140. class XmlElement;
  141. class JSONFormatter;
  142. extern JUCE_API bool JUCE_CALLTYPE juce_isRunningUnderDebugger() noexcept;
  143. extern JUCE_API void JUCE_CALLTYPE logAssertion (const char* file, int line) noexcept;
  144. #include "memory/juce_Memory.h"
  145. #include "maths/juce_MathsFunctions.h"
  146. #include "memory/juce_ByteOrder.h"
  147. #include "memory/juce_Atomic.h"
  148. #include "text/juce_CharacterFunctions.h"
  149. #if JUCE_MSVC
  150. #pragma warning (push)
  151. #pragma warning (disable: 4514 4996)
  152. #endif
  153. #include "text/juce_CharPointer_UTF8.h"
  154. #include "text/juce_CharPointer_UTF16.h"
  155. #include "text/juce_CharPointer_UTF32.h"
  156. #include "text/juce_CharPointer_ASCII.h"
  157. #if JUCE_MSVC
  158. #pragma warning (pop)
  159. #endif
  160. #include "text/juce_String.h"
  161. #include "text/juce_StringRef.h"
  162. #include "logging/juce_Logger.h"
  163. #include "memory/juce_LeakedObjectDetector.h"
  164. #include "memory/juce_ContainerDeletePolicy.h"
  165. #include "memory/juce_HeapBlock.h"
  166. #include "memory/juce_MemoryBlock.h"
  167. #include "memory/juce_ReferenceCountedObject.h"
  168. #include "memory/juce_ScopedPointer.h"
  169. #include "memory/juce_OptionalScopedPointer.h"
  170. #include "memory/juce_Singleton.h"
  171. #include "memory/juce_WeakReference.h"
  172. #include "threads/juce_ScopedLock.h"
  173. #include "threads/juce_CriticalSection.h"
  174. #include "maths/juce_Range.h"
  175. #include "maths/juce_NormalisableRange.h"
  176. #include "maths/juce_StatisticsAccumulator.h"
  177. #include "containers/juce_ElementComparator.h"
  178. #include "containers/juce_ArrayAllocationBase.h"
  179. #include "containers/juce_Array.h"
  180. #include "containers/juce_LinkedListPointer.h"
  181. #include "containers/juce_ListenerList.h"
  182. #include "containers/juce_OwnedArray.h"
  183. #include "containers/juce_ReferenceCountedArray.h"
  184. #include "containers/juce_ScopedValueSetter.h"
  185. #include "containers/juce_SortedSet.h"
  186. #include "containers/juce_SparseSet.h"
  187. #include "containers/juce_AbstractFifo.h"
  188. #include "text/juce_NewLine.h"
  189. #include "text/juce_StringPool.h"
  190. #include "text/juce_Identifier.h"
  191. #include "text/juce_StringArray.h"
  192. #include "text/juce_StringPairArray.h"
  193. #include "text/juce_TextDiff.h"
  194. #include "text/juce_LocalisedStrings.h"
  195. #include "text/juce_Base64.h"
  196. #include "misc/juce_Result.h"
  197. #include "containers/juce_Variant.h"
  198. #include "containers/juce_NamedValueSet.h"
  199. #include "containers/juce_DynamicObject.h"
  200. #include "containers/juce_HashMap.h"
  201. #include "time/juce_RelativeTime.h"
  202. #include "time/juce_Time.h"
  203. #include "streams/juce_InputStream.h"
  204. #include "streams/juce_OutputStream.h"
  205. #include "streams/juce_BufferedInputStream.h"
  206. #include "streams/juce_MemoryInputStream.h"
  207. #include "streams/juce_MemoryOutputStream.h"
  208. #include "streams/juce_SubregionStream.h"
  209. #include "streams/juce_InputSource.h"
  210. #include "files/juce_File.h"
  211. #include "files/juce_DirectoryIterator.h"
  212. #include "files/juce_FileInputStream.h"
  213. #include "files/juce_FileOutputStream.h"
  214. #include "files/juce_FileSearchPath.h"
  215. #include "files/juce_MemoryMappedFile.h"
  216. #include "files/juce_TemporaryFile.h"
  217. #include "files/juce_FileFilter.h"
  218. #include "files/juce_WildcardFileFilter.h"
  219. #include "streams/juce_FileInputSource.h"
  220. #include "logging/juce_FileLogger.h"
  221. #include "javascript/juce_JSON.h"
  222. #include "javascript/juce_Javascript.h"
  223. #include "maths/juce_BigInteger.h"
  224. #include "maths/juce_Expression.h"
  225. #include "maths/juce_Random.h"
  226. #include "misc/juce_RuntimePermissions.h"
  227. #include "misc/juce_Uuid.h"
  228. #include "misc/juce_WindowsRegistry.h"
  229. #include "system/juce_SystemStats.h"
  230. #include "threads/juce_ChildProcess.h"
  231. #include "threads/juce_DynamicLibrary.h"
  232. #include "threads/juce_HighResolutionTimer.h"
  233. #include "threads/juce_InterProcessLock.h"
  234. #include "threads/juce_Process.h"
  235. #include "threads/juce_SpinLock.h"
  236. #include "threads/juce_WaitableEvent.h"
  237. #include "threads/juce_Thread.h"
  238. #include "threads/juce_ThreadLocalValue.h"
  239. #include "threads/juce_ThreadPool.h"
  240. #include "threads/juce_TimeSliceThread.h"
  241. #include "threads/juce_ReadWriteLock.h"
  242. #include "threads/juce_ScopedReadLock.h"
  243. #include "threads/juce_ScopedWriteLock.h"
  244. #include "network/juce_IPAddress.h"
  245. #include "network/juce_MACAddress.h"
  246. #include "network/juce_NamedPipe.h"
  247. #include "network/juce_Socket.h"
  248. #include "network/juce_URL.h"
  249. #include "time/juce_PerformanceCounter.h"
  250. #include "unit_tests/juce_UnitTest.h"
  251. #include "xml/juce_XmlDocument.h"
  252. #include "xml/juce_XmlElement.h"
  253. #include "zip/juce_GZIPCompressorOutputStream.h"
  254. #include "zip/juce_GZIPDecompressorInputStream.h"
  255. #include "zip/juce_ZipFile.h"
  256. #include "containers/juce_PropertySet.h"
  257. #include "memory/juce_SharedResourcePointer.h"
  258. #if JUCE_CORE_INCLUDE_OBJC_HELPERS && (JUCE_MAC || JUCE_IOS)
  259. #include "native/juce_osx_ObjCHelpers.h"
  260. #endif
  261. #if JUCE_CORE_INCLUDE_COM_SMART_PTR && JUCE_WINDOWS
  262. #include "native/juce_win32_ComSmartPtr.h"
  263. #endif
  264. #if JUCE_CORE_INCLUDE_JNI_HELPERS && JUCE_ANDROID
  265. #include "native/juce_android_JNIHelpers.h"
  266. #endif
  267. #ifndef DOXYGEN
  268. /*
  269. As the very long class names here try to explain, the purpose of this code is to cause
  270. a linker error if not all of your compile units are consistent in the options that they
  271. enable before including JUCE headers. The reason this is important is that if you have
  272. two cpp files, and one includes the juce headers with debug enabled, and another does so
  273. without that, then each will be generating code with different class layouts, and you'll
  274. get subtle and hard-to-track-down memory corruption!
  275. */
  276. #if JUCE_DEBUG
  277. struct JUCE_API this_will_fail_to_link_if_some_of_your_compile_units_are_built_in_debug_mode
  278. { this_will_fail_to_link_if_some_of_your_compile_units_are_built_in_debug_mode() noexcept; };
  279. static this_will_fail_to_link_if_some_of_your_compile_units_are_built_in_debug_mode compileUnitMismatchSentinel;
  280. #else
  281. struct JUCE_API this_will_fail_to_link_if_some_of_your_compile_units_are_built_in_release_mode
  282. { this_will_fail_to_link_if_some_of_your_compile_units_are_built_in_release_mode() noexcept; };
  283. static this_will_fail_to_link_if_some_of_your_compile_units_are_built_in_release_mode compileUnitMismatchSentinel;
  284. #endif
  285. #endif
  286. }
  287. #if JUCE_MSVC
  288. #pragma warning (pop)
  289. // In DLL builds, need to disable this warnings for other modules
  290. #if defined (JUCE_DLL_BUILD) || defined (JUCE_DLL)
  291. #pragma warning (disable: 4251)
  292. #endif
  293. #endif
  294. #endif // JUCE_CORE_H_INCLUDED