From: Mikko Rasa Date: Wed, 18 Jul 2012 15:32:47 +0000 (+0300) Subject: Fix cascading of BuildInfo X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=de7ca0d3ce73bfa3f870c4257dbf71e621224876;p=builder.git Fix cascading of BuildInfo --- diff --git a/source/buildinfo.cpp b/source/buildinfo.cpp index b7f9c5c..c02d115 100644 --- a/source/buildinfo.cpp +++ b/source/buildinfo.cpp @@ -100,7 +100,7 @@ void BuildInfo::Loader::library(const string &s) } -void operator>>(LexicalConverter &conv, BuildInfo::LibraryMode &libmode) +void operator>>(const LexicalConverter &conv, BuildInfo::LibraryMode &libmode) { if(conv.get()=="FORCE_STATIC") libmode = BuildInfo::FORCE_STATIC; diff --git a/source/buildinfo.h b/source/buildinfo.h index ca8819d..e0929e7 100644 --- a/source/buildinfo.h +++ b/source/buildinfo.h @@ -39,6 +39,32 @@ public: CHAINED //< Include only compilation options }; + /** + A wrapper which tracks the set status of the wrapped variable. A default + value may be provided in initialization without causing it to be treated as + set. Assigning from a raw value flags the Tracked object as set. Assigning + from another Tracked object will only change the value of the target if the + source is set. + */ + template + class Tracked + { + public: + typedef T LoadType; + + private: + T value; + bool set; + + public: + Tracked(): value(T()), set(false) { } + Tracked(T v): value(v), set(false) { } + Tracked &operator=(const Tracked &v) { if(v.set) { value = v.value; set = true; } return *this; } + + Tracked &operator=(T v) { value = v; set = true; return *this; } + operator T() const { return value; } + }; + typedef std::map DefineMap; typedef std::list PathList; typedef std::list WordList; @@ -47,13 +73,13 @@ public: PathList incpath; PathList libpath; WordList libs; - LibraryMode libmode; - bool threads; - bool debug; - int optimize; - bool strip; - unsigned warning_level; - bool fatal_warnings; + Tracked libmode; + Tracked threads; + Tracked debug; + Tracked optimize; + Tracked strip; + Tracked warning_level; + Tracked fatal_warnings; BuildInfo();