reorganise some boost::format usage

using our util::_Fmt front-end helps to reduce the code size,
since all usages rely on a single inclusion of boost::format

including boost::format via header can cause quite some code bloat


NOTE: partial solution, still some further includes to reorganise
This commit is contained in:
Fischlurch 2013-09-01 17:36:05 +02:00
parent febce1282c
commit bcbd05d7eb
27 changed files with 101 additions and 94 deletions

View file

@ -35,6 +35,8 @@
#ifndef LIB_HASH_VALUE_H
#define LIB_HASH_VALUE_H
#include <stdlib.h>
/**
* storage for a Lumiera unique ID,

View file

@ -72,7 +72,7 @@ namespace meta {
/** detect possibility of a conversion to string.
* Naive implementation just trying a the direct conversion.
* Naive implementation just trying the direct conversion.
* The embedded constant #value will be true in case this succeeds.
* Might fail in more tricky situations (references, const, volatile)
* @see string-util.hpp more elaborate solution including lexical_cast

View file

@ -23,12 +23,11 @@
#include "lib/test/test-helper.hpp"
#include "lib/test/testdummy.hpp"
#include "lib/format-string.hpp"
#include <boost/format.hpp>
using boost::format;
using boost::str;
#include <string>
using std::string;
namespace lib {
namespace test{
@ -37,8 +36,8 @@ namespace test{
string
showSizeof (size_t siz, const char* name)
{
static format fmt ("sizeof( %s ) %|30t|= %3d");
return str (fmt % (name? name:"?") % siz);
static util::_Fmt fmt ("sizeof( %s ) %|30t|= %3d");
return string (fmt % (name? name:"?") % siz);
}
@ -58,7 +57,7 @@ namespace test{
}
/** storage for testdummy flags */
/** storage for test-dummy flags */
long Dummy::_local_checksum = 0;
bool Dummy::_throw_in_ctor = false;

View file

@ -56,12 +56,14 @@ extern "C" {
#include <limits>
#include <string>
#include <boost/rational.hpp>
#include <boost/lexical_cast.hpp>
using std::string;
using util::floordiv;
using lib::time::FSecs;
using lib::time::FrameRate;
using boost::rational_cast;
using boost::lexical_cast;
namespace error = lumiera::error;
@ -167,6 +169,18 @@ namespace time {
}
/** visual framerate representation (for diagnostics) */
FrameRate::operator string() const
{
return 1==denominator() ? lexical_cast<string> (numerator())+"FPS"
: lexical_cast<string> (numerator())
+ "/"
+ lexical_cast<string> (denominator())
+ "FPS";
}
Offset
operator* (boost::rational<int64_t> factor, Offset const& o)
{

View file

@ -530,6 +530,8 @@ namespace time {
/** duration of one frame */
Duration duration() const;
operator std::string() const;
};

View file

@ -24,23 +24,24 @@
#include "proc/asset.hpp"
#include "proc/assetmanager.hpp"
#include "proc/asset/asset-format.hpp"
#include "lib/format-string.hpp"
#include "lib/util-foreach.hpp"
#include "lib/util.hpp"
#include <boost/format.hpp>
#include <tr1/functional>
#include <string>
using std::tr1::function;
using std::tr1::placeholders::_1;
using std::tr1::bind;
using boost::format;
using util::contains;
using util::removeall;
using util::for_each;
using util::and_all;
using util::isnil;
using util::cStr;
using util::_Fmt;
namespace proc {
@ -77,15 +78,21 @@ namespace asset {
Asset::Ident::operator string () const
{
format id_tuple("(%2%:%3%.%1% v%4%)");
return str (id_tuple % name % category % org % version);
return string (_Fmt("(%2%:%3%.%1% v%4%)")
% name
% category
% org
% version);
}
Asset::operator string () const
{
format id_tuple("Asset(%2%:%3%.%1% v%4%)");
return str (id_tuple % ident.name % ident.category % ident.org % ident.version);
return string (_Fmt("Asset(%2%:%3%.%1% v%4%)")
% ident.name
% ident.category
% ident.org
% ident.version);
}

View file

@ -27,15 +27,15 @@
#include "lib/time/quantiser.hpp"
#include "lib/time/timevalue.hpp"
#include "lib/time/display.hpp"
#include "lib/format-string.hpp"
#include "common/advice.hpp"
#include "lib/util.hpp"
#include <boost/format.hpp>
#include <string>
using util::_Fmt;
using util::cStr;
using util::isnil;
using boost::format;
using boost::str;
using std::string;
@ -146,8 +146,8 @@ namespace meta {
if (isnil (id_))
{
format gridIdFormat("grid(%f_%d)");
id_ = str(gridIdFormat % fps_ % _raw(origin_));
_Fmt gridIdFormat("grid(%f_%d)");
id_ = string(gridIdFormat % fps_ % _raw(origin_));
}
EntryID<TimeGrid> nameID (id_);

View file

@ -71,6 +71,6 @@ END
TEST "Simple TimeGrid" TimeGridBasics_test <<END
out-lit: simple PAL Grid: (STRUCT/time-scales:lumi.grid(25_1_0) v1)
out-lit: simple PAL Grid: (STRUCT/time-scales:lumi.grid(25FPS_0) v1)
return: 0
END

View file

@ -22,15 +22,15 @@
#include "lib/test/run.hpp"
#include "lib/format-string.hpp"
#include "lib/util.hpp"
#include "proc/asset/category.hpp"
#include "proc/asset/asset-format.hpp"
#include <boost/format.hpp>
#include <iostream>
using boost::format;
using util::_Fmt;
using util::isnil;
using std::string;
using std::cout;
@ -68,7 +68,7 @@ namespace test {
Category c3 (VIDEO,"bin1/subbin");
Category c4 (EFFECT,"some_kind");
format fmt ("Category: %s");
_Fmt fmt ("Category: %s");
cout << fmt % c1 << "\n";
cout << fmt % c2 << "\n";

View file

@ -34,18 +34,18 @@
#include "proc/assetmanager.hpp"
#include "lib/format-string.hpp"
#include "lib/util-foreach.hpp"
#include "lib/util.hpp"
#include <boost/format.hpp>
#include <tr1/functional>
#include <iostream>
using util::contains;
using util::for_each;
using util::_Fmt;
using std::tr1::placeholders::_1;
using std::tr1::bind;
using boost::format;
using std::string;
using std::cout;
@ -60,7 +60,7 @@ namespace asset {
cout << "Asset(NULL)\n";
else
{
format fmt("%s %|50T.| id=%s adr=%p smart-ptr=%p use-count=%u");
_Fmt fmt("%s %|50T.| id=%s adr=%p smart-ptr=%p use-count=%u");
cout << fmt % str(aa) % aa->getID() % aa.get() % &aa % (aa.use_count() - 1) << "\n";
} }

View file

@ -33,10 +33,8 @@
#include "lib/query-util.hpp"
#include "common/query.hpp"
#include <boost/format.hpp>
#include <iostream>
using boost::format;
using util::contains;
using util::isnil;
using std::string;
@ -187,7 +185,7 @@ namespace test {
aMang.remove (pattern2->getID());
CHECK ( aMang.known (thePatt->getID()));
CHECK (!aMang.known (pattern2->getID()));
CHECK (!aMang.known (thePipe->getID())); // has been unlinked too, because dependant on pattern2
CHECK (!aMang.known (thePipe->getID())); // has been unlinked too, because dependent on pattern2
CHECK (thePipe);
PProcPatt pattern3 = thePipe->getProcPatt(); /////TODO: transition to P<>

View file

@ -24,10 +24,8 @@
#include "lib/test/run.hpp"
//#include "lib/util.hpp"
//#include <boost/format.hpp>
#include <iostream>
//using boost::format;
using std::string;
using std::cout;

View file

@ -41,7 +41,7 @@ namespace test {
Asset::Ident
make_new_ident ()
{
return Asset::Ident ( str(format("TestAsset.%i") % counter)
return Asset::Ident ( string(_Fmt("TestAsset.%i") % counter)
, Category (META)
, "test"
, counter++
@ -50,8 +50,8 @@ namespace test {
Asset::Ident
make_new_ident (PAsset& ref)
{
return Asset::Ident ( str(format("%s-TestAsset.%i") % ref->ident.name
% counter)
return Asset::Ident ( string(_Fmt("%s-TestAsset.%i") % ref->ident.name
% counter)
, ref->ident.category
, "test"
, counter++

View file

@ -26,23 +26,21 @@
#include "proc/asset.hpp"
#include "lib/format-string.hpp"
#include <boost/format.hpp>
using std::tr1::shared_ptr;
using boost::format;
using std::string;
namespace proc {
namespace asset{
namespace test {
using util::_Fmt;
/**
* Test(mock) asset subclass usable for hijacking a given
* asset class (template parameter) and subsequently accessing
* internal facillities for writing unit tests. Prerequisite
* internal facilities for writing unit tests. Prerequisite
* for using this template is that the used asset base class
* has a (protected) ctor taking an Asset::Ident....
*/
@ -50,7 +48,7 @@ namespace test {
class TestAsset : public A
{
TestAsset () ;
TestAsset (PAsset&); ///< declared dependant on the given Asset
TestAsset (PAsset&); ///< declared dependent on the given Asset
static void deleter (TestAsset<A>* aa) { delete aa; }

View file

@ -28,10 +28,8 @@
#include "lib/test/run.hpp"
//#include "lib/util.hpp"
//#include <boost/format.hpp>
#include <iostream>
//using boost::format;
using std::string;
using std::cout;

View file

@ -27,22 +27,22 @@
#include "lib/scoped-ptrvect.hpp"
#include "lib/time/diagnostics.hpp"
#include "lib/meta/tuple.hpp"
#include "lib/format-string.hpp"
#include "lib/util-foreach.hpp"
#include "lib/util.hpp"
#include <boost/format.hpp>
#include <tr1/functional>
#include <iostream>
#include <sstream>
#include <cstdlib>
#include <string>
using util::_Fmt;
using util::isnil;
using util::for_each;
using lib::time::Time;
using lib::time::TimeVar;
using lib::time::TimeValue;
using boost::format;
using std::string;
using std::ostream;
using std::ostringstream;
@ -128,7 +128,7 @@ namespace test {
void
doIt (Tracker<TimeVar> time, Tracker<string> str, int rand)
{
static format fmt ("doIt( Time=%s \"%s\" rand=%2d )");
static _Fmt fmt ("doIt( Time=%s \"%s\" rand=%2d )");
cout << "invoke operation..." << endl;
protocol << fmt % *time % *str % rand;
}

View file

@ -26,13 +26,13 @@
#include "proc/control/command.hpp"
#include "proc/control/command-def.hpp"
#include "proc/control/handling-pattern.hpp"
#include "lib/format-string.hpp"
#include "lib/util.hpp"
#include "proc/control/test-dummy-commands.hpp"
#include <tr1/functional>
#include <boost/ref.hpp>
#include <boost/format.hpp>
#include <boost/lexical_cast.hpp>
#include <string>
@ -42,9 +42,8 @@ namespace control {
namespace test {
using util::_Fmt;
using std::string;
using boost::format;
using boost::str;
using std::tr1::function;
using std::tr1::bind;
using std::tr1::ref;
@ -87,7 +86,7 @@ namespace test {
string randomTxt()
{
format fmt ("invoked( %2d )");
_Fmt fmt ("invoked( %2d )");
randVal_ = rand() % 100;
return str (fmt % randVal_);

View file

@ -39,6 +39,7 @@
#include "lib/test/run.hpp"
#include "lib/meta/util.hpp"
#include "lib/format-string.hpp"
#include "lib/meta/generator.hpp"
#include "lib/meta/typelist-manip.hpp"
#include "lib/meta/configflags.hpp"
@ -46,10 +47,10 @@
#include "proc/engine/nodewiring-config.hpp"
#include "lib/util.hpp"
#include <boost/format.hpp>
#include <iostream>
using ::test::Test;
using util::_Fmt;
using std::string;
using std::cout;
using std::endl;
@ -244,8 +245,8 @@ cout << "__________________________\n" \
void
visit (ulong code)
{
result += str (format ("visit(code=%u) -->%s\n")
% code % Printer<CONF>::print() );
result += string (_Fmt ("visit(code=%u) -->%s\n")
% code % Printer<CONF>::print() );
}
};

View file

@ -25,11 +25,6 @@
#define LIB_META_DUMMY_FUNCTIONS_H
//#include <boost/format.hpp>
//#include <string>
//using std::string;
//using boost::format;
namespace lib {

View file

@ -25,8 +25,8 @@
#include "lib/meta/generator.hpp"
#include "lib/meta/generator-combinations.hpp"
#include "meta/typelist-diagnostics.hpp"
#include "lib/format-string.hpp"
#include <boost/format.hpp>
#include <iostream>
using ::test::Test;
@ -52,9 +52,7 @@ namespace test {
> Types2;
using boost::str;
using boost::format;
format formatted ("-<%u%u>%s");
util::_Fmt formatted ("-<%u%u>%s");
/**
* A Test-Template to be instantiated
@ -70,9 +68,9 @@ namespace test {
{
T1 param1;
T2 param2;
return str(formatted % uint(param1)
% uint(param2)
% BASE::visitAll());
return string(formatted % uint(param1)
% uint(param2)
% BASE::visitAll());
}
};

View file

@ -38,10 +38,11 @@
#include "lib/test/run.hpp"
#include "lib/format-string.hpp"
#include "lib/meta/generator.hpp"
#include <boost/format.hpp>
#include <iostream>
#include <string>
using std::string;
using std::cout;
@ -60,10 +61,10 @@ namespace test {
};
boost::format fmt ("Block<%2i>");
util::_Fmt fmt ("Block<%2i>");
template<int I>
string Block<I>::name = str (fmt % I);
string Block<I>::name = string (fmt % I);

View file

@ -37,6 +37,7 @@
#include "meta/typelist-diagnostics.hpp"
#include "lib/format-string.hpp"
#include "lib/meta/tuple.hpp"
#include <boost/utility/enable_if.hpp>
@ -45,8 +46,6 @@
#include <string>
using std::string;
using boost::str;
using boost::format;
using boost::enable_if;
using boost::lexical_cast;
using util::unConst;
@ -65,10 +64,10 @@ namespace test {
string
showTupElement(Num<i> o)
{
static format constElm("(%i)");
static format changedElm("{%i}");
static util::_Fmt constElm("(%i)");
static util::_Fmt changedElm("{%i}");
return str ( (o.o_==i? constElm:changedElm) % int(o.o_));
return string( (o.o_==i? constElm:changedElm) % int(o.o_));
}
string

View file

@ -41,15 +41,14 @@
#include "lib/meta/typelist.hpp"
#include "lib/meta/generator.hpp"
#include "lib/format-string.hpp"
#include "lib/meta/util.hpp"
#include <boost/utility/enable_if.hpp>
#include <boost/format.hpp>
#include <string>
using std::string;
using boost::format;
using boost::enable_if;
@ -101,9 +100,8 @@ namespace meta {
namespace test { // unit tests covering typelist manipulating templates
namespace { // hidden internals for diagnostics....
using boost::format;
format fmt ("-<%u>%s");
util::_Fmt fmt ("-<%u>%s");
struct NullP
{
@ -120,28 +118,28 @@ namespace meta {
struct Printer<NullType, BASE>
: BASE
{
static string print () { return str( fmt % "·" % BASE::print()); }
static string print () { return string( fmt % "·" % BASE::print()); }
};
template<class BASE, int I>
struct Printer<Num<I>, BASE> ///< display the presence of a Num instance in the typelist
: BASE
{
static string print () { return str( fmt % uint(Num<I>::VAL) % BASE::print()); }
static string print () { return string( fmt % uint(Num<I>::VAL) % BASE::print()); }
};
template<class BASE, uint Fl>
struct Printer<Flag<Fl>, BASE> ///< display the presence of a Flag in the typelist
: BASE
{
static string print () { return str( fmt % uint(Fl) % BASE::print()); }
static string print () { return string( fmt % uint(Fl) % BASE::print()); }
};
template<class BASE>
struct Printer<int, BASE> ///< display the presence of a plain int in the typelist
: BASE
{
static string print () { return str( fmt % 'i' % BASE::print()); }
static string print () { return string( fmt % 'i' % BASE::print()); }
};

View file

@ -23,17 +23,17 @@
#include "lib/test/run.hpp"
#include "lib/test/test-helper.hpp"
#include "lib/format-string.hpp"
#include "lib/util.hpp"
#include "testtargetobj.hpp"
#include "lib/singleton-subclass.hpp"
#include <boost/lexical_cast.hpp>
#include <boost/format.hpp>
#include <iostream>
using boost::lexical_cast;
using boost::format;
using util::_Fmt;
using util::isnil;
using std::string;
using std::cout;
@ -99,7 +99,7 @@ namespace test{
{
uint num= isnil(arg)? 1 : lexical_cast<uint>(arg[1]);
cout << format("using the Singleton should create TargetObj(%d)...\n") % num;
cout << _Fmt("using the Singleton should create TargetObj(%d)...\n") % num;
Interface::setCountParam(num);
@ -107,7 +107,7 @@ namespace test{
singleton::UseSubclass<Impl> typeinfo;
// define an instance of the Singleton factory,
// Specialised to create the concrete Type passed in
// specialised to create the concrete Type passed in
SingletonSubclassFactory<Interface> instance (typeinfo);
// Now use the Singleton factory...

View file

@ -22,6 +22,7 @@
#include "lib/test/run.hpp"
#include "lib/format-string.hpp"
#include "lib/util.hpp"
#include "testtargetobj.hpp"
@ -29,12 +30,11 @@
#include <tr1/functional>
#include <boost/lexical_cast.hpp>
#include <boost/format.hpp>
#include <iostream>
using std::tr1::function;
using boost::lexical_cast;
using boost::format;
using util::_Fmt;
using util::isnil;
using std::string;
using std::cout;
@ -115,7 +115,7 @@ namespace test{
void useInstance (uint num, string kind)
{
cout << format("testing TargetObj(%d) as Singleton(%s)\n") % num % kind;
cout << _Fmt("testing TargetObj(%d) as Singleton(%s)\n") % num % kind;
TargetObj::setCountParam(num);
TargetObj& t1 = instance();
TargetObj& t2 = instance();

View file

@ -22,6 +22,7 @@
#include "lib/test/run.hpp"
#include "lib/format-string.hpp"
#include "lib/test/test-helper.hpp"
#include "lib/time/display.hpp"
#include "lib/time/digxel.hpp"
@ -30,7 +31,6 @@
#include <time.h>
#include <cstdlib>
#include <iostream>
#include <boost/format.hpp>
using lumiera::error::LUMIERA_ERROR_ASSERTION;
using util::isSameObject;
@ -347,7 +347,7 @@ namespace test{
digi = 1;
clock_t start(0), stop(0);
boost::format resultDisplay("timings(%s)%|36T.|%4.0fns\n");
util::_Fmt resultDisplay("timings(%s)%|36T.|%4.0fns\n");
#define START_TIMINGS start=clock();
#define DISPLAY_TIMINGS(ID)\

View file

@ -22,11 +22,10 @@
* *****************************************************/
#include <iostream>
#include <boost/format.hpp>
#include "common/interfacedescriptor.h"
#include "common/config_interface.h"
#include "lib/format-string.hpp"
extern "C" {
#include "common/interface.h"
@ -35,7 +34,8 @@ extern "C" {
#include "interface/say_hello.h"
}
using boost::format;
#include <iostream>
using std::cout;
using std::endl;
@ -47,7 +47,7 @@ class ExamplePlugin
static LumieraInterface
myopen (LumieraInterface self, LumieraInterface interfaces)
{
static format fmt("opened %x global interfaces %x");
static util::_Fmt fmt("opened %x global interfaces %x");
cout << fmt % self % interfaces << endl;
return self;
}