diff --git a/3party/Alohalytics/examples/ios/SampleClient.xcodeproj/.gitignore b/3party/Alohalytics/examples/ios/SampleClient.xcodeproj/.gitignore
new file mode 100644
index 0000000000..7f42cddede
--- /dev/null
+++ b/3party/Alohalytics/examples/ios/SampleClient.xcodeproj/.gitignore
@@ -0,0 +1,2 @@
+project.xcworkspace
+xcuserdata
diff --git a/3party/Alohalytics/examples/ios/SampleClient.xcodeproj/project.pbxproj b/3party/Alohalytics/examples/ios/SampleClient.xcodeproj/project.pbxproj
index 2a2092dddb..9272982ad3 100644
--- a/3party/Alohalytics/examples/ios/SampleClient.xcodeproj/project.pbxproj
+++ b/3party/Alohalytics/examples/ios/SampleClient.xcodeproj/project.pbxproj
@@ -267,7 +267,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
- CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
+ CLANG_CXX_LANGUAGE_STANDARD = "c++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
@@ -297,7 +297,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
- IPHONEOS_DEPLOYMENT_TARGET = 8.1;
+ IPHONEOS_DEPLOYMENT_TARGET = 5.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
@@ -309,7 +309,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
- CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
+ CLANG_CXX_LANGUAGE_STANDARD = "c++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
@@ -333,7 +333,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
- IPHONEOS_DEPLOYMENT_TARGET = 8.1;
+ IPHONEOS_DEPLOYMENT_TARGET = 5.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
@@ -414,6 +414,7 @@
6BDEF0761A3CF2D100054FAC /* Release */,
);
defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
};
6BDEF0771A3CF2D100054FAC /* Build configuration list for PBXNativeTarget "SampleClientTests" */ = {
isa = XCConfigurationList;
@@ -422,6 +423,7 @@
6BDEF0791A3CF2D100054FAC /* Release */,
);
defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
diff --git a/3party/Alohalytics/examples/ios/SampleClient.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/3party/Alohalytics/examples/ios/SampleClient.xcodeproj/project.xcworkspace/contents.xcworkspacedata
deleted file mode 100644
index c1faf5c24c..0000000000
--- a/3party/Alohalytics/examples/ios/SampleClient.xcodeproj/project.xcworkspace/contents.xcworkspacedata
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
-
diff --git a/3party/Alohalytics/examples/ios/SampleClient.xcodeproj/project.xcworkspace/xcshareddata/SampleClient.xccheckout b/3party/Alohalytics/examples/ios/SampleClient.xcodeproj/project.xcworkspace/xcshareddata/SampleClient.xccheckout
deleted file mode 100644
index ce4126e4ba..0000000000
--- a/3party/Alohalytics/examples/ios/SampleClient.xcodeproj/project.xcworkspace/xcshareddata/SampleClient.xccheckout
+++ /dev/null
@@ -1,41 +0,0 @@
-
-
-
-
- IDESourceControlProjectFavoriteDictionaryKey
-
- IDESourceControlProjectIdentifier
- DC49AAAD-79F8-48DF-87B1-7B0856F93DB4
- IDESourceControlProjectName
- SampleClient
- IDESourceControlProjectOriginsDictionary
-
- B29F426D1BF5D0F0A418F392D1F363C5DC680EA5
- github.com:KnowSheet/AlohaStatsClient.git
-
- IDESourceControlProjectPath
- examples/ios/SampleClient.xcodeproj
- IDESourceControlProjectRelativeInstallPathDictionary
-
- B29F426D1BF5D0F0A418F392D1F363C5DC680EA5
- ../../../..
-
- IDESourceControlProjectURL
- github.com:KnowSheet/AlohaStatsClient.git
- IDESourceControlProjectVersion
- 111
- IDESourceControlProjectWCCIdentifier
- B29F426D1BF5D0F0A418F392D1F363C5DC680EA5
- IDESourceControlProjectWCConfigurations
-
-
- IDESourceControlRepositoryExtensionIdentifierKey
- public.vcs.git
- IDESourceControlWCCIdentifierKey
- B29F426D1BF5D0F0A418F392D1F363C5DC680EA5
- IDESourceControlWCCName
- AlohaStatsClient
-
-
-
-
diff --git a/3party/Alohalytics/examples/ios/SampleClient.xcodeproj/project.xcworkspace/xcuserdata/alexz.xcuserdatad/UserInterfaceState.xcuserstate b/3party/Alohalytics/examples/ios/SampleClient.xcodeproj/project.xcworkspace/xcuserdata/alexz.xcuserdatad/UserInterfaceState.xcuserstate
deleted file mode 100644
index 20dddb4e21..0000000000
Binary files a/3party/Alohalytics/examples/ios/SampleClient.xcodeproj/project.xcworkspace/xcuserdata/alexz.xcuserdatad/UserInterfaceState.xcuserstate and /dev/null differ
diff --git a/3party/Alohalytics/examples/ios/SampleClient.xcodeproj/xcuserdata/alexz.xcuserdatad/xcschemes/SampleClient.xcscheme b/3party/Alohalytics/examples/ios/SampleClient.xcodeproj/xcuserdata/alexz.xcuserdatad/xcschemes/SampleClient.xcscheme
deleted file mode 100644
index ef89e60aa5..0000000000
--- a/3party/Alohalytics/examples/ios/SampleClient.xcodeproj/xcuserdata/alexz.xcuserdatad/xcschemes/SampleClient.xcscheme
+++ /dev/null
@@ -1,110 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/3party/Alohalytics/examples/ios/SampleClient.xcodeproj/xcuserdata/alexz.xcuserdatad/xcschemes/xcschememanagement.plist b/3party/Alohalytics/examples/ios/SampleClient.xcodeproj/xcuserdata/alexz.xcuserdatad/xcschemes/xcschememanagement.plist
deleted file mode 100644
index 7208349db4..0000000000
--- a/3party/Alohalytics/examples/ios/SampleClient.xcodeproj/xcuserdata/alexz.xcuserdatad/xcschemes/xcschememanagement.plist
+++ /dev/null
@@ -1,27 +0,0 @@
-
-
-
-
- SchemeUserState
-
- SampleClient.xcscheme
-
- orderHint
- 0
-
-
- SuppressBuildableAutocreation
-
- 6BDEF0501A3CF2D100054FAC
-
- primary
-
-
- 6BDEF0691A3CF2D100054FAC
-
- primary
-
-
-
-
-
diff --git a/3party/Alohalytics/examples/ios/SampleClient/Info.plist b/3party/Alohalytics/examples/ios/SampleClient/Info.plist
index 7aa21dbd9a..ee8791cef9 100644
--- a/3party/Alohalytics/examples/ios/SampleClient/Info.plist
+++ b/3party/Alohalytics/examples/ios/SampleClient/Info.plist
@@ -7,7 +7,7 @@
CFBundleExecutable
$(EXECUTABLE_NAME)
CFBundleIdentifier
- org.alohaclient.$(PRODUCT_NAME:rfc1034identifier)
+ org.alohalytics.$(PRODUCT_NAME:rfc1034identifier)
CFBundleInfoDictionaryVersion
6.0
CFBundleName
diff --git a/3party/Alohalytics/src/Bricks/exception.h b/3party/Alohalytics/src/Bricks/exception.h
index 0a98f31265..f43cfea8aa 100644
--- a/3party/Alohalytics/src/Bricks/exception.h
+++ b/3party/Alohalytics/src/Bricks/exception.h
@@ -1,12 +1,66 @@
+/*******************************************************************************
+The MIT License (MIT)
+
+Copyright (c) 2014 Dmitry "Dima" Korolev
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+*******************************************************************************/
+
#ifndef BRICKS_EXCEPTIONS_H
#define BRICKS_EXCEPTIONS_H
#include
+#include
+
+#include "strings/printf.h"
namespace bricks {
-// TODO(dkorolev): Add string descriptions.
-struct Exception : std::exception {};
+class Exception : public std::exception {
+ public:
+ Exception(const std::string& what = "") : what_(what) {}
+ virtual ~Exception() = default;
+
+ void SetWhat(const std::string& what) { what_ = what; }
+
+ // LCOV_EXCL_START
+ virtual const char* what() const noexcept override { return what_.c_str(); }
+ // LCOV_EXCL_STOP
+
+ virtual const std::string& What() const noexcept { return what_; }
+
+ void SetCaller(const std::string& caller) { what_ = caller + '\t' + what_; }
+
+ void SetOrigin(const char* file, int line) { what_ = strings::Printf("%s:%d\t", file, line) + what_; }
+
+ private:
+ std::string what_;
+};
+
+// Extra parenthesis around `e((E))` are essential to not make it a function declaration.
+#define BRICKS_THROW(E) \
+ { \
+ auto e((E)); \
+ e.SetCaller(#E); \
+ e.SetOrigin(__FILE__, __LINE__); \
+ throw e; \
+ }
} // namespace bricks
diff --git a/3party/Alohalytics/src/Bricks/file/file.h b/3party/Alohalytics/src/Bricks/file/file.h
index 884ec768cb..90ae821407 100644
--- a/3party/Alohalytics/src/Bricks/file/file.h
+++ b/3party/Alohalytics/src/Bricks/file/file.h
@@ -33,8 +33,27 @@ SOFTWARE.
#include
#include
+#ifdef _MSC_VER
+#include
+#include
+struct ScopedCloseFindFileHandle {
+ HANDLE handle_;
+ ScopedCloseFindFileHandle(HANDLE handle) : handle_(handle) {}
+ ~ScopedCloseFindFileHandle() {
+ ::FindClose(handle_);
+ }
+};
+#else
#include
#include
+struct ScopedCloseDir {
+ DIR * dir_;
+ ScopedCloseDir(DIR * dir) : dir_(dir) {}
+ ~ScopedCloseDir() {
+ ::closedir(dir_);
+ }
+};
+#endif
#include "exceptions.h"
#include "../../logger.h"
@@ -47,8 +66,8 @@ inline std::string ReadFileAsString(std::string const& file_name) {
fi.exceptions(std::ifstream::failbit | std::ifstream::badbit);
fi.open(file_name, std::ifstream::binary);
fi.seekg(0, std::ios::end);
- const size_t size = fi.tellg();
- std::string buffer(size, '\0');
+ const std::streampos size = fi.tellg();
+ std::string buffer(static_cast(size), '\0');
fi.seekg(0);
if (fi.read(&buffer[0], size).good()) {
return buffer;
@@ -100,17 +119,6 @@ class ScopedRemoveFile final {
std::string file_name_;
};
-class ScopedCloseDir final {
- DIR* dir_;
-
- public:
- explicit ScopedCloseDir(DIR* dir) : dir_(dir) {
- }
- ~ScopedCloseDir() {
- ::closedir(dir_);
- }
-};
-
// Platform-indepenent, injection-friendly filesystem wrapper.
struct FileSystem {
typedef std::ofstream OutputFile;
@@ -148,9 +156,24 @@ struct FileSystem {
static inline void ScanDirUntil(const std::string& directory,
std::function lambda) {
- DIR* dir = ::opendir(directory.c_str());
- const ScopedCloseDir dir_closer(dir);
+#ifdef _MSC_VER
+ WIN32_FIND_DATAA find_data;
+ HANDLE handle = ::FindFirstFileA(directory.c_str(), &find_data);
+ if (handle == INVALID_HANDLE_VALUE) {
+ return;
+ }
+ const ScopedCloseFindFileHandle closer(handle);
+ do {
+ if (!(find_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
+ if (!lambda(find_data.cFileName)) {
+ return;
+ }
+ }
+ } while (::FindNextFileA(handle, &find_data) != 0);
+#else
+ DIR * dir = ::opendir(directory.c_str());
if (dir) {
+ const ScopedCloseDir closer(dir);
while (struct dirent* entry = ::readdir(dir)) {
if (*entry->d_name && ::strcmp(entry->d_name, ".") && ::strcmp(entry->d_name, "..")) {
if (!lambda(entry->d_name)) {
@@ -159,6 +182,7 @@ struct FileSystem {
}
}
}
+#endif
}
static inline void ScanDir(const std::string& directory, std::function lambda) {
@@ -179,8 +203,12 @@ struct FileSystem {
}
static inline void CreateDirectory(const std::string& directory) {
+#ifdef _MSC_VER
+ ::_mkdir(directory.c_str());
+#else
// Hard-code default permissions to avoid cross-platform compatibility issues.
::mkdir(directory.c_str(), 0755);
+#endif
}
};
diff --git a/3party/Alohalytics/src/Bricks/rtti/dispatcher.h b/3party/Alohalytics/src/Bricks/rtti/dispatcher.h
new file mode 100644
index 0000000000..112e7c6ace
--- /dev/null
+++ b/3party/Alohalytics/src/Bricks/rtti/dispatcher.h
@@ -0,0 +1,100 @@
+/*******************************************************************************
+The MIT License (MIT)
+
+Copyright (c) 2014 Dmitry "Dima" Korolev
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+*******************************************************************************/
+
+// RTTI-based call dispatching to the handler of the appropriate type.
+
+#ifndef BRICKS_RTTI_DISPATCHER_H
+#define BRICKS_RTTI_DISPATCHER_H
+
+#include "exceptions.h"
+
+#include
+
+namespace bricks {
+namespace rtti {
+
+template
+struct RuntimeDispatcher {
+ typedef BASE T_BASE;
+ typedef DERIVED T_DERIVED;
+ template
+ static void DispatchCall(const TYPE &x, PROCESSOR &c) {
+ if (const DERIVED *d = dynamic_cast(&x)) {
+ c(*d);
+ } else {
+ RuntimeDispatcher::DispatchCall(x, c);
+ }
+ }
+ template
+ static void DispatchCall(TYPE &x, PROCESSOR &c) {
+ if (DERIVED *d = dynamic_cast(&x)) {
+ c(*d);
+ } else {
+ RuntimeDispatcher::DispatchCall(x, c);
+ }
+ }
+};
+
+template
+struct RuntimeDispatcher {
+ typedef BASE T_BASE;
+ typedef DERIVED T_DERIVED;
+ template
+ static void DispatchCall(const TYPE &x, PROCESSOR &c) {
+ if (const DERIVED *d = dynamic_cast(&x)) {
+ c(*d);
+ } else {
+ const BASE *b = dynamic_cast(&x);
+ if (b) {
+ c(*b);
+ } else {
+ BRICKS_THROW(UnrecognizedPolymorphicType());
+ }
+ }
+ }
+ template
+ static void DispatchCall(TYPE &x, PROCESSOR &c) {
+ if (DERIVED *d = dynamic_cast(&x)) {
+ c(*d);
+ } else {
+ BASE *b = dynamic_cast(&x);
+ if (b) {
+ c(*b);
+ } else {
+ BRICKS_THROW(UnrecognizedPolymorphicType());
+ }
+ }
+ }
+};
+
+template
+struct RuntimeTupleDispatcher {};
+
+template
+struct RuntimeTupleDispatcher> : RuntimeDispatcher {};
+
+} // namespace rtti
+} // namespace bricks
+
+#endif // BRICKS_RTTI_DISPATCHER_H
diff --git a/3party/Alohalytics/src/Bricks/rtti/exceptions.h b/3party/Alohalytics/src/Bricks/rtti/exceptions.h
new file mode 100644
index 0000000000..f9856d7b5b
--- /dev/null
+++ b/3party/Alohalytics/src/Bricks/rtti/exceptions.h
@@ -0,0 +1,38 @@
+/*******************************************************************************
+The MIT License (MIT)
+
+Copyright (c) 2014 Dmitry "Dima" Korolev
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+*******************************************************************************/
+
+#ifndef BRICKS_RTTI_EXCEPTIONS_H
+#define BRICKS_RTTI_EXCEPTIONS_H
+
+#include "../exception.h"
+
+namespace bricks {
+namespace rtti {
+
+struct UnrecognizedPolymorphicType : Exception {};
+
+} // namespace rtti
+} // namespace bricks
+
+#endif // BRICKS_RTTI_EXCEPTIONS_H
diff --git a/3party/Alohalytics/src/Bricks/rtti/test.cc b/3party/Alohalytics/src/Bricks/rtti/test.cc
new file mode 100644
index 0000000000..4b2ff85cbc
--- /dev/null
+++ b/3party/Alohalytics/src/Bricks/rtti/test.cc
@@ -0,0 +1,262 @@
+/*******************************************************************************
+The MIT License (MIT)
+
+Copyright (c) 2014 Dmitry "Dima" Korolev
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+*******************************************************************************/
+
+#include "dispatcher.h"
+
+#include
+#include
+
+#include "../3party/gtest/gtest-main.h"
+
+using std::string;
+using std::tuple;
+
+template
+struct TypeList;
+
+struct Base {
+ // Empty constructor required by clang++.
+ Base() {}
+ // Need to define at least one virtual method.
+ virtual ~Base() = default;
+};
+struct Foo : Base {
+ Foo() {}
+};
+struct Bar : Base {
+ Bar() {}
+};
+struct Baz : Base {
+ Baz() {}
+};
+
+struct OtherBase {
+ // Empty constructor required by clang++.
+ OtherBase() {}
+ // Need to define at least one virtual method.
+ virtual ~OtherBase() = default;
+};
+
+typedef TypeList FooBarBazTypeList;
+
+struct Processor {
+ string s;
+ void operator()(const Base&) { s = "const Base&"; }
+ void operator()(const Foo&) { s = "const Foo&"; }
+ void operator()(const Bar&) { s = "const Bar&"; }
+ void operator()(const Baz&) { s = "const Baz&"; }
+ void operator()(Base&) { s = "Base&"; }
+ void operator()(Foo&) { s = "Foo&"; }
+ void operator()(Bar&) { s = "Bar&"; }
+ void operator()(Baz&) { s = "Baz&"; }
+};
+
+TEST(RuntimeDispatcher, StaticCalls) {
+ Processor p;
+ EXPECT_EQ("", p.s);
+ p(Base());
+ EXPECT_EQ("const Base&", p.s);
+ p(Foo());
+ EXPECT_EQ("const Foo&", p.s);
+ p(Bar());
+ EXPECT_EQ("const Bar&", p.s);
+ p(Baz());
+ EXPECT_EQ("const Baz&", p.s);
+}
+
+TEST(RuntimeDispatcher, ImmutableStaticCalls) {
+ const Base base;
+ const Foo foo;
+ const Bar bar;
+ const Baz baz;
+ Processor p;
+ EXPECT_EQ("", p.s);
+ p(base);
+ EXPECT_EQ("const Base&", p.s);
+ p(foo);
+ EXPECT_EQ("const Foo&", p.s);
+ p(bar);
+ EXPECT_EQ("const Bar&", p.s);
+ p(baz);
+ EXPECT_EQ("const Baz&", p.s);
+}
+
+TEST(RuntimeDispatcher, MutableStaticCalls) {
+ Base base;
+ Foo foo;
+ Bar bar;
+ Baz baz;
+ Processor p;
+ EXPECT_EQ("", p.s);
+ p(base);
+ EXPECT_EQ("Base&", p.s);
+ p(foo);
+ EXPECT_EQ("Foo&", p.s);
+ p(bar);
+ EXPECT_EQ("Bar&", p.s);
+ p(baz);
+ EXPECT_EQ("Baz&", p.s);
+}
+
+TEST(RuntimeDispatcher, ImmutableWithoutDispatching) {
+ const Base base;
+ const Foo foo;
+ const Bar bar;
+ const Baz baz;
+ const Base& rbase = base;
+ const Base& rfoo = foo;
+ const Base& rbar = bar;
+ const Base& rbaz = baz;
+ Processor p;
+ EXPECT_EQ("", p.s);
+ p(rbase);
+ EXPECT_EQ("const Base&", p.s);
+ p(rfoo);
+ EXPECT_EQ("const Base&", p.s);
+ p(rbar);
+ EXPECT_EQ("const Base&", p.s);
+ p(rbaz);
+ EXPECT_EQ("const Base&", p.s);
+}
+
+TEST(RuntimeDispatcher, MutableWithoutDispatching) {
+ Base base;
+ Foo foo;
+ Bar bar;
+ Baz baz;
+ Base& rbase = base;
+ Base& rfoo = foo;
+ Base& rbar = bar;
+ Base& rbaz = baz;
+ Processor p;
+ EXPECT_EQ("", p.s);
+ p(rbase);
+ EXPECT_EQ("Base&", p.s);
+ p(rfoo);
+ EXPECT_EQ("Base&", p.s);
+ p(rbar);
+ EXPECT_EQ("Base&", p.s);
+ p(rbaz);
+ EXPECT_EQ("Base&", p.s);
+}
+
+TEST(RuntimeDispatcher, ImmutableWithDispatching) {
+ const Base base;
+ const Foo foo;
+ const Bar bar;
+ const Baz baz;
+ const OtherBase other;
+ const Base& rbase = base;
+ const Base& rfoo = foo;
+ const Base& rbar = bar;
+ const Base& rbaz = baz;
+ const OtherBase& rother = other;
+ Processor p;
+ EXPECT_EQ("", p.s);
+ bricks::rtti::RuntimeDispatcher::DispatchCall(rbase, p);
+ EXPECT_EQ("const Base&", p.s);
+ bricks::rtti::RuntimeDispatcher::DispatchCall(rfoo, p);
+ EXPECT_EQ("const Foo&", p.s);
+ bricks::rtti::RuntimeDispatcher::DispatchCall(rbar, p);
+ EXPECT_EQ("const Bar&", p.s);
+ bricks::rtti::RuntimeDispatcher::DispatchCall(rbaz, p);
+ EXPECT_EQ("const Baz&", p.s);
+ ASSERT_THROW((bricks::rtti::RuntimeDispatcher::DispatchCall(rother, p)),
+ bricks::rtti::UnrecognizedPolymorphicType);
+}
+
+TEST(RuntimeDispatcher, MutableWithDispatching) {
+ Base base;
+ Foo foo;
+ Bar bar;
+ Baz baz;
+ OtherBase other;
+ Base& rbase = base;
+ Base& rfoo = foo;
+ Base& rbar = bar;
+ Base& rbaz = baz;
+ OtherBase& rother = other;
+ Processor p;
+ EXPECT_EQ("", p.s);
+ bricks::rtti::RuntimeDispatcher::DispatchCall(rbase, p);
+ EXPECT_EQ("Base&", p.s);
+ bricks::rtti::RuntimeDispatcher::DispatchCall(rfoo, p);
+ EXPECT_EQ("Foo&", p.s);
+ bricks::rtti::RuntimeDispatcher::DispatchCall(rbar, p);
+ EXPECT_EQ("Bar&", p.s);
+ bricks::rtti::RuntimeDispatcher::DispatchCall(rbaz, p);
+ EXPECT_EQ("Baz&", p.s);
+ ASSERT_THROW((bricks::rtti::RuntimeDispatcher::DispatchCall(rother, p)),
+ bricks::rtti::UnrecognizedPolymorphicType);
+}
+
+TEST(RuntimeDispatcher, ImmutableWithTupleTypeListDispatching) {
+ const Base base;
+ const Foo foo;
+ const Bar bar;
+ const Baz baz;
+ const OtherBase other;
+ const Base& rbase = base;
+ const Base& rfoo = foo;
+ const Base& rbar = bar;
+ const Base& rbaz = baz;
+ const OtherBase& rother = other;
+ Processor p;
+ EXPECT_EQ("", p.s);
+ bricks::rtti::RuntimeTupleDispatcher>::DispatchCall(rbase, p);
+ EXPECT_EQ("const Base&", p.s);
+ bricks::rtti::RuntimeTupleDispatcher>::DispatchCall(rfoo, p);
+ EXPECT_EQ("const Foo&", p.s);
+ bricks::rtti::RuntimeTupleDispatcher>::DispatchCall(rbar, p);
+ EXPECT_EQ("const Bar&", p.s);
+ bricks::rtti::RuntimeTupleDispatcher>::DispatchCall(rbaz, p);
+ EXPECT_EQ("const Baz&", p.s);
+ ASSERT_THROW((bricks::rtti::RuntimeDispatcher::DispatchCall(rother, p)),
+ bricks::rtti::UnrecognizedPolymorphicType);
+}
+
+TEST(RuntimeDispatcher, MutableWithTupleTypeListDispatching) {
+ Base base;
+ Foo foo;
+ Bar bar;
+ Baz baz;
+ OtherBase other;
+ Base& rbase = base;
+ Base& rfoo = foo;
+ Base& rbar = bar;
+ Base& rbaz = baz;
+ OtherBase& rother = other;
+ Processor p;
+ EXPECT_EQ("", p.s);
+ bricks::rtti::RuntimeTupleDispatcher>::DispatchCall(rbase, p);
+ EXPECT_EQ("Base&", p.s);
+ bricks::rtti::RuntimeTupleDispatcher>::DispatchCall(rfoo, p);
+ EXPECT_EQ("Foo&", p.s);
+ bricks::rtti::RuntimeTupleDispatcher>::DispatchCall(rbar, p);
+ EXPECT_EQ("Bar&", p.s);
+ bricks::rtti::RuntimeTupleDispatcher>::DispatchCall(rbaz, p);
+ EXPECT_EQ("Baz&", p.s);
+ ASSERT_THROW((bricks::rtti::RuntimeDispatcher::DispatchCall(rother, p)),
+ bricks::rtti::UnrecognizedPolymorphicType);
+}
diff --git a/3party/Alohalytics/src/FileStorageQueue/exponential_retry_strategy.h b/3party/Alohalytics/src/FileStorageQueue/exponential_retry_strategy.h
index a7ca820580..3dc0a1accd 100644
--- a/3party/Alohalytics/src/FileStorageQueue/exponential_retry_strategy.h
+++ b/3party/Alohalytics/src/FileStorageQueue/exponential_retry_strategy.h
@@ -10,6 +10,15 @@
#include "exception.h"
#include "../Bricks/time/chrono.h"
+#ifdef _MSC_VER
+#ifdef max
+#undef max
+#endif
+#ifdef min
+#undef min
+#endif
+#endif // _MSC_VER
+
namespace fsq {
namespace strategy {
diff --git a/3party/Alohalytics/src/FileStorageQueue/fsq.h b/3party/Alohalytics/src/FileStorageQueue/fsq.h
index 393a742acb..7e9d3a0e37 100644
--- a/3party/Alohalytics/src/FileStorageQueue/fsq.h
+++ b/3party/Alohalytics/src/FileStorageQueue/fsq.h
@@ -317,7 +317,7 @@ class FSQ final : public CONFIG::T_FILE_NAMING_STRATEGY,
// Step 1/4: Get the list of finalized files.
typedef std::vector> FileInfoVector;
const FileInfoVector& finalized_files_on_disk = ScanDir([this](const std::string& s, T_TIMESTAMP* t) {
- return T_FILE_NAMING_STRATEGY::finalized.ParseFileName(s, t);
+ return this->finalized.ParseFileName(s, t);
});
status_.finalized.queue.assign(finalized_files_on_disk.begin(), finalized_files_on_disk.end());
status_.finalized.total_size = 0;
@@ -327,7 +327,7 @@ class FSQ final : public CONFIG::T_FILE_NAMING_STRATEGY,
// Step 2/4: Get the list of current files.
const FileInfoVector& current_files_on_disk = ScanDir([this](
- const std::string& s, T_TIMESTAMP* t) { return T_FILE_NAMING_STRATEGY::current.ParseFileName(s, t); });
+ const std::string& s, T_TIMESTAMP* t) { return this->current.ParseFileName(s, t); });
if (!current_files_on_disk.empty()) {
const bool resume = T_FILE_RESUME_STRATEGY::ShouldResume();
const size_t number_of_files_to_finalize = current_files_on_disk.size() - (resume ? 1u : 0u);
diff --git a/3party/Alohalytics/src/android/java/org/alohalytics/ConnectivityChangedReceiver.java b/3party/Alohalytics/src/android/java/org/alohalytics/ConnectivityChangedReceiver.java
index 5254538ffe..7549fa02e5 100644
--- a/3party/Alohalytics/src/android/java/org/alohalytics/ConnectivityChangedReceiver.java
+++ b/3party/Alohalytics/src/android/java/org/alohalytics/ConnectivityChangedReceiver.java
@@ -52,8 +52,6 @@ public class ConnectivityChangedReceiver extends BroadcastReceiver {
}
public void onWiFiConnected() {
- // TODO(AlexZ): Make it optional.
- org.alohalytics.Statistics.logEvent("$onWiFi");
org.alohalytics.Statistics.forceUpload();
}
}
diff --git a/3party/Alohalytics/src/android/java/org/alohalytics/Statistics.java b/3party/Alohalytics/src/android/java/org/alohalytics/Statistics.java
index 2c804ccd6c..db64baceb0 100644
--- a/3party/Alohalytics/src/android/java/org/alohalytics/Statistics.java
+++ b/3party/Alohalytics/src/android/java/org/alohalytics/Statistics.java
@@ -123,8 +123,8 @@ public class Statistics {
private static final String PREF_APP_UPDATE_TIME = "APP_UPDATE_TIME";
// Returns id and true if id was generated or false if id was read from preferences.
- // Please note, that only the very first call to getInstallationId can tell the truth.
- public synchronized static Pair getInstallationId(final Context context) {
+ // Please note, that only the very first call to getInstallationId in the app lifetime returns true.
+ private synchronized static Pair getInstallationId(final Context context) {
if (uniqueID == null) {
final SharedPreferences sharedPrefs = context.getSharedPreferences(
PREF_FILE, Context.MODE_PRIVATE);
diff --git a/3party/Alohalytics/src/event_base.h b/3party/Alohalytics/src/event_base.h
index 614268f2ce..45dfc429a6 100644
--- a/3party/Alohalytics/src/event_base.h
+++ b/3party/Alohalytics/src/event_base.h
@@ -33,6 +33,9 @@
#include "cereal/include/cereal.hpp"
#include "cereal/include/types/base_class.hpp"
#include "cereal/include/types/polymorphic.hpp"
+#include "cereal/include/archives/binary.hpp"
+#include "cereal/include/types/string.hpp"
+#include "cereal/include/types/map.hpp"
// For easier processing on a server side, every statistics event should derive from this base class.
struct AlohalyticsBaseEvent {
diff --git a/3party/Alohalytics/src/posix/http_client_curl.cc b/3party/Alohalytics/src/posix/http_client_curl.cc
index b4c17bda82..b6b3b08440 100644
--- a/3party/Alohalytics/src/posix/http_client_curl.cc
+++ b/3party/Alohalytics/src/posix/http_client_curl.cc
@@ -28,6 +28,11 @@
#include
#include // std::cerr
+#ifdef _MSC_VER
+#define popen _popen
+#define pclose _pclose
+#endif
+
// Used as a test stub for basic HTTP client implementation.
namespace alohalytics {
@@ -54,7 +59,11 @@ bool HTTPClientPlatformWrapper::RunHTTPRequest() {
if (!post_body_.empty()) {
// POST body through tmp file to avoid breaking command line.
char tmp_file[L_tmpnam];
+#ifdef _MSC_VER
+ ::tmpnam_s(tmp_file, L_tmpnam);
+#else
::tmpnam(tmp_file);
+#endif
std::ofstream(tmp_file) << post_body_;
post_file_ = tmp_file;
}
diff --git a/3party/Alohalytics/src/server/demo.cc b/3party/Alohalytics/src/server/demo.cc
new file mode 100644
index 0000000000..cb0e1d05fb
--- /dev/null
+++ b/3party/Alohalytics/src/server/demo.cc
@@ -0,0 +1,84 @@
+/*******************************************************************************
+ The MIT License (MIT)
+
+ Copyright (c) 2014 Alexander Zolotarev from Minsk, Belarus
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in all
+ copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ SOFTWARE.
+ *******************************************************************************/
+
+// Small demo which prints raw (ungzipped) cereal stream from stdin.
+
+// This define is needed to preserve client's timestamps in events.
+#define ALOHALYTICS_SERVER
+#include "../event_base.h"
+
+#include "../Bricks/rtti/dispatcher.h"
+
+#include
+#include
+#include
+
+struct Processor {
+ void PrintTime(const AlohalyticsBaseEvent & event) {
+ const time_t timestamp = static_cast(event.timestamp / 1000);
+ std::cout << std::put_time(std::localtime(×tamp), "%e-%b-%Y %H:%M:%S");
+ }
+ void operator()(const AlohalyticsBaseEvent & event) {
+ PrintTime(event);
+ std::cout << "Unhandled event of type " << typeid(event).name() << std::endl;
+ }
+ void operator()(const AlohalyticsIdEvent & event) {
+ PrintTime(event);
+ std::cout << " ID: " << event.id << std::endl;
+ }
+ void operator()(const AlohalyticsKeyEvent & event) {
+ PrintTime(event);
+ std::cout << ' ' << event.key << std::endl;
+ }
+ void operator()(const AlohalyticsKeyValueEvent & event) {
+ PrintTime(event);
+ std::cout << ' ' << event.key << " = " << event.value << std::endl;
+ }
+ void operator()(const AlohalyticsKeyPairsEvent & event) {
+ PrintTime(event);
+ std::cout << ' ' << event.key << " [ ";
+ for (const auto & pair : event.pairs) {
+ std::cout << pair.first << '=' << pair.second << ' ';
+ }
+ std::cout << ']' << std::endl;
+ }
+};
+
+int main(int, char **) {
+ cereal::BinaryInputArchive ar(std::cin);
+ Processor processor;
+ try {
+ while (std::cin.good()) {
+ std::unique_ptr ptr;
+ ar(ptr);
+ bricks::rtti::RuntimeDispatcher::DispatchCall(*ptr, processor);
+ }
+ } catch (const cereal::Exception & ex) {
+ }
+ return 0;
+}