makefile::Makefile Class Reference

Container and Manager for all our MakefileItems. More...

#include <Makefile.h>

List of all members.

Public Types

enum  QuoteMode { MAKE, SHELL, NONE }
 Selects quoting modes. More...

Public Member Functions

virtual ~Makefile ()
void add (MakefileItem *item)
 Adds a MakefileItem to a list of existing Items.
int writeMakefile (ostream &out)
 Outputs all known MakefileItem to an ostream.

Static Public Member Functions

MakefilegetSingleton ()
void clean ()
string quote (const string &in, Makefile::QuoteMode mode)
 Quotes and escapes characters using regular expressions.
void remove (MakefileItem *item)
 Removes a MakefileItem to a list of existing Items.

Static Public Attributes

const std::locale locale
 Used for numeric output to get a decimal dot anyways.

Private Member Functions

 Makefile ()

Private Attributes

std::vector< MakefileItem * > items
 Holds pointers to every existing MakefileItem.
bool written
 has the makefile been written?

Static Private Attributes

Makefileinstance = NULL


Detailed Description

Container and Manager for all our MakefileItems.

It also contains some static utils and enums.

Definition at line 46 of file Makefile.h.


Member Enumeration Documentation

enum makefile::Makefile::QuoteMode
 

Selects quoting modes.

Enumeration values:
MAKE 
SHELL 
NONE 

Definition at line 69 of file Makefile.h.


Constructor & Destructor Documentation

makefile::Makefile::Makefile  )  [inline, private]
 

Definition at line 52 of file Makefile.h.

Referenced by getSingleton().

virtual makefile::Makefile::~Makefile  )  [inline, virtual]
 

Definition at line 55 of file Makefile.h.


Member Function Documentation

void makefile::Makefile::add MakefileItem item  )  [inline]
 

Adds a MakefileItem to a list of existing Items.

This adds a MakefileItem to the output order. Only items added are output.

Parameters:
item pointer

Definition at line 82 of file Makefile.h.

void makefile::Makefile::clean  )  [static]
 

Definition at line 50 of file Makefile.cpp.

References instance.

Referenced by remove(), trycond(), trymakefile(), and tryrule().

Makefile & makefile::Makefile::getSingleton  )  [static]
 

Examples:
example.cpp.

Definition at line 43 of file Makefile.cpp.

References instance, and Makefile().

Referenced by main(), trycond(), trymakefile(), tryrule(), HuginBase::PanoramaMakefilelibExport::writeMakefile(), and HuginBase::AssistantMakefilelibExport::writeMakefile().

string makefile::Makefile::quote const string in,
Makefile::QuoteMode  mode
[static]
 

Quotes and escapes characters using regular expressions.

Two modes are currently distinguished, depending on the usage of the string. The regular expressions need a lot of backslash escaping, eg. \\ means backslash. We need to get through the compiler and the boost::regex library with the special characters

The replacements in detail:

  • Shell mode
    • WIN32: $ --> $$, \ --> /, # --> #, and surround with quotes
    • others: $ --> $$, [\ ~"|'`{}[]()*#:=&] --> escape with backslash
  • Make mode
    • WIN32: $ --> $$, [ #=] --> escape with backslash
    • others: $ --> $$, [ #:=] --> escape with backslash

All replacements take care of variable references and do not replace patterns.

Note:
src/hugin_base/hugin_utils/platform.h is where the information is from. Unfortunately there are lots of comments in that code, which say that the correctness of the escaping rules is rather unsure.
Parameters:
in Input string.
mode switch.
Returns:
A new string containing the processed content.

Definition at line 93 of file Makefile.cpp.

References cstr, makefile::regex, and makefile::string.

Referenced by HuginBase::PanoramaMakefilelibExport::createItems(), and tryreplace().

void makefile::Makefile::remove MakefileItem item  )  [static]
 

Removes a MakefileItem to a list of existing Items.

MakefileItem::~MakefileItem removes itself using this. We have to make sure that we don't hold pointers to non-existing MakefileItems.

Note:
The easiest way is to wipe the whole Makefile singleton, so if one MakefileItem is destructed, we loose the pointers to all the others too. This is ok if removing an item while needing the rest is not a use case. And if memory handling is not done by this class.
Todo:
Should it be necessary, implement this remove method to not throw everyting away.
Parameters:
item pointer

Definition at line 57 of file Makefile.cpp.

References clean(), instance, and written.

int makefile::Makefile::writeMakefile ostream out  ) 
 

Outputs all known MakefileItem to an ostream.

Parameters:
out ostream to write the Makefile to.
Returns:

Definition at line 143 of file Makefile.cpp.

References items, out, and written.

Referenced by main(), trycond(), trymakefile(), tryrule(), HuginBase::PanoramaMakefilelibExport::writeMakefile(), and HuginBase::AssistantMakefilelibExport::writeMakefile().


Member Data Documentation

Makefile * makefile::Makefile::instance = NULL [static, private]
 

Definition at line 32 of file Makefile.cpp.

Referenced by clean(), getSingleton(), and remove().

std::vector<MakefileItem*> makefile::Makefile::items [private]
 

Holds pointers to every existing MakefileItem.

Definition at line 49 of file Makefile.h.

Referenced by writeMakefile().

const std::locale makefile::Makefile::locale [static]
 

Used for numeric output to get a decimal dot anyways.

We use the "C" locale for NUMERIC and the system's for everything else.

Note:
: C++ locales are different from C. Calling setlocale doesn't influence C++ streams!

bool makefile::Makefile::written [private]
 

has the makefile been written?

Definition at line 51 of file Makefile.h.

Referenced by remove(), and writeMakefile().


The documentation for this class was generated from the following files:
Generated on Thu Apr 24 01:25:51 2014 for Hugintrunk by  doxygen 1.3.9.1