diff options
author | falkTX <falktx@gmail.com> | 2015-04-26 17:26:02 +0200 |
---|---|---|
committer | falkTX <falktx@gmail.com> | 2015-04-26 17:26:02 +0200 |
commit | 4f8b332b9411c5c54b241eaab5f6d13a85e8bcab (patch) | |
tree | e3785deae7518598fcce093744e87c18bf87ae20 | |
parent | c9d7b3e6f0ae68b9a3fc6f935172fca28ce80fb9 (diff) |
Rename some files
-rw-r--r-- | distrho/DistrhoPlugin.hpp | 2 | ||||
-rw-r--r-- | distrho/DistrhoUI.hpp | 2 | ||||
-rw-r--r-- | distrho/extra/Base64.hpp | 127 | ||||
-rw-r--r-- | distrho/extra/LeakDetector.hpp (renamed from distrho/extra/d_leakdetector.hpp) | 0 | ||||
-rw-r--r-- | distrho/extra/Mutex.hpp (renamed from distrho/extra/d_mutex.hpp) | 0 | ||||
-rw-r--r-- | distrho/extra/ScopedPointer.hpp (renamed from distrho/extra/d_scopedpointer.hpp) | 0 | ||||
-rw-r--r-- | distrho/extra/Sleep.hpp (renamed from distrho/extra/d_sleep.hpp) | 0 | ||||
-rw-r--r-- | distrho/extra/String.hpp (renamed from distrho/extra/d_string.hpp) | 2 | ||||
-rw-r--r-- | distrho/extra/Thread.hpp (renamed from distrho/extra/d_thread.hpp) | 0 |
9 files changed, 130 insertions, 3 deletions
diff --git a/distrho/DistrhoPlugin.hpp b/distrho/DistrhoPlugin.hpp index bf1f8cd5..3da97c7e 100644 --- a/distrho/DistrhoPlugin.hpp +++ b/distrho/DistrhoPlugin.hpp @@ -17,7 +17,7 @@ #ifndef DISTRHO_PLUGIN_HPP_INCLUDED #define DISTRHO_PLUGIN_HPP_INCLUDED -#include "extra/d_string.hpp" +#include "extra/String.hpp" #include "src/DistrhoPluginChecks.h" START_NAMESPACE_DISTRHO diff --git a/distrho/DistrhoUI.hpp b/distrho/DistrhoUI.hpp index 5dd45a12..f313e9a7 100644 --- a/distrho/DistrhoUI.hpp +++ b/distrho/DistrhoUI.hpp @@ -17,7 +17,7 @@ #ifndef DISTRHO_UI_HPP_INCLUDED #define DISTRHO_UI_HPP_INCLUDED -#include "extra/d_leakdetector.hpp" +#include "extra/LeakDetector.hpp" #include "src/DistrhoPluginChecks.h" #if DISTRHO_UI_USE_NANOVG diff --git a/distrho/extra/Base64.hpp b/distrho/extra/Base64.hpp new file mode 100644 index 00000000..b1cce48d --- /dev/null +++ b/distrho/extra/Base64.hpp @@ -0,0 +1,127 @@ +/* + * DISTRHO Plugin Framework (DPF) + * Copyright (C) 2012-2015 Filipe Coelho <falktx@falktx.com> + * + * 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 THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + * TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + * NO EVENT SHALL THE AUTHOR 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. + */ + +#ifndef DISTRHO_BASE64_HPP_INCLUDED +#define DISTRHO_BASE64_HPP_INCLUDED + +#include "../DistrhoUtils.hpp" + +#include <cctype> +#include <vector> + +// ----------------------------------------------------------------------- +// base64 stuff, based on http://www.adp-gmbh.ch/cpp/common/base64.html +// Copyright (C) 2004-2008 René Nyffenegger + +// ----------------------------------------------------------------------- +// Helpers + +#ifndef DOXYGEN +namespace DistrhoBase64Helpers { + +static const char* const kBase64Chars = + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "abcdefghijklmnopqrstuvwxyz" + "0123456789+/"; + +static inline +uint8_t findBase64CharIndex(const char c) +{ + static const uint8_t kBase64CharsLen(static_cast<uint8_t>(std::strlen(kBase64Chars))); + + for (uint8_t i=0; i<kBase64CharsLen; ++i) + { + if (kBase64Chars[i] == c) + return i; + } + + d_stderr2("findBase64CharIndex('%c') - failed", c); + return 0; +} + +static inline +bool isBase64Char(const char c) +{ + return (std::isalnum(c) || (c == '+') || (c == '/')); +} + +} // namespace DistrhoBase64Helpers +#endif + +// ----------------------------------------------------------------------- + +static inline +std::vector<uint8_t> d_getChunkFromBase64String(const char* const base64string) +{ + DISTRHO_SAFE_ASSERT_RETURN(base64string != nullptr, std::vector<uint8_t>()); + + uint i=0, j=0; + uint charArray3[3], charArray4[4]; + + std::vector<uint8_t> ret; + ret.reserve(std::strlen(base64string)*3/4 + 4); + + for (std::size_t l=0, len=std::strlen(base64string); l<len; ++l) + { + const char c = base64string[l]; + + if (c == '\0' || c == '=') + break; + if (c == ' ' || c == '\n') + continue; + + DISTRHO_SAFE_ASSERT_CONTINUE(CarlaBase64Helpers::isBase64Char(c)); + + charArray4[i++] = static_cast<uint>(c); + + if (i == 4) + { + for (i=0; i<4; ++i) + charArray4[i] = DistrhoBase64Helpers::findBase64CharIndex(static_cast<char>(charArray4[i])); + + charArray3[0] = (charArray4[0] << 2) + ((charArray4[1] & 0x30) >> 4); + charArray3[1] = ((charArray4[1] & 0xf) << 4) + ((charArray4[2] & 0x3c) >> 2); + charArray3[2] = ((charArray4[2] & 0x3) << 6) + charArray4[3]; + + for (i=0; i<3; ++i) + ret.push_back(static_cast<uint8_t>(charArray3[i])); + + i = 0; + } + } + + if (i != 0) + { + for (j=0; j<i && j<4; ++j) + charArray4[j] = DistrhoBase64Helpers::findBase64CharIndex(static_cast<char>(charArray4[j])); + + for (j=i; j<4; ++j) + charArray4[j] = 0; + + charArray3[0] = (charArray4[0] << 2) + ((charArray4[1] & 0x30) >> 4); + charArray3[1] = ((charArray4[1] & 0xf) << 4) + ((charArray4[2] & 0x3c) >> 2); + charArray3[2] = ((charArray4[2] & 0x3) << 6) + charArray4[3]; + + for (j=0; i>0 && j<i-1; j++) + ret.push_back(static_cast<uint8_t>(charArray3[j])); + } + + return ret; +} + +// ----------------------------------------------------------------------- + +#endif // DISTRHO_BASE64_HPP_INCLUDED diff --git a/distrho/extra/d_leakdetector.hpp b/distrho/extra/LeakDetector.hpp index 08974e6a..08974e6a 100644 --- a/distrho/extra/d_leakdetector.hpp +++ b/distrho/extra/LeakDetector.hpp diff --git a/distrho/extra/d_mutex.hpp b/distrho/extra/Mutex.hpp index 8badcc33..8badcc33 100644 --- a/distrho/extra/d_mutex.hpp +++ b/distrho/extra/Mutex.hpp diff --git a/distrho/extra/d_scopedpointer.hpp b/distrho/extra/ScopedPointer.hpp index 12e6ba0f..12e6ba0f 100644 --- a/distrho/extra/d_scopedpointer.hpp +++ b/distrho/extra/ScopedPointer.hpp diff --git a/distrho/extra/d_sleep.hpp b/distrho/extra/Sleep.hpp index 4953a12b..4953a12b 100644 --- a/distrho/extra/d_sleep.hpp +++ b/distrho/extra/Sleep.hpp diff --git a/distrho/extra/d_string.hpp b/distrho/extra/String.hpp index b2a35561..2e2bfe9f 100644 --- a/distrho/extra/d_string.hpp +++ b/distrho/extra/String.hpp @@ -17,7 +17,7 @@ #ifndef DISTRHO_STRING_HPP_INCLUDED #define DISTRHO_STRING_HPP_INCLUDED -#include "d_leakdetector.hpp" +#include "LeakDetector.hpp" START_NAMESPACE_DISTRHO diff --git a/distrho/extra/d_thread.hpp b/distrho/extra/Thread.hpp index e3bf25f0..e3bf25f0 100644 --- a/distrho/extra/d_thread.hpp +++ b/distrho/extra/Thread.hpp |