/*
- Copyright (C) 2018 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2018-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
*/
+
#include "analytics.h"
-#include "exceptions.h"
#include "compose.hpp"
+#include "exceptions.h"
+#include <dcp/filesystem.h>
#include <dcp/raw_convert.h>
+#include <dcp/warnings.h>
#include <libcxml/cxml.h>
+LIBDCP_DISABLE_WARNINGS
#include <libxml++/libxml++.h>
-#include <boost/filesystem.hpp>
+LIBDCP_ENABLE_WARNINGS
#include <boost/algorithm/string.hpp>
+#include <boost/filesystem.hpp>
#include "i18n.h"
+
using std::string;
using dcp::raw_convert;
using boost::algorithm::trim;
+
Analytics* Analytics::_instance;
int const Analytics::_current_version = 1;
+
Analytics::Analytics ()
- : _successful_dcp_encodes (0)
{
}
+
void
Analytics::successful_dcp_encode ()
{
}
}
+
void
Analytics::write () const
{
xmlpp::Document doc;
- xmlpp::Element* root = doc.create_root_node ("Analytics");
+ auto root = doc.create_root_node ("Analytics");
root->add_child("Version")->add_child_text(raw_convert<string>(_current_version));
root->add_child("SuccessfulDCPEncodes")->add_child_text(raw_convert<string>(_successful_dcp_encodes));
try {
- doc.write_to_file_formatted(path("analytics.xml").string());
+ doc.write_to_file_formatted(write_path("analytics.xml").string());
} catch (xmlpp::exception& e) {
string s = e.what ();
trim (s);
- throw FileError (s, path("analytics.xml"));
+ throw FileError (s, write_path("analytics.xml"));
}
}
+
void
Analytics::read ()
try
{
cxml::Document f ("Analytics");
- f.read_file (path("analytics.xml"));
+ f.read_file(dcp::filesystem::fix_long_path(read_path("analytics.xml")));
_successful_dcp_encodes = f.number_child<int>("SuccessfulDCPEncodes");
} catch (...) {
/* Never mind */
}
+
Analytics*
Analytics::instance ()
{