aboutsummaryrefslogtreecommitdiff
path: root/toolsrc/include
diff options
context:
space:
mode:
authorRobert Schumacher <roschuma@microsoft.com>2017-12-01 16:08:09 -0800
committerRobert Schumacher <roschuma@microsoft.com>2017-12-01 16:08:09 -0800
commit71f8958a069208b08a4bcca207956ef8a15238ab (patch)
tree1fdded86553d97386fcd4d799bda4863fbe1516f /toolsrc/include
parent34d8c77d35089484f66d80299dc6f8303a994a84 (diff)
downloadvcpkg-71f8958a069208b08a4bcca207956ef8a15238ab.tar.gz
vcpkg-71f8958a069208b08a4bcca207956ef8a15238ab.zip
[vcpkg-contact-survey] Add monthly survey prompt
Diffstat (limited to 'toolsrc/include')
-rw-r--r--toolsrc/include/pch.h1
-rw-r--r--toolsrc/include/tests.pch.h1
-rw-r--r--toolsrc/include/vcpkg/base/chrono.h19
-rw-r--r--toolsrc/include/vcpkg/globalstate.h2
-rw-r--r--toolsrc/include/vcpkg/userconfig.h20
5 files changed, 43 insertions, 0 deletions
diff --git a/toolsrc/include/pch.h b/toolsrc/include/pch.h
index 5c31fbbd1..683bef171 100644
--- a/toolsrc/include/pch.h
+++ b/toolsrc/include/pch.h
@@ -41,6 +41,7 @@
#include <map>
#include <memory>
#include <mutex>
+#include <random>
#include <regex>
#include <set>
#include <stdexcept>
diff --git a/toolsrc/include/tests.pch.h b/toolsrc/include/tests.pch.h
index 0037af585..5c00fca4a 100644
--- a/toolsrc/include/tests.pch.h
+++ b/toolsrc/include/tests.pch.h
@@ -2,6 +2,7 @@
#include <CppUnitTest.h>
+#include <vcpkg/base/chrono.h>
#include <vcpkg/base/sortedvector.h>
#include <vcpkg/base/strings.h>
#include <vcpkg/base/util.h>
diff --git a/toolsrc/include/vcpkg/base/chrono.h b/toolsrc/include/vcpkg/base/chrono.h
index c791f53fa..4291115f7 100644
--- a/toolsrc/include/vcpkg/base/chrono.h
+++ b/toolsrc/include/vcpkg/base/chrono.h
@@ -2,6 +2,8 @@
#include <chrono>
#include <string>
+#include <time.h>
+#include <vcpkg/base/optional.h>
namespace vcpkg::Chrono
{
@@ -44,4 +46,21 @@ namespace vcpkg::Chrono
private:
std::chrono::high_resolution_clock::time_point m_start_tick;
};
+
+ class CTime
+ {
+ public:
+ static Optional<CTime> get_current_date_time();
+ static Optional<CTime> parse(CStringView str);
+
+ constexpr CTime() : m_tm{0} {}
+ explicit constexpr CTime(tm t) : m_tm{t} {}
+
+ std::string to_string() const;
+
+ std::chrono::system_clock::time_point to_time_point() const;
+
+ private:
+ mutable tm m_tm;
+ };
}
diff --git a/toolsrc/include/vcpkg/globalstate.h b/toolsrc/include/vcpkg/globalstate.h
index 40ec7958e..360d3f43e 100644
--- a/toolsrc/include/vcpkg/globalstate.h
+++ b/toolsrc/include/vcpkg/globalstate.h
@@ -10,6 +10,8 @@ namespace vcpkg
struct GlobalState
{
static Util::LockGuarded<Chrono::ElapsedTimer> timer;
+ static Util::LockGuarded<std::string> g_surveydate;
+
static std::atomic<bool> debugging;
static std::atomic<bool> feature_packages;
diff --git a/toolsrc/include/vcpkg/userconfig.h b/toolsrc/include/vcpkg/userconfig.h
new file mode 100644
index 000000000..63b8e5481
--- /dev/null
+++ b/toolsrc/include/vcpkg/userconfig.h
@@ -0,0 +1,20 @@
+#pragma once
+
+#include <string>
+#include <vcpkg/base/files.h>
+
+namespace vcpkg
+{
+ struct UserConfig
+ {
+ std::string user_id;
+ std::string user_time;
+ std::string user_mac;
+
+ std::string last_completed_survey;
+
+ static UserConfig try_read_data(const Files::Filesystem& fs);
+
+ void try_write_data(Files::Filesystem& fs) const;
+ };
+}