X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fbuildinfo.h;h=595fe1a55ccd5bb414ebbe5febec8f86431465b2;hb=a957405689fafa1afc233182a3756e36ea34281c;hp=8bedcec4c7506d4a0209b92ef33f269948679ac0;hpb=95d5743c0f2a0dd8b56928525b8caa5f6ee8cc1d;p=builder.git diff --git a/source/buildinfo.h b/source/buildinfo.h index 8bedcec..595fe1a 100644 --- a/source/buildinfo.h +++ b/source/buildinfo.h @@ -4,7 +4,7 @@ #include #include #include -#include "misc.h" +#include /** Stores information about compiler command line parameters in a more abstract @@ -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(); @@ -62,11 +88,6 @@ public: The update level determines what information is updated. */ void update_from(const BuildInfo &, UpdateLevel = LOCAL); - -private: - /** Makes sure there are no duplicate entries in the lists. For warnings, - contradicting flags are eliminated and the last one stays in effect. */ - void unique(); }; #endif