fix macOS build (following Projucer changes made in Windows, which removed /Applications/JUCE/modules from its headers). move JUCE headers under source control, so that Windows and macOS can both build against same version of JUCE. remove AUv3 target (I think it's an iOS thing, so it will never work with this macOS fluidsynth dylib).
This commit is contained in:
80
modules/juce_core/misc/juce_Result.cpp
Normal file
80
modules/juce_core/misc/juce_Result.cpp
Normal file
@ -0,0 +1,80 @@
|
||||
/*
|
||||
==============================================================================
|
||||
|
||||
This file is part of the JUCE library.
|
||||
Copyright (c) 2017 - ROLI Ltd.
|
||||
|
||||
JUCE is an open source library subject to commercial or open-source
|
||||
licensing.
|
||||
|
||||
The code included in this file is provided under the terms of the ISC license
|
||||
http://www.isc.org/downloads/software-support-policy/isc-license. Permission
|
||||
To use, copy, modify, and/or distribute this software for any purpose with or
|
||||
without fee is hereby granted provided that the above copyright notice and
|
||||
this permission notice appear in all copies.
|
||||
|
||||
JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
|
||||
EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
|
||||
DISCLAIMED.
|
||||
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
namespace juce
|
||||
{
|
||||
|
||||
Result::Result() noexcept {}
|
||||
|
||||
Result::Result (const String& message) noexcept
|
||||
: errorMessage (message)
|
||||
{
|
||||
}
|
||||
|
||||
Result::Result (const Result& other)
|
||||
: errorMessage (other.errorMessage)
|
||||
{
|
||||
}
|
||||
|
||||
Result& Result::operator= (const Result& other)
|
||||
{
|
||||
errorMessage = other.errorMessage;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Result::Result (Result&& other) noexcept
|
||||
: errorMessage (static_cast<String&&> (other.errorMessage))
|
||||
{
|
||||
}
|
||||
|
||||
Result& Result::operator= (Result&& other) noexcept
|
||||
{
|
||||
errorMessage = static_cast<String&&> (other.errorMessage);
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool Result::operator== (const Result& other) const noexcept
|
||||
{
|
||||
return errorMessage == other.errorMessage;
|
||||
}
|
||||
|
||||
bool Result::operator!= (const Result& other) const noexcept
|
||||
{
|
||||
return errorMessage != other.errorMessage;
|
||||
}
|
||||
|
||||
Result Result::fail (const String& errorMessage) noexcept
|
||||
{
|
||||
return Result (errorMessage.isEmpty() ? "Unknown Error" : errorMessage);
|
||||
}
|
||||
|
||||
const String& Result::getErrorMessage() const noexcept
|
||||
{
|
||||
return errorMessage;
|
||||
}
|
||||
|
||||
bool Result::wasOk() const noexcept { return errorMessage.isEmpty(); }
|
||||
Result::operator bool() const noexcept { return errorMessage.isEmpty(); }
|
||||
bool Result::failed() const noexcept { return errorMessage.isNotEmpty(); }
|
||||
bool Result::operator!() const noexcept { return errorMessage.isNotEmpty(); }
|
||||
|
||||
} // namespace juce
|
116
modules/juce_core/misc/juce_Result.h
Normal file
116
modules/juce_core/misc/juce_Result.h
Normal file
@ -0,0 +1,116 @@
|
||||
/*
|
||||
==============================================================================
|
||||
|
||||
This file is part of the JUCE library.
|
||||
Copyright (c) 2017 - ROLI Ltd.
|
||||
|
||||
JUCE is an open source library subject to commercial or open-source
|
||||
licensing.
|
||||
|
||||
The code included in this file is provided under the terms of the ISC license
|
||||
http://www.isc.org/downloads/software-support-policy/isc-license. Permission
|
||||
To use, copy, modify, and/or distribute this software for any purpose with or
|
||||
without fee is hereby granted provided that the above copyright notice and
|
||||
this permission notice appear in all copies.
|
||||
|
||||
JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
|
||||
EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
|
||||
DISCLAIMED.
|
||||
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
namespace juce
|
||||
{
|
||||
|
||||
//==============================================================================
|
||||
/**
|
||||
Represents the 'success' or 'failure' of an operation, and holds an associated
|
||||
error message to describe the error when there's a failure.
|
||||
|
||||
E.g.
|
||||
@code
|
||||
Result myOperation()
|
||||
{
|
||||
if (doSomeKindOfFoobar())
|
||||
return Result::ok();
|
||||
else
|
||||
return Result::fail ("foobar didn't work!");
|
||||
}
|
||||
|
||||
const Result result (myOperation());
|
||||
|
||||
if (result.wasOk())
|
||||
{
|
||||
...it's all good...
|
||||
}
|
||||
else
|
||||
{
|
||||
warnUserAboutFailure ("The foobar operation failed! Error message was: "
|
||||
+ result.getErrorMessage());
|
||||
}
|
||||
@endcode
|
||||
|
||||
@tags{Core}
|
||||
*/
|
||||
class JUCE_API Result
|
||||
{
|
||||
public:
|
||||
//==============================================================================
|
||||
/** Creates and returns a 'successful' result. */
|
||||
static Result ok() noexcept { return Result(); }
|
||||
|
||||
/** Creates a 'failure' result.
|
||||
If you pass a blank error message in here, a default "Unknown Error" message
|
||||
will be used instead.
|
||||
*/
|
||||
static Result fail (const String& errorMessage) noexcept;
|
||||
|
||||
//==============================================================================
|
||||
/** Returns true if this result indicates a success. */
|
||||
bool wasOk() const noexcept;
|
||||
|
||||
/** Returns true if this result indicates a failure.
|
||||
You can use getErrorMessage() to retrieve the error message associated
|
||||
with the failure.
|
||||
*/
|
||||
bool failed() const noexcept;
|
||||
|
||||
/** Returns true if this result indicates a success.
|
||||
This is equivalent to calling wasOk().
|
||||
*/
|
||||
operator bool() const noexcept;
|
||||
|
||||
/** Returns true if this result indicates a failure.
|
||||
This is equivalent to calling failed().
|
||||
*/
|
||||
bool operator!() const noexcept;
|
||||
|
||||
/** Returns the error message that was set when this result was created.
|
||||
For a successful result, this will be an empty string;
|
||||
*/
|
||||
const String& getErrorMessage() const noexcept;
|
||||
|
||||
//==============================================================================
|
||||
Result (const Result&);
|
||||
Result& operator= (const Result&);
|
||||
Result (Result&&) noexcept;
|
||||
Result& operator= (Result&&) noexcept;
|
||||
|
||||
bool operator== (const Result& other) const noexcept;
|
||||
bool operator!= (const Result& other) const noexcept;
|
||||
|
||||
private:
|
||||
String errorMessage;
|
||||
|
||||
// The default constructor is not for public use!
|
||||
// Instead, use Result::ok() or Result::fail()
|
||||
Result() noexcept;
|
||||
explicit Result (const String&) noexcept;
|
||||
|
||||
// These casts are private to prevent people trying to use the Result object in numeric contexts
|
||||
operator int() const;
|
||||
operator void*() const;
|
||||
};
|
||||
|
||||
} // namespace juce
|
36
modules/juce_core/misc/juce_RuntimePermissions.cpp
Normal file
36
modules/juce_core/misc/juce_RuntimePermissions.cpp
Normal file
@ -0,0 +1,36 @@
|
||||
/*
|
||||
==============================================================================
|
||||
|
||||
This file is part of the JUCE library.
|
||||
Copyright (c) 2017 - ROLI Ltd.
|
||||
|
||||
JUCE is an open source library subject to commercial or open-source
|
||||
licensing.
|
||||
|
||||
The code included in this file is provided under the terms of the ISC license
|
||||
http://www.isc.org/downloads/software-support-policy/isc-license. Permission
|
||||
To use, copy, modify, and/or distribute this software for any purpose with or
|
||||
without fee is hereby granted provided that the above copyright notice and
|
||||
this permission notice appear in all copies.
|
||||
|
||||
JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
|
||||
EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
|
||||
DISCLAIMED.
|
||||
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
namespace juce
|
||||
{
|
||||
|
||||
#if ! JUCE_ANDROID // We currently don't request runtime permissions on any other platform
|
||||
// than Android, so this file contains a dummy implementation for those.
|
||||
// This may change in the future.
|
||||
|
||||
void RuntimePermissions::request (PermissionID, Callback callback) { callback (true); }
|
||||
bool RuntimePermissions::isRequired (PermissionID) { return false; }
|
||||
bool RuntimePermissions::isGranted (PermissionID) { return true; }
|
||||
|
||||
#endif
|
||||
|
||||
} // namespace juce
|
131
modules/juce_core/misc/juce_RuntimePermissions.h
Normal file
131
modules/juce_core/misc/juce_RuntimePermissions.h
Normal file
@ -0,0 +1,131 @@
|
||||
/*
|
||||
==============================================================================
|
||||
|
||||
This file is part of the JUCE library.
|
||||
Copyright (c) 2017 - ROLI Ltd.
|
||||
|
||||
JUCE is an open source library subject to commercial or open-source
|
||||
licensing.
|
||||
|
||||
The code included in this file is provided under the terms of the ISC license
|
||||
http://www.isc.org/downloads/software-support-policy/isc-license. Permission
|
||||
To use, copy, modify, and/or distribute this software for any purpose with or
|
||||
without fee is hereby granted provided that the above copyright notice and
|
||||
this permission notice appear in all copies.
|
||||
|
||||
JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
|
||||
EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
|
||||
DISCLAIMED.
|
||||
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
namespace juce
|
||||
{
|
||||
|
||||
//==============================================================================
|
||||
/**
|
||||
Class to handle app runtime permissions for certain functionality on some platforms.
|
||||
|
||||
The use of this class is currently only required if the app should run on
|
||||
Android API level 23 and higher.
|
||||
|
||||
On lower API levels, the permissions are specified in the app manifest. On iOS,
|
||||
runtime permission requests are handled automatically by the Apple APIs and not
|
||||
manually in the app code. On Windows, OS X, and Linux, runtime permissions are not
|
||||
used at all. In all these cases, request() will simply call through to the
|
||||
callback with no overhead and pass true (making it safe to use on all platforms).
|
||||
|
||||
For example, to enable audio recording on Android in your cross-platform app,
|
||||
you could modify your code as follows:
|
||||
|
||||
Old code:
|
||||
|
||||
audioDeviceManager.initialise (2, 2, nullptr, true, String(), nullptr);
|
||||
|
||||
New code:
|
||||
|
||||
RuntimePermissions::request (
|
||||
RuntimePermissions::audioRecording,
|
||||
[this] (bool wasGranted)
|
||||
{
|
||||
if (! wasGranted)
|
||||
{
|
||||
// e.g. display an error or initialise with 0 input channels
|
||||
return;
|
||||
}
|
||||
|
||||
audioDeviceManager.initialise (2, 2, nullptr, true, String(), nullptr);
|
||||
}
|
||||
);
|
||||
|
||||
@tags{Core}
|
||||
*/
|
||||
class JUCE_API RuntimePermissions
|
||||
{
|
||||
public:
|
||||
//==============================================================================
|
||||
enum PermissionID
|
||||
{
|
||||
/** Permission to access the microphone (required on Android).
|
||||
You need to request this, for example, to initialise an AudioDeviceManager with
|
||||
a non-zero number of input channels, and to open the default audio input device.
|
||||
*/
|
||||
recordAudio = 1,
|
||||
|
||||
/** Permission to scan for and pair to Bluetooth MIDI devices (required on Android).
|
||||
You need to request this before calling BluetoothMidiDevicePairingDialogue::open(),
|
||||
otherwise no devices will be found.
|
||||
*/
|
||||
bluetoothMidi = 2,
|
||||
|
||||
/** Permission to read from external storage such as SD cards */
|
||||
readExternalStorage = 3,
|
||||
|
||||
/** Permission to write to external storage such as SD cards */
|
||||
writeExternalStorage = 4,
|
||||
|
||||
/** Permission to use camera */
|
||||
camera = 5
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
/** Function type of runtime permission request callbacks. */
|
||||
typedef std::function<void (bool)> Callback;
|
||||
|
||||
//==============================================================================
|
||||
/** Call this method to request a runtime permission.
|
||||
|
||||
@param permission The PermissionID of the permission you want to request.
|
||||
|
||||
@param callback The callback to be called after the request has been granted
|
||||
or denied; the argument passed will be true if the permission
|
||||
has been granted and false otherwise.
|
||||
|
||||
If no runtime request is required or possible to obtain the permission, the
|
||||
callback will be called immediately. The argument passed in will be true
|
||||
if the permission is granted or no permission is required on this platform,
|
||||
and false otherwise.
|
||||
|
||||
If a runtime request is required to obtain the permission, the callback
|
||||
will be called asynchronously after the OS has granted or denied the requested
|
||||
permission (typically by displaying a dialog box to the user and waiting until
|
||||
the user has responded).
|
||||
*/
|
||||
static void request (PermissionID permission, Callback callback);
|
||||
|
||||
/** Returns whether a runtime request is required to obtain the permission
|
||||
on the current platform.
|
||||
*/
|
||||
static bool isRequired (PermissionID permission);
|
||||
|
||||
/** Returns true if the app has been already granted this permission, either
|
||||
via a previous runtime request or otherwise, or no permission is necessary.
|
||||
|
||||
Note that this can be false even if isRequired returns false. In this case,
|
||||
the permission can not be obtained at all at runtime.
|
||||
*/
|
||||
static bool isGranted (PermissionID permission);
|
||||
};
|
||||
|
||||
} // namespace juce
|
259
modules/juce_core/misc/juce_StdFunctionCompat.cpp
Normal file
259
modules/juce_core/misc/juce_StdFunctionCompat.cpp
Normal file
@ -0,0 +1,259 @@
|
||||
/*
|
||||
==============================================================================
|
||||
|
||||
This file is part of the JUCE library.
|
||||
Copyright (c) 2017 - ROLI Ltd.
|
||||
|
||||
Permission is granted to use this software under the terms of the ISC license
|
||||
http://www.isc.org/downloads/software-support-policy/isc-license/
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH REGARD
|
||||
TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT,
|
||||
OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
|
||||
USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
||||
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
OF THIS SOFTWARE.
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
To release a closed-source product which uses other parts of JUCE not
|
||||
licensed under the ISC terms, commercial licenses are available: visit
|
||||
www.juce.com for more information.
|
||||
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
namespace juce
|
||||
{
|
||||
|
||||
#if JUCE_UNIT_TESTS
|
||||
|
||||
namespace FunctionTestsHelpers
|
||||
{
|
||||
static void incrementArgument (int& x) { x++; }
|
||||
static double multiply (double x, double a) noexcept { return a * x; }
|
||||
|
||||
struct BigData
|
||||
{
|
||||
BigData()
|
||||
{
|
||||
for (auto i = 0; i < bigDataSize; ++i)
|
||||
content[i] = i + 1;
|
||||
}
|
||||
|
||||
int sum() const
|
||||
{
|
||||
int result = 0;
|
||||
for (auto i = 0; i < bigDataSize; ++i)
|
||||
result += content[i];
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static const int bigDataSize = 32,
|
||||
bigDataSum = bigDataSize * (bigDataSize + 1) / 2;
|
||||
int content[bigDataSize];
|
||||
};
|
||||
|
||||
struct FunctionObject
|
||||
{
|
||||
FunctionObject() {}
|
||||
|
||||
FunctionObject (const FunctionObject& other)
|
||||
{
|
||||
bigData.reset (new BigData (*other.bigData));
|
||||
}
|
||||
|
||||
int operator()(int i) const { return bigData->sum() + i; }
|
||||
|
||||
std::unique_ptr<BigData> bigData { new BigData() };
|
||||
};
|
||||
}
|
||||
|
||||
class FunctionTests : public UnitTest
|
||||
{
|
||||
public:
|
||||
FunctionTests() : UnitTest ("Function", "Function") {}
|
||||
|
||||
void runTest() override
|
||||
{
|
||||
FunctionTestsHelpers::BigData bigData;
|
||||
|
||||
{
|
||||
beginTest ("Functions");
|
||||
|
||||
std::function<void(int&)> f1 (FunctionTestsHelpers::incrementArgument);
|
||||
|
||||
auto x = 0;
|
||||
f1 (x);
|
||||
expectEquals (x, 1);
|
||||
|
||||
std::function<double(double, double)> f2 (FunctionTestsHelpers::multiply);
|
||||
expectEquals (6.0, f2 (2.0, 3.0));
|
||||
|
||||
}
|
||||
|
||||
{
|
||||
beginTest ("Function objects");
|
||||
std::function<int(int)> f1 = FunctionTestsHelpers::FunctionObject();
|
||||
expectEquals (f1 (5), FunctionTestsHelpers::BigData::bigDataSum + 5);
|
||||
}
|
||||
|
||||
{
|
||||
beginTest ("Lambdas");
|
||||
|
||||
std::function<int()> fStack ([] { return 3; });
|
||||
expectEquals (fStack(), 3);
|
||||
|
||||
std::function<int()> fHeap ([=] { return bigData.sum(); });
|
||||
expectEquals (fHeap(), FunctionTestsHelpers::BigData::bigDataSum);
|
||||
}
|
||||
|
||||
{
|
||||
beginTest ("Boolean");
|
||||
|
||||
std::function<void(int&)> f1;
|
||||
|
||||
if (f1)
|
||||
expect (false);
|
||||
|
||||
std::function<int()> f2 ([]() { return 3; });
|
||||
|
||||
if (! f2)
|
||||
expect (false);
|
||||
}
|
||||
|
||||
std::function<int()> fEmpty;
|
||||
|
||||
std::function<int()> fStack ([] { return 3; });
|
||||
|
||||
std::function<int()> fHeap ([=] { return bigData.sum(); });
|
||||
|
||||
{
|
||||
beginTest ("copy constructor");
|
||||
|
||||
std::function<int()> f1 (fStack);
|
||||
expectEquals (f1(), 3);
|
||||
|
||||
std::function<int()> f2 (fHeap);
|
||||
expectEquals (f2(), FunctionTestsHelpers::BigData::bigDataSum);
|
||||
|
||||
std::function<int()> f3 (fEmpty);
|
||||
if (f3)
|
||||
expect (false);
|
||||
}
|
||||
|
||||
{
|
||||
beginTest ("assignment");
|
||||
|
||||
std::function<int()> f1;
|
||||
f1 = fStack;
|
||||
expectEquals (f1(), 3);
|
||||
|
||||
std::function<int()> f2;
|
||||
f2 = fHeap;
|
||||
expectEquals (f2(), FunctionTestsHelpers::BigData::bigDataSum);
|
||||
|
||||
f1 = fHeap;
|
||||
expectEquals (f1(), FunctionTestsHelpers::BigData::bigDataSum);
|
||||
|
||||
f2 = fStack;
|
||||
expectEquals (f2(), 3);
|
||||
|
||||
f1 = fEmpty;
|
||||
if (f1)
|
||||
expect (false);
|
||||
}
|
||||
|
||||
{
|
||||
beginTest ("move constructor");
|
||||
|
||||
std::unique_ptr<std::function<int()>> fStackTmp (new std::function<int()> (fStack));
|
||||
std::function<int()> f1 (static_cast<std::function<int()>&&> (*fStackTmp));
|
||||
|
||||
fStackTmp.reset();
|
||||
expectEquals (f1(), 3);
|
||||
|
||||
std::unique_ptr<std::function<int()>> fHeapTmp (new std::function<int()> (fHeap));
|
||||
std::function<int()> f2 (static_cast<std::function<int()>&&> (*fHeapTmp));
|
||||
if (*fHeapTmp)
|
||||
expect (false);
|
||||
|
||||
fHeapTmp.reset();
|
||||
expectEquals (f2(), FunctionTestsHelpers::BigData::bigDataSum);
|
||||
|
||||
std::unique_ptr<std::function<int()>> fEmptyTmp (new std::function<int()>());
|
||||
std::function<int()> f3 (static_cast<std::function<int()>&&> (*fEmptyTmp));
|
||||
fEmptyTmp.reset();
|
||||
if (f3)
|
||||
expect (false);
|
||||
}
|
||||
|
||||
{
|
||||
beginTest ("move assignment");
|
||||
|
||||
std::function<int()> f1 (fHeap);
|
||||
std::unique_ptr<std::function<int()>> fStackTmp (new std::function<int()> (fStack));
|
||||
f1 = static_cast<std::function<int()>&&> (*fStackTmp);
|
||||
|
||||
fStackTmp.reset();
|
||||
expectEquals (f1(), 3);
|
||||
|
||||
std::function<int()> f2 (fStack);
|
||||
std::unique_ptr<std::function<int()>> fHeapTmp (new std::function<int()> (fHeap));
|
||||
f2 = static_cast<std::function<int()>&&> (*fHeapTmp);
|
||||
if (*fHeapTmp)
|
||||
expect (false);
|
||||
|
||||
fHeapTmp.reset();
|
||||
expectEquals (f2(), FunctionTestsHelpers::BigData::bigDataSum);
|
||||
|
||||
std::function<int()> f3 (fHeap);
|
||||
std::unique_ptr<std::function<int()>> fEmptyTmp (new std::function<int()>());
|
||||
f3 = static_cast<std::function<int()>&&> (*fEmptyTmp);
|
||||
fEmptyTmp.reset();
|
||||
if (f3)
|
||||
expect (false);
|
||||
}
|
||||
|
||||
{
|
||||
beginTest ("nullptr");
|
||||
|
||||
std::function<int()> f1 (nullptr);
|
||||
if (f1)
|
||||
expect (false);
|
||||
|
||||
std::function<int()> f2 ([]() { return 11; });
|
||||
f2 = nullptr;
|
||||
if (f2)
|
||||
expect (false);
|
||||
}
|
||||
|
||||
{
|
||||
beginTest ("Swap");
|
||||
|
||||
std::function<int()> f1;
|
||||
std::function<int()> f2 (fStack);
|
||||
f2.swap (f1);
|
||||
expectEquals (f1(), 3);
|
||||
if (f2)
|
||||
expect (false);
|
||||
|
||||
std::function<int()> f3 (fHeap);
|
||||
f3.swap (f1);
|
||||
expectEquals (f3(), 3);
|
||||
expectEquals (f1(), FunctionTestsHelpers::BigData::bigDataSum);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
static FunctionTests functionTests;
|
||||
|
||||
#endif
|
||||
|
||||
} // namespace juce
|
210
modules/juce_core/misc/juce_StdFunctionCompat.h
Normal file
210
modules/juce_core/misc/juce_StdFunctionCompat.h
Normal file
@ -0,0 +1,210 @@
|
||||
/*
|
||||
==============================================================================
|
||||
|
||||
This file is part of the JUCE library.
|
||||
Copyright (c) 2017 - ROLI Ltd.
|
||||
|
||||
Permission is granted to use this software under the terms of the ISC license
|
||||
http://www.isc.org/downloads/software-support-policy/isc-license/
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH REGARD
|
||||
TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT,
|
||||
OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
|
||||
USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
||||
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
OF THIS SOFTWARE.
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
To release a closed-source product which uses other parts of JUCE not
|
||||
licensed under the ISC terms, commercial licenses are available: visit
|
||||
www.juce.com for more information.
|
||||
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
namespace std
|
||||
{
|
||||
/**
|
||||
This class provides an alternative to std::function that is compatible
|
||||
with OS X 10.6 and earlier. This will only be used in OS X versions 10.6
|
||||
and earlier and the Projucer live build.
|
||||
|
||||
@tags{Core}
|
||||
*/
|
||||
template <typename>
|
||||
class function;
|
||||
|
||||
#ifndef DOXYGEN
|
||||
template <typename Result, typename... Arguments>
|
||||
class function<Result (Arguments...)>
|
||||
{
|
||||
public:
|
||||
/** Creates an empty function. */
|
||||
function() noexcept {}
|
||||
|
||||
/** Creates an empty function. */
|
||||
function (decltype (nullptr)) noexcept {}
|
||||
|
||||
/** Creates a function targetting the provided Functor. */
|
||||
template <typename Functor>
|
||||
function (Functor f)
|
||||
{
|
||||
functorHolderHelper = getFunctorStorage (sizeof (FunctorHolder<Functor, Result, Arguments...>));
|
||||
new (functorHolderHelper) FunctorHolder<Functor, Result, Arguments...> (f);
|
||||
}
|
||||
|
||||
/** Copy constructor. */
|
||||
function (function const& other)
|
||||
{
|
||||
copy (other);
|
||||
}
|
||||
|
||||
/** Move constructor */
|
||||
function (function&& other)
|
||||
{
|
||||
move (other);
|
||||
}
|
||||
|
||||
/** Destructor. */
|
||||
~function()
|
||||
{
|
||||
release();
|
||||
}
|
||||
|
||||
/** Replaces the contents of this function with the contents of another. */
|
||||
function& operator= (function const& other)
|
||||
{
|
||||
release();
|
||||
copy (other);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
/** Moves the contents of another function into this one. */
|
||||
function& operator= (function&& other)
|
||||
{
|
||||
release();
|
||||
move (other);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
/** Allows conditional expressions to test if this function is empty. */
|
||||
explicit operator bool() const noexcept
|
||||
{
|
||||
return functorHolderHelper != nullptr;
|
||||
}
|
||||
|
||||
/** Swaps the contents of this function with another. After this operation the
|
||||
two functions will be pointing at each other's targets. */
|
||||
void swap (function& other)
|
||||
{
|
||||
function<Result (Arguments...)> tmp (*this);
|
||||
*this = other;
|
||||
other = tmp;
|
||||
}
|
||||
|
||||
/** Invokes the target of this function. */
|
||||
Result operator() (Arguments... args) const
|
||||
{
|
||||
return (*functorHolderHelper) (args...);
|
||||
}
|
||||
|
||||
bool operator== (decltype (nullptr)) const noexcept { return (functorHolderHelper == nullptr); }
|
||||
bool operator!= (decltype (nullptr)) const noexcept { return (functorHolderHelper != nullptr); }
|
||||
|
||||
private:
|
||||
//==============================================================================
|
||||
template <typename ReturnType, typename... Args>
|
||||
struct FunctorHolderBase
|
||||
{
|
||||
virtual ~FunctorHolderBase() {}
|
||||
virtual int getSize() const noexcept = 0;
|
||||
virtual void copy (void*) const = 0;
|
||||
virtual ReturnType operator()(Args...) = 0;
|
||||
};
|
||||
|
||||
template <typename Functor, typename ReturnType, typename... Args>
|
||||
struct FunctorHolder : FunctorHolderBase<Result, Arguments...>
|
||||
{
|
||||
FunctorHolder (Functor func) : f (func) {}
|
||||
|
||||
int getSize() const noexcept override final
|
||||
{
|
||||
return sizeof (*this);
|
||||
}
|
||||
|
||||
void copy (void* destination) const override final
|
||||
{
|
||||
new (destination) FunctorHolder (f);
|
||||
}
|
||||
|
||||
ReturnType operator()(Args... args) override final
|
||||
{
|
||||
return f (args...);
|
||||
}
|
||||
|
||||
Functor f;
|
||||
};
|
||||
|
||||
FunctorHolderBase<Result, Arguments...>* getFunctorStorage (int size)
|
||||
{
|
||||
return reinterpret_cast<FunctorHolderBase<Result, Arguments...>*>
|
||||
(size > functorHolderStackSize ? new char [static_cast<unsigned long> (size)]
|
||||
: &(stackFunctorStorage[0]));
|
||||
}
|
||||
|
||||
void copy (function const& other)
|
||||
{
|
||||
if (other.functorHolderHelper != nullptr)
|
||||
{
|
||||
functorHolderHelper = getFunctorStorage (other.functorHolderHelper->getSize());
|
||||
other.functorHolderHelper->copy (functorHolderHelper);
|
||||
}
|
||||
}
|
||||
|
||||
void move (function& other)
|
||||
{
|
||||
if (other.functorHolderHelper != nullptr)
|
||||
{
|
||||
if (other.functorHolderHelper->getSize() > functorHolderStackSize)
|
||||
{
|
||||
functorHolderHelper = other.functorHolderHelper;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::copy (other.stackFunctorStorage, other.stackFunctorStorage + functorHolderStackSize,
|
||||
stackFunctorStorage);
|
||||
functorHolderHelper = reinterpret_cast<FunctorHolderBase<Result, Arguments...>*> (&(stackFunctorStorage[0]));
|
||||
}
|
||||
|
||||
other.functorHolderHelper = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void release()
|
||||
{
|
||||
if (functorHolderHelper != nullptr)
|
||||
{
|
||||
if (functorHolderHelper->getSize() > functorHolderStackSize)
|
||||
delete[] reinterpret_cast<char*> (functorHolderHelper);
|
||||
else
|
||||
functorHolderHelper->~FunctorHolderBase<Result, Arguments...>();
|
||||
|
||||
functorHolderHelper = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
static const int functorHolderStackSize = 24;
|
||||
char stackFunctorStorage[functorHolderStackSize];
|
||||
|
||||
FunctorHolderBase<Result, Arguments...>* functorHolderHelper = nullptr;
|
||||
};
|
||||
#endif
|
||||
}
|
157
modules/juce_core/misc/juce_Uuid.cpp
Normal file
157
modules/juce_core/misc/juce_Uuid.cpp
Normal file
@ -0,0 +1,157 @@
|
||||
/*
|
||||
==============================================================================
|
||||
|
||||
This file is part of the JUCE library.
|
||||
Copyright (c) 2017 - ROLI Ltd.
|
||||
|
||||
JUCE is an open source library subject to commercial or open-source
|
||||
licensing.
|
||||
|
||||
The code included in this file is provided under the terms of the ISC license
|
||||
http://www.isc.org/downloads/software-support-policy/isc-license. Permission
|
||||
To use, copy, modify, and/or distribute this software for any purpose with or
|
||||
without fee is hereby granted provided that the above copyright notice and
|
||||
this permission notice appear in all copies.
|
||||
|
||||
JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
|
||||
EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
|
||||
DISCLAIMED.
|
||||
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
namespace juce
|
||||
{
|
||||
|
||||
Uuid::Uuid()
|
||||
{
|
||||
Random r;
|
||||
|
||||
for (size_t i = 0; i < sizeof (uuid); ++i)
|
||||
uuid[i] = (uint8) (r.nextInt (256));
|
||||
|
||||
// To make it RFC 4122 compliant, need to force a few bits...
|
||||
uuid[6] = (uuid[6] & 0x0f) | 0x40;
|
||||
uuid[8] = (uuid[8] & 0x3f) | 0x80;
|
||||
}
|
||||
|
||||
Uuid::~Uuid() noexcept {}
|
||||
|
||||
Uuid::Uuid (const Uuid& other) noexcept
|
||||
{
|
||||
memcpy (uuid, other.uuid, sizeof (uuid));
|
||||
}
|
||||
|
||||
Uuid& Uuid::operator= (const Uuid& other) noexcept
|
||||
{
|
||||
memcpy (uuid, other.uuid, sizeof (uuid));
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool Uuid::operator== (const Uuid& other) const noexcept { return memcmp (uuid, other.uuid, sizeof (uuid)) == 0; }
|
||||
bool Uuid::operator!= (const Uuid& other) const noexcept { return ! operator== (other); }
|
||||
|
||||
bool Uuid::operator< (const Uuid& other) const noexcept { return compare (other) < 0; }
|
||||
bool Uuid::operator> (const Uuid& other) const noexcept { return compare (other) > 0; }
|
||||
bool Uuid::operator<= (const Uuid& other) const noexcept { return compare (other) <= 0; }
|
||||
bool Uuid::operator>= (const Uuid& other) const noexcept { return compare (other) >= 0; }
|
||||
|
||||
int Uuid::compare (Uuid other) const noexcept
|
||||
{
|
||||
for (size_t i = 0; i < sizeof (uuid); ++i)
|
||||
if (int diff = uuid[i] - (int) other.uuid[i])
|
||||
return diff > 0 ? 1 : -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Uuid Uuid::null() noexcept
|
||||
{
|
||||
return Uuid ((const uint8*) nullptr);
|
||||
}
|
||||
|
||||
bool Uuid::isNull() const noexcept
|
||||
{
|
||||
for (auto i : uuid)
|
||||
if (i != 0)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
String Uuid::getHexRegion (int start, int length) const
|
||||
{
|
||||
return String::toHexString (uuid + start, length, 0);
|
||||
}
|
||||
|
||||
String Uuid::toString() const
|
||||
{
|
||||
return getHexRegion (0, 16);
|
||||
}
|
||||
|
||||
String Uuid::toDashedString() const
|
||||
{
|
||||
return getHexRegion (0, 4)
|
||||
+ "-" + getHexRegion (4, 2)
|
||||
+ "-" + getHexRegion (6, 2)
|
||||
+ "-" + getHexRegion (8, 2)
|
||||
+ "-" + getHexRegion (10, 6);
|
||||
}
|
||||
|
||||
Uuid::Uuid (const String& uuidString)
|
||||
{
|
||||
operator= (uuidString);
|
||||
}
|
||||
|
||||
Uuid& Uuid::operator= (const String& uuidString)
|
||||
{
|
||||
MemoryBlock mb;
|
||||
mb.loadFromHexString (uuidString);
|
||||
mb.ensureSize (sizeof (uuid), true);
|
||||
mb.copyTo (uuid, 0, sizeof (uuid));
|
||||
return *this;
|
||||
}
|
||||
|
||||
Uuid::Uuid (const uint8* const rawData) noexcept
|
||||
{
|
||||
operator= (rawData);
|
||||
}
|
||||
|
||||
Uuid& Uuid::operator= (const uint8* const rawData) noexcept
|
||||
{
|
||||
if (rawData != nullptr)
|
||||
memcpy (uuid, rawData, sizeof (uuid));
|
||||
else
|
||||
zeromem (uuid, sizeof (uuid));
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
uint32 Uuid::getTimeLow() const noexcept { return ByteOrder::bigEndianInt (uuid); }
|
||||
uint16 Uuid::getTimeMid() const noexcept { return ByteOrder::bigEndianShort (uuid + 4); }
|
||||
uint16 Uuid::getTimeHighAndVersion() const noexcept { return ByteOrder::bigEndianShort (uuid + 6); }
|
||||
uint8 Uuid::getClockSeqAndReserved() const noexcept { return uuid[8]; }
|
||||
uint8 Uuid::getClockSeqLow() const noexcept { return uuid[9]; }
|
||||
uint64 Uuid::getNode() const noexcept { return (((uint64) ByteOrder::bigEndianShort (uuid + 10)) << 32) + ByteOrder::bigEndianInt (uuid + 12); }
|
||||
|
||||
uint64 Uuid::hash() const noexcept
|
||||
{
|
||||
uint64 result = 0;
|
||||
|
||||
for (auto n : uuid)
|
||||
result = ((uint64) 101) * result + n;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
} // namespace juce
|
||||
|
||||
#if ! DOXYGEN
|
||||
namespace std
|
||||
{
|
||||
template <> struct hash<juce::Uuid>
|
||||
{
|
||||
size_t operator() (const juce::Uuid& u) const noexcept { return (size_t) u.hash(); }
|
||||
};
|
||||
}
|
||||
#endif
|
137
modules/juce_core/misc/juce_Uuid.h
Normal file
137
modules/juce_core/misc/juce_Uuid.h
Normal file
@ -0,0 +1,137 @@
|
||||
/*
|
||||
==============================================================================
|
||||
|
||||
This file is part of the JUCE library.
|
||||
Copyright (c) 2017 - ROLI Ltd.
|
||||
|
||||
JUCE is an open source library subject to commercial or open-source
|
||||
licensing.
|
||||
|
||||
The code included in this file is provided under the terms of the ISC license
|
||||
http://www.isc.org/downloads/software-support-policy/isc-license. Permission
|
||||
To use, copy, modify, and/or distribute this software for any purpose with or
|
||||
without fee is hereby granted provided that the above copyright notice and
|
||||
this permission notice appear in all copies.
|
||||
|
||||
JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
|
||||
EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
|
||||
DISCLAIMED.
|
||||
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
namespace juce
|
||||
{
|
||||
|
||||
//==============================================================================
|
||||
/**
|
||||
A universally unique 128-bit identifier.
|
||||
|
||||
This class generates very random unique numbers. It's vanishingly unlikely
|
||||
that two identical UUIDs would ever be created by chance. The values are
|
||||
formatted to meet the RFC 4122 version 4 standard.
|
||||
|
||||
The class includes methods for saving the ID as a string or as raw binary data.
|
||||
|
||||
@tags{Core}
|
||||
*/
|
||||
class JUCE_API Uuid
|
||||
{
|
||||
public:
|
||||
//==============================================================================
|
||||
/** Creates a new unique ID, compliant with RFC 4122 version 4. */
|
||||
Uuid();
|
||||
|
||||
/** Destructor. */
|
||||
~Uuid() noexcept;
|
||||
|
||||
/** Creates a copy of another UUID. */
|
||||
Uuid (const Uuid&) noexcept;
|
||||
|
||||
/** Copies another UUID. */
|
||||
Uuid& operator= (const Uuid&) noexcept;
|
||||
|
||||
//==============================================================================
|
||||
/** Returns true if the ID is zero. */
|
||||
bool isNull() const noexcept;
|
||||
|
||||
/** Returns a null Uuid object. */
|
||||
static Uuid null() noexcept;
|
||||
|
||||
bool operator== (const Uuid&) const noexcept;
|
||||
bool operator!= (const Uuid&) const noexcept;
|
||||
bool operator< (const Uuid&) const noexcept;
|
||||
bool operator> (const Uuid&) const noexcept;
|
||||
bool operator<= (const Uuid&) const noexcept;
|
||||
bool operator>= (const Uuid&) const noexcept;
|
||||
|
||||
//==============================================================================
|
||||
/** Returns a stringified version of this UUID.
|
||||
|
||||
A Uuid object can later be reconstructed from this string using operator= or
|
||||
the constructor that takes a string parameter.
|
||||
|
||||
@returns a 32 character hex string.
|
||||
*/
|
||||
String toString() const;
|
||||
|
||||
/** Returns a stringified version of this UUID, separating it into sections with dashes.
|
||||
@returns a string in the format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
|
||||
*/
|
||||
String toDashedString() const;
|
||||
|
||||
/** Creates an ID from an encoded string version.
|
||||
@see toString
|
||||
*/
|
||||
Uuid (const String& uuidString);
|
||||
|
||||
/** Copies from a stringified UUID.
|
||||
The string passed in should be one that was created with the toString() method.
|
||||
*/
|
||||
Uuid& operator= (const String& uuidString);
|
||||
|
||||
|
||||
//==============================================================================
|
||||
/** Returns the time-low section of the UUID. */
|
||||
uint32 getTimeLow() const noexcept;
|
||||
/** Returns the time-mid section of the UUID. */
|
||||
uint16 getTimeMid() const noexcept;
|
||||
/** Returns the time-high-and-version section of the UUID. */
|
||||
uint16 getTimeHighAndVersion() const noexcept;
|
||||
/** Returns the clock-seq-and-reserved section of the UUID. */
|
||||
uint8 getClockSeqAndReserved() const noexcept;
|
||||
/** Returns the clock-seq-low section of the UUID. */
|
||||
uint8 getClockSeqLow() const noexcept;
|
||||
/** Returns the node section of the UUID. */
|
||||
uint64 getNode() const noexcept;
|
||||
|
||||
/** Returns a hash of the UUID. */
|
||||
uint64 hash() const noexcept;
|
||||
|
||||
//==============================================================================
|
||||
/** Returns a pointer to the internal binary representation of the ID.
|
||||
|
||||
This is an array of 16 bytes. To reconstruct a Uuid from its data, use
|
||||
the constructor or operator= method that takes an array of uint8s.
|
||||
*/
|
||||
const uint8* getRawData() const noexcept { return uuid; }
|
||||
|
||||
/** Creates a UUID from a 16-byte array.
|
||||
@see getRawData
|
||||
*/
|
||||
Uuid (const uint8* rawData) noexcept;
|
||||
|
||||
/** Sets this UUID from 16-bytes of raw data. */
|
||||
Uuid& operator= (const uint8* rawData) noexcept;
|
||||
|
||||
|
||||
private:
|
||||
//==============================================================================
|
||||
uint8 uuid[16];
|
||||
String getHexRegion (int, int) const;
|
||||
int compare (Uuid) const noexcept;
|
||||
|
||||
JUCE_LEAK_DETECTOR (Uuid)
|
||||
};
|
||||
|
||||
} // namespace juce
|
138
modules/juce_core/misc/juce_WindowsRegistry.h
Normal file
138
modules/juce_core/misc/juce_WindowsRegistry.h
Normal file
@ -0,0 +1,138 @@
|
||||
/*
|
||||
==============================================================================
|
||||
|
||||
This file is part of the JUCE library.
|
||||
Copyright (c) 2017 - ROLI Ltd.
|
||||
|
||||
JUCE is an open source library subject to commercial or open-source
|
||||
licensing.
|
||||
|
||||
The code included in this file is provided under the terms of the ISC license
|
||||
http://www.isc.org/downloads/software-support-policy/isc-license. Permission
|
||||
To use, copy, modify, and/or distribute this software for any purpose with or
|
||||
without fee is hereby granted provided that the above copyright notice and
|
||||
this permission notice appear in all copies.
|
||||
|
||||
JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
|
||||
EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
|
||||
DISCLAIMED.
|
||||
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
namespace juce
|
||||
{
|
||||
|
||||
#if JUCE_WINDOWS || DOXYGEN
|
||||
|
||||
/**
|
||||
Contains some static helper functions for manipulating the MS Windows registry
|
||||
(Only available on Windows, of course!)
|
||||
|
||||
@tags{Core}
|
||||
*/
|
||||
class JUCE_API WindowsRegistry
|
||||
{
|
||||
public:
|
||||
/** These values can be used to specify whether the 32- or 64-bit registry should be used.
|
||||
When running on a 32-bit OS, there is no 64-bit registry, so the mode will be ignored.
|
||||
*/
|
||||
enum WoW64Mode
|
||||
{
|
||||
/** Default handling: 32-bit apps will use the 32-bit registry, and 64-bit apps
|
||||
will use the 64-bit registry. */
|
||||
WoW64_Default = 0,
|
||||
|
||||
/** Always use the 64-bit registry store. (KEY_WOW64_64KEY). */
|
||||
WoW64_64bit = 0x100,
|
||||
|
||||
/** Always use the 32-bit registry store. (KEY_WOW64_32KEY). */
|
||||
WoW64_32bit = 0x200
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
/** Returns a string from the registry.
|
||||
The path is a string for the entire path of a value in the registry,
|
||||
e.g. "HKEY_CURRENT_USER\Software\foo\bar"
|
||||
*/
|
||||
static String JUCE_CALLTYPE getValue (const String& regValuePath,
|
||||
const String& defaultValue = String(),
|
||||
WoW64Mode mode = WoW64_Default);
|
||||
|
||||
/** Reads a binary block from the registry.
|
||||
The path is a string for the entire path of a value in the registry,
|
||||
e.g. "HKEY_CURRENT_USER\Software\foo\bar"
|
||||
@returns a DWORD indicating the type of the key.
|
||||
*/
|
||||
static uint32 JUCE_CALLTYPE getBinaryValue (const String& regValuePath, MemoryBlock& resultData, WoW64Mode mode = WoW64_Default);
|
||||
|
||||
/** Sets a registry value as a string.
|
||||
This will take care of creating any groups needed to get to the given registry value.
|
||||
*/
|
||||
static bool JUCE_CALLTYPE setValue (const String& regValuePath, const String& value, WoW64Mode mode = WoW64_Default);
|
||||
|
||||
/** Sets a registry value as a DWORD.
|
||||
This will take care of creating any groups needed to get to the given registry value.
|
||||
*/
|
||||
static bool JUCE_CALLTYPE setValue (const String& regValuePath, uint32 value, WoW64Mode mode = WoW64_Default);
|
||||
|
||||
/** Sets a registry value as a QWORD.
|
||||
This will take care of creating any groups needed to get to the given registry value.
|
||||
*/
|
||||
static bool JUCE_CALLTYPE setValue (const String& regValuePath, uint64 value, WoW64Mode mode = WoW64_Default);
|
||||
|
||||
/** Sets a registry value as a binary block.
|
||||
This will take care of creating any groups needed to get to the given registry value.
|
||||
*/
|
||||
static bool JUCE_CALLTYPE setValue (const String& regValuePath, const MemoryBlock& value, WoW64Mode mode = WoW64_Default);
|
||||
|
||||
/** Returns true if the given value exists in the registry. */
|
||||
static bool JUCE_CALLTYPE valueExists (const String& regValuePath, WoW64Mode mode = WoW64_Default);
|
||||
|
||||
/** Returns true if the given key exists in the registry. */
|
||||
static bool JUCE_CALLTYPE keyExists (const String& regValuePath, WoW64Mode mode = WoW64_Default);
|
||||
|
||||
/** Deletes a registry value. */
|
||||
static bool JUCE_CALLTYPE deleteValue (const String& regValuePath, WoW64Mode mode = WoW64_Default);
|
||||
|
||||
/** Deletes a registry key (which is registry-talk for 'folder'). */
|
||||
static bool JUCE_CALLTYPE deleteKey (const String& regKeyPath, WoW64Mode mode = WoW64_Default);
|
||||
|
||||
/** Creates a file association in the registry.
|
||||
|
||||
This lets you set the executable that should be launched by a given file extension.
|
||||
@param fileExtension the file extension to associate, including the
|
||||
initial dot, e.g. ".txt"
|
||||
@param symbolicDescription a space-free short token to identify the file type
|
||||
@param fullDescription a human-readable description of the file type
|
||||
@param targetExecutable the executable that should be launched
|
||||
@param iconResourceNumber the icon that gets displayed for the file type will be
|
||||
found by looking up this resource number in the
|
||||
executable. Pass 0 here to not use an icon
|
||||
@param registerForCurrentUserOnly if false, this will try to register the association
|
||||
for all users (you might not have permission to do this
|
||||
unless running in an installer). If true, it will register the
|
||||
association in HKEY_CURRENT_USER.
|
||||
@param mode the WoW64 mode to use for choosing the database
|
||||
*/
|
||||
static bool JUCE_CALLTYPE registerFileAssociation (const String& fileExtension,
|
||||
const String& symbolicDescription,
|
||||
const String& fullDescription,
|
||||
const File& targetExecutable,
|
||||
int iconResourceNumber,
|
||||
bool registerForCurrentUserOnly,
|
||||
WoW64Mode mode = WoW64_Default);
|
||||
|
||||
// DEPRECATED: use the other methods with a WoW64Mode parameter of WoW64_64bit instead.
|
||||
JUCE_DEPRECATED (static String getValueWow64 (const String&, const String& defaultValue = String()));
|
||||
JUCE_DEPRECATED (static bool valueExistsWow64 (const String&));
|
||||
JUCE_DEPRECATED (static bool keyExistsWow64 (const String&));
|
||||
|
||||
private:
|
||||
WindowsRegistry() = delete;
|
||||
JUCE_DECLARE_NON_COPYABLE (WindowsRegistry)
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
} // namespace juce
|
Reference in New Issue
Block a user