Permalink
Browse files

Try out tinyformat instead of boost::format

  • Loading branch information...
JonnyH committed Nov 7, 2016
1 parent 7abe474 commit 8dba0afb258d1af4ce565daeb19ec5c52414f6cc
Showing with 8 additions and 61 deletions.
  1. +3 −0 .gitmodules
  2. +1 −0 dependencies/tinyformat
  3. +1 −25 library/library_pch.h
  4. +2 −36 library/strings_format.h
  5. +1 −0 tools/extractors/extract_vehicles.cpp
View
@@ -17,3 +17,6 @@
[submodule "dependencies/lodepng"]
path = dependencies/lodepng
url = https://github.com/lvandeve/lodepng.git
[submodule "dependencies/tinyformat"]
path = dependencies/tinyformat
url = https://github.com/c42f/tinyformat.git
Submodule tinyformat added at 3a33bb
View
@@ -1,48 +1,24 @@
#pragma once
#include "dependencies/tinyformat/tinyformat.h"
#include <algorithm>
#include <algorithm>
#include <boost/algorithm/string/predicate.hpp>
#include <boost/algorithm/string/predicate.hpp>
#include <boost/format.hpp>
#include <boost/format.hpp>
#include <boost/locale.hpp>
#include <boost/locale.hpp>
#include <boost/locale/format.hpp>
#include <boost/locale/format.hpp>
#include <cstdint>
#include <cstdint>
#include <fstream>
#include <fstream>
#include <glm/glm.hpp>
#include <glm/glm.hpp>
#include <glm/vec2.hpp>
#include <glm/vec2.hpp>
#include <glm/vec3.hpp>
#include <glm/vec3.hpp>
#include <iostream>
#include <iostream>
#include <istream>
#include <istream>
#include <iterator>
#include <iterator>
#include <limits>
#include <limits>
#include <list>
#include <list>
#include <map>
#include <map>
#include <memory>
#include <memory>
#include <ostream>
#include <ostream>
#include <random>
#include <random>
#include <set>
#include <set>
#include <stdexcept>
#include <stdexcept>
#include <string>
#include <string>
#include <vector>
#include <vector>
View
@@ -1,49 +1,15 @@
#pragma once
#include "dependencies/tinyformat/tinyformat.h"
#include "library/strings.h"
// Disable automatic #pragma linking for boost - only enabled in msvc and that should provide boost
// symbols as part of the module that uses it
#define BOOST_ALL_NO_LIB
#include <boost/format.hpp>
#include <boost/locale/format.hpp>
namespace OpenApoc
{
static inline boost::format &format(boost::format &f) { return f; }
template <typename T, typename... Args>
static boost::format &format(boost::format &f, T const &arg, Args &&... args)
{
return format(f % arg, std::forward<Args>(args)...);
}
template <typename... Args> static UString format(const UString &fmt, Args &&... args)
{
boost::format f(fmt.str());
return format(f, std::forward<Args>(args)...).str();
}
//_lFormat shouldn't be used directly, instead use OpenApoc::tr()
static inline boost::locale::format &lFormat(boost::locale::format &f) { return f; }
template <typename T, typename... Args>
static boost::locale::format &lFormat(boost::locale::format &f, T const &arg, Args &&... args)
{
return lFormat(f % arg, std::forward<Args>(args)...);
return tfm::format(fmt.cStr(), std::forward<Args>(args)...);
}
UString tr(const UString &str, const UString domain = "ufo_string");
template <typename... Args> static UString tr(const UString &fmt, Args &&... args)
{
boost::locale::format f(boost::locale::translate(fmt.str()).str("ufo_string"));
return lFormat(f, std::forward<Args>(args)...).str();
}
template <typename... Args>
static UString tr(const UString &fmt, const UString domain, Args &&... args)
{
boost::locale::format f(boost::locale::translate(fmt.str()).str(domain.str()));
return lFormat(f, std::forward<Args>(args)...).str();
}
} // namespace OpenApoc
@@ -6,6 +6,7 @@
#include "library/voxel.h"
#include "tools/extractors/common/ufo2p.h"
#include "tools/extractors/extractors.h"
#include <cstring>
#include <list>
#include <map>
#include <set>

0 comments on commit 8dba0af

Please sign in to comment.