ENH:Documentation and cleanups
This commit is contained in:
parent
336f3e80db
commit
88bbc0c30d
|
@ -54,11 +54,11 @@ int main(int ac, char** av)
|
||||||
cmMSProjectGenerator* pg = new cmMSProjectGenerator;
|
cmMSProjectGenerator* pg = new cmMSProjectGenerator;
|
||||||
if(arg.find("-DSP", 0) != std::string::npos)
|
if(arg.find("-DSP", 0) != std::string::npos)
|
||||||
{
|
{
|
||||||
pg->SetBuildDSP();
|
pg->BuildDSPOff();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
pg->SetBuildDSW();
|
pg->BuildDSWOn();
|
||||||
}
|
}
|
||||||
builder.SetMakefileGenerator(pg);
|
builder.SetMakefileGenerator(pg);
|
||||||
builder.ReadMakefile(av[1]);
|
builder.ReadMakefile(av[1]);
|
||||||
|
|
|
@ -1,3 +1,18 @@
|
||||||
|
/*=========================================================================
|
||||||
|
|
||||||
|
Program: Insight Segmentation & Registration Toolkit
|
||||||
|
Module: $RCSfile$
|
||||||
|
Language: C++
|
||||||
|
Date: $Date$
|
||||||
|
Version: $Revision$
|
||||||
|
|
||||||
|
|
||||||
|
Copyright (c) 2000 National Library of Medicine
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
See COPYRIGHT.txt for copyright details.
|
||||||
|
|
||||||
|
=========================================================================*/
|
||||||
#include "cmAddTargetRule.h"
|
#include "cmAddTargetRule.h"
|
||||||
|
|
||||||
// cmAddTargetRule
|
// cmAddTargetRule
|
||||||
|
|
|
@ -1,3 +1,18 @@
|
||||||
|
/*=========================================================================
|
||||||
|
|
||||||
|
Program: Insight Segmentation & Registration Toolkit
|
||||||
|
Module: $RCSfile$
|
||||||
|
Language: C++
|
||||||
|
Date: $Date$
|
||||||
|
Version: $Revision$
|
||||||
|
|
||||||
|
|
||||||
|
Copyright (c) 2000 National Library of Medicine
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
See COPYRIGHT.txt for copyright details.
|
||||||
|
|
||||||
|
=========================================================================*/
|
||||||
#include "cmAuxSourceDirectoryRule.h"
|
#include "cmAuxSourceDirectoryRule.h"
|
||||||
#include "cmDirectory.h"
|
#include "cmDirectory.h"
|
||||||
|
|
||||||
|
|
|
@ -13,39 +13,66 @@
|
||||||
See COPYRIGHT.txt for copyright details.
|
See COPYRIGHT.txt for copyright details.
|
||||||
|
|
||||||
=========================================================================*/
|
=========================================================================*/
|
||||||
/**
|
|
||||||
* cmClassFile a structure that represents a class loaded from
|
|
||||||
* a makefile.
|
|
||||||
*/
|
|
||||||
#ifndef cmClassFile_h
|
#ifndef cmClassFile_h
|
||||||
#define cmClassFile_h
|
#define cmClassFile_h
|
||||||
|
|
||||||
#include "cmStandardIncludes.h"
|
#include "cmStandardIncludes.h"
|
||||||
|
|
||||||
|
/** \class cmClassFile
|
||||||
struct cmClassFile
|
* \brief Represent a class loaded from a makefile.
|
||||||
|
*
|
||||||
|
* cmClassFile is represents a class loaded from
|
||||||
|
* a makefile.
|
||||||
|
*/
|
||||||
|
class cmClassFile
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* Construct instance as a concrete class with both a
|
||||||
|
* .h and .cxx file.
|
||||||
|
*/
|
||||||
cmClassFile()
|
cmClassFile()
|
||||||
{
|
{
|
||||||
m_AbstractClass = false;
|
m_AbstractClass = false;
|
||||||
m_HeaderFileOnly = false;
|
m_HeaderFileOnly = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the name of the file, given the directory
|
* Set the name of the file, given the directory
|
||||||
* the file should be in. Extensions are tried on
|
* the file should be in. Various extensions are tried on
|
||||||
* the name in the directory to find the actual file.
|
* the name (e.g., .cxx, .cpp) in the directory to find the actual file.
|
||||||
*/
|
*/
|
||||||
void SetName(const char* name, const char* dir);
|
void SetName(const char* name, const char* dir);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* print the structure to cout
|
* Print the structure to std::cout.
|
||||||
*/
|
*/
|
||||||
void Print();
|
void Print();
|
||||||
|
|
||||||
bool m_AbstractClass; // is this an abstract class
|
/**
|
||||||
bool m_HeaderFileOnly; // is this file only a header file
|
* Indicate whether the class is abstract (non-instantiable).
|
||||||
std::string m_FullPath; // full path to the file
|
*/
|
||||||
std::string m_ClassName; // class name
|
bool m_AbstractClass;
|
||||||
// list of files that this file depends on
|
|
||||||
|
/**
|
||||||
|
* Indicate whether this class is defined with only the header file.
|
||||||
|
*/
|
||||||
|
bool m_HeaderFileOnly;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The full path to the file.
|
||||||
|
*/
|
||||||
|
std::string m_FullPath;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The file name associated with stripped off directory and extension.
|
||||||
|
* (In most cases this is the name of the class.)
|
||||||
|
*/
|
||||||
|
std::string m_ClassName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The dependencies of this class are gathered here.
|
||||||
|
*/
|
||||||
std::vector<std::string> m_Depends;
|
std::vector<std::string> m_Depends;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -70,7 +70,7 @@ cmDSWMakefile
|
||||||
{
|
{
|
||||||
// Create a new cmDSPMakefile to read the currentDir CMakeLists.txt file
|
// Create a new cmDSPMakefile to read the currentDir CMakeLists.txt file
|
||||||
cmMSProjectGenerator* pg = new cmMSProjectGenerator;
|
cmMSProjectGenerator* pg = new cmMSProjectGenerator;
|
||||||
pg->SetBuildDSP();
|
pg->BuildDSPOff();
|
||||||
cmMakefile* mf = new cmMakefile;
|
cmMakefile* mf = new cmMakefile;
|
||||||
mf->SetMakefileGenerator(pg);
|
mf->SetMakefileGenerator(pg);
|
||||||
// add it to the vector
|
// add it to the vector
|
||||||
|
|
|
@ -13,22 +13,33 @@
|
||||||
See COPYRIGHT.txt for copyright details.
|
See COPYRIGHT.txt for copyright details.
|
||||||
|
|
||||||
=========================================================================*/
|
=========================================================================*/
|
||||||
/**
|
|
||||||
* cmDSWMakefile - class to write a microsoft DSW file.
|
|
||||||
*/
|
|
||||||
#ifndef cmDSWMakefile_h
|
#ifndef cmDSWMakefile_h
|
||||||
#define cmDSWMakefile_h
|
#define cmDSWMakefile_h
|
||||||
|
|
||||||
#include "cmStandardIncludes.h"
|
#include "cmStandardIncludes.h"
|
||||||
#include "cmMakefile.h"
|
#include "cmMakefile.h"
|
||||||
|
|
||||||
class cmDSPMakefile;
|
class cmDSPMakefile;
|
||||||
class cmMSProjectGenerator;
|
class cmMSProjectGenerator;
|
||||||
|
|
||||||
|
/** \class cmDSWMakefile
|
||||||
|
* \brief Write a Microsoft Visual C++ DSW (workspace) file.
|
||||||
|
*
|
||||||
|
* cmDSWMakefile produces a Microsoft Visual C++ DSW (workspace) file.
|
||||||
|
*/
|
||||||
class cmDSWMakefile
|
class cmDSWMakefile
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*/
|
||||||
cmDSWMakefile(cmMakefile*);
|
cmDSWMakefile(cmMakefile*);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate the DSW workspace file.
|
||||||
|
*/
|
||||||
virtual void OutputDSWFile();
|
virtual void OutputDSWFile();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void FindAllCMakeListsFiles(const char* subdir,
|
void FindAllCMakeListsFiles(const char* subdir,
|
||||||
std::vector<cmMSProjectGenerator*>&);
|
std::vector<cmMSProjectGenerator*>&);
|
||||||
|
|
|
@ -70,7 +70,7 @@ cmDSWMakefile
|
||||||
{
|
{
|
||||||
// Create a new cmDSPMakefile to read the currentDir CMakeLists.txt file
|
// Create a new cmDSPMakefile to read the currentDir CMakeLists.txt file
|
||||||
cmMSProjectGenerator* pg = new cmMSProjectGenerator;
|
cmMSProjectGenerator* pg = new cmMSProjectGenerator;
|
||||||
pg->SetBuildDSP();
|
pg->BuildDSPOff();
|
||||||
cmMakefile* mf = new cmMakefile;
|
cmMakefile* mf = new cmMakefile;
|
||||||
mf->SetMakefileGenerator(pg);
|
mf->SetMakefileGenerator(pg);
|
||||||
// add it to the vector
|
// add it to the vector
|
||||||
|
|
|
@ -13,22 +13,33 @@
|
||||||
See COPYRIGHT.txt for copyright details.
|
See COPYRIGHT.txt for copyright details.
|
||||||
|
|
||||||
=========================================================================*/
|
=========================================================================*/
|
||||||
/**
|
|
||||||
* cmDSWMakefile - class to write a microsoft DSW file.
|
|
||||||
*/
|
|
||||||
#ifndef cmDSWMakefile_h
|
#ifndef cmDSWMakefile_h
|
||||||
#define cmDSWMakefile_h
|
#define cmDSWMakefile_h
|
||||||
|
|
||||||
#include "cmStandardIncludes.h"
|
#include "cmStandardIncludes.h"
|
||||||
#include "cmMakefile.h"
|
#include "cmMakefile.h"
|
||||||
|
|
||||||
class cmDSPMakefile;
|
class cmDSPMakefile;
|
||||||
class cmMSProjectGenerator;
|
class cmMSProjectGenerator;
|
||||||
|
|
||||||
|
/** \class cmDSWMakefile
|
||||||
|
* \brief Write a Microsoft Visual C++ DSW (workspace) file.
|
||||||
|
*
|
||||||
|
* cmDSWMakefile produces a Microsoft Visual C++ DSW (workspace) file.
|
||||||
|
*/
|
||||||
class cmDSWMakefile
|
class cmDSWMakefile
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*/
|
||||||
cmDSWMakefile(cmMakefile*);
|
cmDSWMakefile(cmMakefile*);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate the DSW workspace file.
|
||||||
|
*/
|
||||||
virtual void OutputDSWFile();
|
virtual void OutputDSWFile();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void FindAllCMakeListsFiles(const char* subdir,
|
void FindAllCMakeListsFiles(const char* subdir,
|
||||||
std::vector<cmMSProjectGenerator*>&);
|
std::vector<cmMSProjectGenerator*>&);
|
||||||
|
|
|
@ -18,20 +18,19 @@
|
||||||
|
|
||||||
#include "cmStandardIncludes.h"
|
#include "cmStandardIncludes.h"
|
||||||
#include "cmSystemTools.h"
|
#include "cmSystemTools.h"
|
||||||
|
|
||||||
/** \class cmDirectory
|
/** \class cmDirectory
|
||||||
* \brief Portable directory/filename traversal.
|
* \brief Portable directory/filename traversal.
|
||||||
*
|
*
|
||||||
* cmDirectory provides a portable way of finding the names of the files
|
* cmDirectory provides a portable way of finding the names of the files
|
||||||
* in a system directory.
|
* in a system directory.
|
||||||
*
|
*
|
||||||
* cmDirectory works with windows and unix only.
|
* cmDirectory currently works with Windows and Unix operating systems.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
class cmDirectory
|
class cmDirectory
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load the specified directory and load the names of the files
|
* Load the specified directory and load the names of the files
|
||||||
* in that directory. 0 is returned if the directory can not be
|
* in that directory. 0 is returned if the directory can not be
|
||||||
|
@ -52,7 +51,7 @@ public:
|
||||||
private:
|
private:
|
||||||
std::vector<std::string> m_Files; // Array of Files
|
std::vector<std::string> m_Files; // Array of Files
|
||||||
std::string m_Path; // Path to Open'ed directory
|
std::string m_Path; // Path to Open'ed directory
|
||||||
}; // End Class: cmDirectory
|
|
||||||
|
|
||||||
|
}; // End Class: cmDirectory
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -24,7 +24,8 @@
|
||||||
*
|
*
|
||||||
* cmFindProgramRule is used to define a CMake variable
|
* cmFindProgramRule is used to define a CMake variable
|
||||||
* that specifies an executable program. The rule searches
|
* that specifies an executable program. The rule searches
|
||||||
* for a given file in a list of directories.
|
* in the current path (e.g., PATH environment variable) for
|
||||||
|
* an executable that matches one of the supplied names.
|
||||||
*/
|
*/
|
||||||
class cmFindProgramRule : public cmRuleMaker
|
class cmFindProgramRule : public cmRuleMaker
|
||||||
{
|
{
|
||||||
|
@ -74,7 +75,7 @@ public:
|
||||||
virtual const char* FullDocumentation()
|
virtual const char* FullDocumentation()
|
||||||
{
|
{
|
||||||
return
|
return
|
||||||
"FIND_PROGRAM(NAME try1 try2 ...)";
|
"FIND_PROGRAM(NAME executable1 executable2 ...)";
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ cmMSProjectGenerator::cmMSProjectGenerator()
|
||||||
{
|
{
|
||||||
m_DSWMakefile = 0;
|
m_DSWMakefile = 0;
|
||||||
m_DSPMakefile = 0;
|
m_DSPMakefile = 0;
|
||||||
SetBuildDSW();
|
BuildDSWOn();
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmMSProjectGenerator::GenerateMakefile()
|
void cmMSProjectGenerator::GenerateMakefile()
|
||||||
|
|
|
@ -13,28 +13,62 @@
|
||||||
See COPYRIGHT.txt for copyright details.
|
See COPYRIGHT.txt for copyright details.
|
||||||
|
|
||||||
=========================================================================*/
|
=========================================================================*/
|
||||||
/**
|
|
||||||
* cmMSProjectGenerator - class to write a microsoft DSW file.
|
|
||||||
*/
|
|
||||||
#ifndef cmMSProjectGenerator_h
|
#ifndef cmMSProjectGenerator_h
|
||||||
#define cmMSProjectGenerator_h
|
#define cmMSProjectGenerator_h
|
||||||
|
|
||||||
#include "cmStandardIncludes.h"
|
#include "cmStandardIncludes.h"
|
||||||
#include "cmMakefileGenerator.h"
|
#include "cmMakefileGenerator.h"
|
||||||
|
|
||||||
class cmDSPMakefile;
|
class cmDSPMakefile;
|
||||||
class cmDSWMakefile;
|
class cmDSWMakefile;
|
||||||
|
|
||||||
|
/** \class cmMSProjectGenerator
|
||||||
|
* \brief Write a Microsoft Visual C++ DSP (project) file.
|
||||||
|
*
|
||||||
|
* cmMSProjectGenerator produces a Microsoft Visual C++ DSP (project) file.
|
||||||
|
*/
|
||||||
class cmMSProjectGenerator : public cmMakefileGenerator
|
class cmMSProjectGenerator : public cmMakefileGenerator
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
/**
|
||||||
|
* Constructor sets the generation of DSW files on.
|
||||||
|
*/
|
||||||
cmMSProjectGenerator();
|
cmMSProjectGenerator();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Destructor.
|
||||||
|
*/
|
||||||
~cmMSProjectGenerator();
|
~cmMSProjectGenerator();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Produce the makefile (in this case a Microsoft Visual C++ project).
|
||||||
|
*/
|
||||||
virtual void GenerateMakefile();
|
virtual void GenerateMakefile();
|
||||||
void SetBuildDSP() { m_BuildDSW = false;}
|
|
||||||
void SetBuildDSW() { m_BuildDSW = true;}
|
/**
|
||||||
cmDSWMakefile* GetDSWMakefile() { return m_DSWMakefile;}
|
* Turn off the generation of a Microsoft Visual C++ DSP file.
|
||||||
cmDSPMakefile* GetDSPMakefile() { return m_DSPMakefile;}
|
*/
|
||||||
|
void BuildDSPOff()
|
||||||
|
{m_BuildDSW = false;}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Turn on the generation of a Microsoft Visual C++ DSW file.
|
||||||
|
*/
|
||||||
|
void BuildDSWOn()
|
||||||
|
{m_BuildDSW = true;}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve a pointer to a cmDSWMakefile instance.
|
||||||
|
*/
|
||||||
|
cmDSWMakefile* GetDSWMakefile()
|
||||||
|
{return m_DSWMakefile;}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve a pointer to a cmDSPMakefile instance.
|
||||||
|
*/
|
||||||
|
cmDSPMakefile* GetDSPMakefile()
|
||||||
|
{return m_DSPMakefile;}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
cmDSWMakefile* m_DSWMakefile;
|
cmDSWMakefile* m_DSWMakefile;
|
||||||
cmDSPMakefile* m_DSPMakefile;
|
cmDSPMakefile* m_DSPMakefile;
|
||||||
|
|
|
@ -13,9 +13,6 @@
|
||||||
See COPYRIGHT.txt for copyright details.
|
See COPYRIGHT.txt for copyright details.
|
||||||
|
|
||||||
=========================================================================*/
|
=========================================================================*/
|
||||||
/**
|
|
||||||
* cmMakeDepend
|
|
||||||
*/
|
|
||||||
#ifndef cmMakeDepend_h
|
#ifndef cmMakeDepend_h
|
||||||
#define cmMakeDepend_h
|
#define cmMakeDepend_h
|
||||||
|
|
||||||
|
@ -24,39 +21,59 @@
|
||||||
#include "cmRegularExpression.h"
|
#include "cmRegularExpression.h"
|
||||||
#include "cmStandardIncludes.h"
|
#include "cmStandardIncludes.h"
|
||||||
|
|
||||||
|
/** \class cmDependInformation
|
||||||
// This structure stores the depend information
|
* \brief Store dependency information for a single source file.
|
||||||
// for a single source file
|
*
|
||||||
|
* This structure stores the depend information for a single source file.
|
||||||
|
*/
|
||||||
struct cmDependInformation
|
struct cmDependInformation
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Construct with dependency generation marked not done; instance
|
||||||
|
* not placed in cmMakefile's list.
|
||||||
|
*/
|
||||||
cmDependInformation()
|
cmDependInformation()
|
||||||
{
|
{
|
||||||
m_DependDone = false;
|
m_DependDone = false;
|
||||||
m_ClassFileIndex = -1;
|
m_ClassFileIndex = -1;
|
||||||
}
|
}
|
||||||
// index into m_DependInformation array of cmMakeDepend
|
|
||||||
// class, represents the files that this file depends on
|
/**
|
||||||
|
* A list of indices into the m_DependInformation array of cmMakeDepend.
|
||||||
|
* The index represents the files that this file depends on.
|
||||||
|
*/
|
||||||
std::vector<int> m_Indices;
|
std::vector<int> m_Indices;
|
||||||
|
|
||||||
// full path to file
|
/**
|
||||||
|
* Full path to this file.
|
||||||
|
*/
|
||||||
std::string m_FullPath;
|
std::string m_FullPath;
|
||||||
|
|
||||||
// name as include directive uses
|
/**
|
||||||
|
* Name that the include directive uses.
|
||||||
|
*/
|
||||||
std::string m_IncludeName;
|
std::string m_IncludeName;
|
||||||
|
|
||||||
// refers back to the index of the cmMakefile's array
|
/**
|
||||||
// of cmClassFile objects which this class class describes,
|
* The index into the cmMakefile::m_Classes list.
|
||||||
// -1 for files not in the array
|
* The index value of -1 indicates that it is not in the list.
|
||||||
|
*/
|
||||||
int m_ClassFileIndex;
|
int m_ClassFileIndex;
|
||||||
|
|
||||||
// flag to determine if depends have
|
/**
|
||||||
// been done for this file
|
* This flag indicates whether dependency checking has been
|
||||||
|
* performed for this file.
|
||||||
|
*/
|
||||||
bool m_DependDone;
|
bool m_DependDone;
|
||||||
|
|
||||||
// function to add the depends of another file to this one
|
/**
|
||||||
|
* This method adds the dependencies of another file to this one.
|
||||||
|
*/
|
||||||
void MergeInfo(cmDependInformation*);
|
void MergeInfo(cmDependInformation*);
|
||||||
|
|
||||||
// remove duplicate depends from the index list
|
/**
|
||||||
|
* This method removes duplicate depends from the index list.
|
||||||
|
*/
|
||||||
void RemoveDuplicateIndices();
|
void RemoveDuplicateIndices();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -66,43 +83,60 @@ struct cmDependInformation
|
||||||
class cmMakeDepend
|
class cmMakeDepend
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
/**
|
||||||
|
* Construct the object with verbose turned off.
|
||||||
|
*/
|
||||||
cmMakeDepend();
|
cmMakeDepend();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Destructor.
|
||||||
|
*/
|
||||||
~cmMakeDepend();
|
~cmMakeDepend();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the makefile that is used as a source of classes.
|
* Set the makefile that is used as a source of classes.
|
||||||
*/
|
*/
|
||||||
void SetMakefile(cmMakefile* makefile);
|
void SetMakefile(cmMakefile* makefile);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate the depend information
|
* Generate the depend information
|
||||||
*/
|
*/
|
||||||
void DoDepends();
|
void DoDepends();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set a regular expression that include files must match
|
* Set a regular expression that include files must match
|
||||||
* in order to be considered as part of the depend information
|
* in order to be considered as part of the depend information.
|
||||||
*/
|
*/
|
||||||
void SetIncludeRegularExpression(const char* regex);
|
void SetIncludeRegularExpression(const char* regex);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a directory to the search path for include files
|
* Add a directory to the search path for include files.
|
||||||
*/
|
*/
|
||||||
void AddSearchPath(const char*);
|
void AddSearchPath(const char*);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
/**
|
||||||
|
* Add a source file to the search path.
|
||||||
|
*/
|
||||||
void AddFileToSearchPath(const char* filepath);
|
void AddFileToSearchPath(const char* filepath);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find the index into the m_DependInformation array
|
* Find the index into the m_DependInformation array
|
||||||
* that matches the given m_IncludeName
|
* that matches the given m_IncludeName.
|
||||||
*/
|
*/
|
||||||
int FindInformation(const char* includeName);
|
int FindInformation(const char* includeName);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compute the depend information for this class
|
* Compute the depend information for this class.
|
||||||
*/
|
*/
|
||||||
void Depend(cmDependInformation* info);
|
void Depend(cmDependInformation* info);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find the full path name for the given file name.
|
* Find the full path name for the given file name.
|
||||||
* This uses the include directories
|
* This uses the include directories.
|
||||||
*/
|
*/
|
||||||
std::string FullPath(const char*);
|
std::string FullPath(const char*);
|
||||||
private:
|
|
||||||
cmMakefile* m_Makefile;
|
cmMakefile* m_Makefile;
|
||||||
bool m_Verbose;
|
bool m_Verbose;
|
||||||
cmRegularExpression m_IncludeFileRegularExpression;
|
cmRegularExpression m_IncludeFileRegularExpression;
|
||||||
|
|
|
@ -13,162 +13,293 @@
|
||||||
See COPYRIGHT.txt for copyright details.
|
See COPYRIGHT.txt for copyright details.
|
||||||
|
|
||||||
=========================================================================*/
|
=========================================================================*/
|
||||||
/**
|
|
||||||
* cmMakefile - used to parse and store the contents of a
|
|
||||||
* CMakeLists.txt makefile in memory.
|
|
||||||
*/
|
|
||||||
#ifndef cmMakefile_h
|
#ifndef cmMakefile_h
|
||||||
#define cmMakefile_h
|
#define cmMakefile_h
|
||||||
|
|
||||||
#include "cmStandardIncludes.h"
|
#include "cmStandardIncludes.h"
|
||||||
#include "cmClassFile.h"
|
#include "cmClassFile.h"
|
||||||
#include "cmSystemTools.h"
|
#include "cmSystemTools.h"
|
||||||
|
|
||||||
class cmRuleMaker;
|
class cmRuleMaker;
|
||||||
class cmMakefileGenerator;
|
class cmMakefileGenerator;
|
||||||
|
|
||||||
|
/** \class cmMakefile
|
||||||
|
* \brief Process the input CMakeLists.txt file.
|
||||||
|
*
|
||||||
|
* Process and store into memory the input CMakeLists.txt file.
|
||||||
|
* Each CMakeLists.txt file is parsed and the rules found there
|
||||||
|
* are added into the build process.
|
||||||
|
*/
|
||||||
class cmMakefile
|
class cmMakefile
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
/**
|
||||||
|
* Construct an empty makefile.
|
||||||
|
*/
|
||||||
cmMakefile();
|
cmMakefile();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Destructor.
|
||||||
|
*/
|
||||||
~cmMakefile();
|
~cmMakefile();
|
||||||
// Parse a CMakeLists.txt file
|
|
||||||
|
/**
|
||||||
|
* Read and parse a CMakeLists.txt file.
|
||||||
|
*/
|
||||||
bool ReadMakefile(const char* makefile, bool inheriting = false);
|
bool ReadMakefile(const char* makefile, bool inheriting = false);
|
||||||
// Add a wrap generator
|
|
||||||
|
/**
|
||||||
|
* Add a wrapper generator.
|
||||||
|
*/
|
||||||
void AddRuleMaker(cmRuleMaker* );
|
void AddRuleMaker(cmRuleMaker* );
|
||||||
// Set the make file
|
|
||||||
|
/**
|
||||||
|
* Specify the makefile generator. This is platform/compiler
|
||||||
|
* dependent, although the interface is through a generic
|
||||||
|
* superclass.
|
||||||
|
*/
|
||||||
void SetMakefileGenerator(cmMakefileGenerator*);
|
void SetMakefileGenerator(cmMakefileGenerator*);
|
||||||
// Generate the output file
|
|
||||||
|
/**
|
||||||
|
* Produce the output makefile.
|
||||||
|
*/
|
||||||
void GenerateMakefile();
|
void GenerateMakefile();
|
||||||
|
|
||||||
// Print useful stuff to stdout
|
/**
|
||||||
|
* Print the object state to std::cout.
|
||||||
|
*/
|
||||||
void Print();
|
void Print();
|
||||||
|
|
||||||
// cmRuleMaker interfaces
|
/**
|
||||||
|
* Add a custom rule to the build.
|
||||||
|
*/
|
||||||
void AddCustomRule(const char* source,
|
void AddCustomRule(const char* source,
|
||||||
const char* result,
|
const char* result,
|
||||||
const char* command,
|
const char* command,
|
||||||
std::vector<std::string>& depends);
|
std::vector<std::string>& depends);
|
||||||
|
/**
|
||||||
|
* Add a define flag to the build.
|
||||||
|
*/
|
||||||
void AddDefineFlag(const char* definition);
|
void AddDefineFlag(const char* definition);
|
||||||
void AddExecutable(cmClassFile&);
|
|
||||||
void AddLinkLibrary(const char*);
|
|
||||||
void AddLinkDirectory(const char*);
|
|
||||||
void AddSubDirectory(const char*);
|
|
||||||
void AddIncludeDirectory(const char*);
|
|
||||||
void AddDefinition(const char* name, const char* value);
|
|
||||||
void SetProjectName(const char*);
|
|
||||||
void SetLibraryName(const char*);
|
|
||||||
void AddClass(cmClassFile& );
|
|
||||||
void AddExtraDirectory(const char* dir);
|
|
||||||
|
|
||||||
// Set the home directory for the project
|
|
||||||
void SetHomeDirectory(const char* dir)
|
|
||||||
{
|
|
||||||
m_cmHomeDirectory = dir;
|
|
||||||
cmSystemTools::ConvertToUnixSlashes(m_cmHomeDirectory);
|
|
||||||
}
|
|
||||||
const char* GetHomeDirectory()
|
|
||||||
{
|
|
||||||
return m_cmHomeDirectory.c_str();
|
|
||||||
}
|
|
||||||
// Set the current directory in the project
|
|
||||||
void SetCurrentDirectory(const char* dir)
|
|
||||||
{
|
|
||||||
m_cmCurrentDirectory = dir;
|
|
||||||
}
|
|
||||||
const char* GetCurrentDirectory()
|
|
||||||
{
|
|
||||||
return m_cmCurrentDirectory.c_str();
|
|
||||||
}
|
|
||||||
// Set the name of the library that is built by this makefile
|
|
||||||
const char* GetLibraryName()
|
|
||||||
{
|
|
||||||
return m_LibraryName.c_str();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add an executable to the build.
|
||||||
|
*/
|
||||||
|
void AddExecutable(cmClassFile&);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a link library to the build.
|
||||||
|
*/
|
||||||
|
void AddLinkLibrary(const char*);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a link directory to the build.
|
||||||
|
*/
|
||||||
|
void AddLinkDirectory(const char*);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a subdirectory to the build.
|
||||||
|
*/
|
||||||
|
void AddSubDirectory(const char*);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add an include directory to the build.
|
||||||
|
*/
|
||||||
|
void AddIncludeDirectory(const char*);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a variable definition to the build. This variable
|
||||||
|
* can be used in CMake to refer to lists, directories, etc.
|
||||||
|
*/
|
||||||
|
void AddDefinition(const char* name, const char* value);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specify the name of the project for this build.
|
||||||
|
*/
|
||||||
|
void SetProjectName(const char*);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the name of the project for this build.
|
||||||
|
*/
|
||||||
const char* GetProjectName()
|
const char* GetProjectName()
|
||||||
{
|
{
|
||||||
return m_ProjectName.c_str();
|
return m_ProjectName.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the name of the library that is built by this makefile
|
/**
|
||||||
|
* Set the name of the library.
|
||||||
|
*/
|
||||||
|
void SetLibraryName(const char*);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a class/source file to the build.
|
||||||
|
*/
|
||||||
|
void AddClass(cmClassFile& );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add an auxiliary directory to the build.
|
||||||
|
*/
|
||||||
|
void AddExtraDirectory(const char* dir);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specify the home directory for the build.
|
||||||
|
*/
|
||||||
|
void SetHomeDirectory(const char* dir)
|
||||||
|
{
|
||||||
|
m_cmHomeDirectory = dir;
|
||||||
|
cmSystemTools::ConvertToUnixSlashes(m_cmHomeDirectory);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the home directory for the build.
|
||||||
|
*/
|
||||||
|
const char* GetHomeDirectory()
|
||||||
|
{
|
||||||
|
return m_cmHomeDirectory.c_str();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the current directory in the project.
|
||||||
|
*/
|
||||||
|
void SetCurrentDirectory(const char* dir)
|
||||||
|
{
|
||||||
|
m_cmCurrentDirectory = dir;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the current directory in the project.
|
||||||
|
*/
|
||||||
|
const char* GetCurrentDirectory()
|
||||||
|
{
|
||||||
|
return m_cmCurrentDirectory.c_str();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specify the name of the library that is built by this makefile.
|
||||||
|
*/
|
||||||
|
const char* GetLibraryName()
|
||||||
|
{
|
||||||
|
return m_LibraryName.c_str();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the name of the library that is built by this makefile.
|
||||||
|
*/
|
||||||
void SetOutputDirectory(const char* lib)
|
void SetOutputDirectory(const char* lib)
|
||||||
{
|
{
|
||||||
m_OutputDirectory = lib;
|
m_OutputDirectory = lib;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the name of the library that is built by this makefile.
|
||||||
|
*/
|
||||||
const char* GetOutputDirectory()
|
const char* GetOutputDirectory()
|
||||||
{
|
{
|
||||||
return m_OutputDirectory.c_str();
|
return m_OutputDirectory.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the name of the library that is built by this makefile
|
/**
|
||||||
|
* Set the name of the current output directory.
|
||||||
|
*/
|
||||||
void SetOutputHomeDirectory(const char* lib)
|
void SetOutputHomeDirectory(const char* lib)
|
||||||
{
|
{
|
||||||
m_OutputHomeDirectory = lib;
|
m_OutputHomeDirectory = lib;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the name of the current output directory.
|
||||||
|
*/
|
||||||
const char* GetOutputHomeDirectory()
|
const char* GetOutputHomeDirectory()
|
||||||
{
|
{
|
||||||
return m_OutputHomeDirectory.c_str();
|
return m_OutputHomeDirectory.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a list of the build subdirectories.
|
||||||
|
*/
|
||||||
const std::vector<std::string>& GetSubDirectories()
|
const std::vector<std::string>& GetSubDirectories()
|
||||||
{
|
{
|
||||||
return m_SubDirectories;
|
return m_SubDirectories;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a boolean flag indicating whether the build generates
|
||||||
|
* any executables.
|
||||||
|
*/
|
||||||
bool HasExecutables()
|
bool HasExecutables()
|
||||||
{
|
{
|
||||||
return m_Executables;
|
return m_Executables;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a list of include directories in the build.
|
||||||
|
*/
|
||||||
std::vector<std::string>& GetIncludeDirectories()
|
std::vector<std::string>& GetIncludeDirectories()
|
||||||
{
|
{
|
||||||
return m_IncludeDirectories;
|
return m_IncludeDirectories;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a list of link directories in the build.
|
||||||
|
*/
|
||||||
std::vector<std::string>& GetLinkDirectories()
|
std::vector<std::string>& GetLinkDirectories()
|
||||||
{
|
{
|
||||||
return m_LinkDirectories;
|
return m_LinkDirectories;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a list of link libraries in the build.
|
||||||
|
*/
|
||||||
std::vector<std::string>& GetLinkLibraries()
|
std::vector<std::string>& GetLinkLibraries()
|
||||||
{
|
{
|
||||||
return m_LinkLibraries;
|
return m_LinkLibraries;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a list of Win32 link libraries in the build.
|
||||||
|
*/
|
||||||
std::vector<std::string>& GetLinkLibrariesWin32()
|
std::vector<std::string>& GetLinkLibrariesWin32()
|
||||||
{
|
{
|
||||||
return m_LinkLibrariesWin32;
|
return m_LinkLibrariesWin32;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a list of Unix link libraries in the build.
|
||||||
|
*/
|
||||||
std::vector<std::string>& GetLinkLibrariesUnix()
|
std::vector<std::string>& GetLinkLibrariesUnix()
|
||||||
{
|
{
|
||||||
return m_LinkLibrariesUnix;
|
return m_LinkLibrariesUnix;
|
||||||
}
|
}
|
||||||
std::vector<cmClassFile>& GetClasses(){ return m_Classes;}
|
|
||||||
|
/**
|
||||||
|
* Return a list of source files in this makefile.
|
||||||
|
*/
|
||||||
|
std::vector<cmClassFile>& GetClasses()
|
||||||
|
{return m_Classes;}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Obtain a list of auxiliary source directories.
|
||||||
|
*/
|
||||||
std::vector<std::string>& GetAuxSourceDirectories()
|
std::vector<std::string>& GetAuxSourceDirectories()
|
||||||
{ return m_AuxSourceDirectories; }
|
{return m_AuxSourceDirectories;}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Do not use this.
|
||||||
|
*/
|
||||||
std::vector<std::string>& GetMakeVerbatim()
|
std::vector<std::string>& GetMakeVerbatim()
|
||||||
{ return m_MakeVerbatim;}
|
{return m_MakeVerbatim;}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Given a variable name, return its value (as a string).
|
||||||
|
*/
|
||||||
const char* GetDefinition(const char*);
|
const char* GetDefinition(const char*);
|
||||||
|
|
||||||
const char* GetDefineFlags()
|
|
||||||
{ return m_DefineFlags.c_str();}
|
|
||||||
|
|
||||||
private:
|
|
||||||
/**
|
|
||||||
* Look for CMakeLists.txt files to parse in dir,
|
|
||||||
* then in dir's parents, until the SourceHome directory
|
|
||||||
* is found.
|
|
||||||
*/
|
|
||||||
void ParseDirectory(const char* dir);
|
|
||||||
/**
|
/**
|
||||||
* Parse a file for includes links and libs
|
* Get a list of preprocessor define flags.
|
||||||
*/
|
*/
|
||||||
void ExpandVaribles();
|
const char* GetDefineFlags()
|
||||||
void ReadClasses(std::ifstream& fin, bool t);
|
{return m_DefineFlags.c_str();}
|
||||||
friend class cmMakeDepend; // make depend needs direct access
|
|
||||||
// to the m_Classes array
|
|
||||||
void PrintStringVector(const char* s, std::vector<std::string>& v);
|
|
||||||
void AddDefaultRules();
|
|
||||||
protected:
|
protected:
|
||||||
bool m_Executables;
|
bool m_Executables;
|
||||||
std::string m_Prefix;
|
std::string m_Prefix;
|
||||||
|
@ -203,6 +334,26 @@ protected:
|
||||||
StringRuleMakerMap m_RuleMakers;
|
StringRuleMakerMap m_RuleMakers;
|
||||||
std::vector<cmRuleMaker*> m_UsedRuleMakers;
|
std::vector<cmRuleMaker*> m_UsedRuleMakers;
|
||||||
cmMakefileGenerator* m_MakefileGenerator;
|
cmMakefileGenerator* m_MakefileGenerator;
|
||||||
|
|
||||||
|
private:
|
||||||
|
/**
|
||||||
|
* Look for CMakeLists.txt files to parse in dir,
|
||||||
|
* then in dir's parents, until the SourceHome directory
|
||||||
|
* is found.
|
||||||
|
*/
|
||||||
|
void ParseDirectory(const char* dir);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse a file for includes links and libs
|
||||||
|
*/
|
||||||
|
void ExpandVaribles();
|
||||||
|
|
||||||
|
void ReadClasses(std::ifstream& fin, bool t);
|
||||||
|
friend class cmMakeDepend; // make depend needs direct access
|
||||||
|
// to the m_Classes array
|
||||||
|
void PrintStringVector(const char* s, std::vector<std::string>& v);
|
||||||
|
void AddDefaultRules();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,18 +1,47 @@
|
||||||
#ifndef cmMakeFileGenerator_h
|
/*=========================================================================
|
||||||
#define cmMakeFileGenerator_h
|
|
||||||
|
Program: Insight Segmentation & Registration Toolkit
|
||||||
|
Module: $RCSfile$
|
||||||
|
Language: C++
|
||||||
|
Date: $Date$
|
||||||
|
Version: $Revision$
|
||||||
|
|
||||||
|
|
||||||
|
Copyright (c) 2000 National Library of Medicine
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
See COPYRIGHT.txt for copyright details.
|
||||||
|
|
||||||
|
=========================================================================*/
|
||||||
|
#ifndef cmMakefileGenerator_h
|
||||||
|
#define cmMakefileGenerator_h
|
||||||
|
|
||||||
#include "cmStandardIncludes.h"
|
#include "cmStandardIncludes.h"
|
||||||
|
|
||||||
class cmMakefile;
|
class cmMakefile;
|
||||||
struct cmClassFile;
|
class cmClassFile;
|
||||||
|
|
||||||
|
/** \class cmMakefileGenerator
|
||||||
|
* \brief Provide an abstract interface for classes generating makefiles.
|
||||||
|
*
|
||||||
|
* Subclasses of this abstract class generate makefiles for various
|
||||||
|
* platforms.
|
||||||
|
*/
|
||||||
class cmMakefileGenerator
|
class cmMakefileGenerator
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// use the m_Makefile and the m_CustomRules and m_ExtraSourceFiles
|
/**
|
||||||
// to generate the makefile
|
* Set the cmMakefile instance from which to generate the makefile.
|
||||||
virtual void GenerateMakefile() = 0;
|
*/
|
||||||
void SetMakefile(cmMakefile*);
|
void SetMakefile(cmMakefile*);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate the makefile using the m_Makefile, m_CustomRules,
|
||||||
|
* and m_ExtraSourceFiles. All subclasses of cmMakefileGenerator
|
||||||
|
* must implement this method.
|
||||||
|
*/
|
||||||
|
virtual void GenerateMakefile() = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
cmMakefile* m_Makefile;
|
cmMakefile* m_Makefile;
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,3 +1,18 @@
|
||||||
|
/*=========================================================================
|
||||||
|
|
||||||
|
Program: Insight Segmentation & Registration Toolkit
|
||||||
|
Module: $RCSfile$
|
||||||
|
Language: C++
|
||||||
|
Date: $Date$
|
||||||
|
Version: $Revision$
|
||||||
|
|
||||||
|
|
||||||
|
Copyright (c) 2000 National Library of Medicine
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
See COPYRIGHT.txt for copyright details.
|
||||||
|
|
||||||
|
=========================================================================*/
|
||||||
//
|
//
|
||||||
// Copyright (C) 1991 Texas Instruments Incorporated.
|
// Copyright (C) 1991 Texas Instruments Incorporated.
|
||||||
//
|
//
|
||||||
|
@ -16,111 +31,12 @@
|
||||||
// Updated: MBN 12/15/89 Sprinkled "const" qualifiers all over the place!
|
// Updated: MBN 12/15/89 Sprinkled "const" qualifiers all over the place!
|
||||||
// Updated: DLS 03/22/91 New lite version
|
// Updated: DLS 03/22/91 New lite version
|
||||||
//
|
//
|
||||||
// This is the header file for the regular expression class. An object of
|
|
||||||
// this class contains a regular expression, in a special "compiled" format.
|
|
||||||
// This compiled format consists of several slots all kept as the objects
|
|
||||||
// private data. The cmRegularExpression class provides a convenient way to represent
|
|
||||||
// regular expressions. It makes it easy to search for the same regular
|
|
||||||
// expression in many different strings without having to compile a string to
|
|
||||||
// regular expression format more than necessary.
|
|
||||||
//
|
|
||||||
// A regular expression allows a programmer to specify complex patterns that
|
|
||||||
// can be searched for and matched against the character string of a String
|
|
||||||
// object. In its simplest case, a regular expression is a sequence of
|
|
||||||
// characters with which you can search for exact character matches. However,
|
|
||||||
// many times you may not know the exact sequence you want to find, or you may
|
|
||||||
// only want to find a match at the beginning or end of a String. The cmRegularExpression
|
|
||||||
// object allows specification of such patterns by utilizing the following
|
|
||||||
// regular expression meta-characters (note that more one of these
|
|
||||||
// meta-characters can be used in a single regular expression in order to
|
|
||||||
// create complex search patterns):
|
|
||||||
//
|
|
||||||
// ^ Match at beginning of line
|
|
||||||
// $ Match at end of line
|
|
||||||
// . Match any single character
|
|
||||||
// [ ] Match any one character inside the brackets
|
|
||||||
// [^ ] Match any character NOT inside the brackets
|
|
||||||
// - Match any character in range on either side of dash
|
|
||||||
// * Match preceding pattern zero or more times
|
|
||||||
// + Match preceding pattern one or more times
|
|
||||||
// ? Match preceding pattern zero or once only
|
|
||||||
// () Save a matched expression and use it in a further match.
|
|
||||||
//
|
|
||||||
// There are three constructors for cmRegularExpression. One just creates an empty cmRegularExpression
|
|
||||||
// object. Another creates a cmRegularExpression object and initializes it with a regular
|
|
||||||
// expression that is given in the form of a char*. The third takes a
|
|
||||||
// reference to a cmRegularExpression object as an argument and creates an object
|
|
||||||
// initialized with the information from the given cmRegularExpression object.
|
|
||||||
//
|
|
||||||
// The find member function finds the first occurence of the regualr
|
|
||||||
// expression of that object in the string given to find as an argument. Find
|
|
||||||
// returns a boolean, and if true, mutates the private data appropriately.
|
|
||||||
// Find sets pointers to the beginning and end of the thing last found, they
|
|
||||||
// are pointers into the actual string that was searched. The start and end
|
|
||||||
// member functions return indicies into the searched string that correspond
|
|
||||||
// to the beginning and end pointers respectively. The compile member
|
|
||||||
// function takes a char* and puts the compiled version of the char* argument
|
|
||||||
// into the object's private data fields. The == and != operators only check
|
|
||||||
// the to see if the compiled regular expression is the same, and the
|
|
||||||
// deep_equal functions also checks to see if the start and end pointers are
|
|
||||||
// the same. The is_valid function returns false if program is set to NULL,
|
|
||||||
// (i.e. there is no valid compiled exression). The set_invalid function sets
|
|
||||||
// the program to NULL (Warning: this deletes the compiled expression). The
|
|
||||||
// following examples may help clarify regular expression usage:
|
|
||||||
//
|
|
||||||
// * The regular expression "^hello" matches a "hello" only at the
|
|
||||||
// beginning of a line. It would match "hello there" but not "hi,
|
|
||||||
// hello there".
|
|
||||||
//
|
|
||||||
// * The regular expression "long$" matches a "long" only at the end
|
|
||||||
// of a line. It would match "so long\0", but not "long ago".
|
|
||||||
//
|
|
||||||
// * The regular expression "t..t..g" will match anything that has a
|
|
||||||
// "t" then any two characters, another "t", any two characters and
|
|
||||||
// then a "g". It will match "testing", or "test again" but would
|
|
||||||
// not match "toasting"
|
|
||||||
//
|
|
||||||
// * The regular expression "[1-9ab]" matches any number one through
|
|
||||||
// nine, and the characters "a" and "b". It would match "hello 1"
|
|
||||||
// or "begin", but would not match "no-match".
|
|
||||||
//
|
|
||||||
// * The regular expression "[^1-9ab]" matches any character that is
|
|
||||||
// not a number one through nine, or an "a" or "b". It would NOT
|
|
||||||
// match "hello 1" or "begin", but would match "no-match".
|
|
||||||
//
|
|
||||||
// * The regular expression "br* " matches something that begins with
|
|
||||||
// a "b", is followed by zero or more "r"s, and ends in a space. It
|
|
||||||
// would match "brrrrr ", and "b ", but would not match "brrh ".
|
|
||||||
//
|
|
||||||
// * The regular expression "br+ " matches something that begins with
|
|
||||||
// a "b", is followed by one or more "r"s, and ends in a space. It
|
|
||||||
// would match "brrrrr ", and "br ", but would not match "b " or
|
|
||||||
// "brrh ".
|
|
||||||
//
|
|
||||||
// * The regular expression "br? " matches something that begins with
|
|
||||||
// a "b", is followed by zero or one "r"s, and ends in a space. It
|
|
||||||
// would match "br ", and "b ", but would not match "brrrr " or
|
|
||||||
// "brrh ".
|
|
||||||
//
|
|
||||||
// * The regular expression "(..p)b" matches something ending with pb
|
|
||||||
// and beginning with whatever the two characters before the first p
|
|
||||||
// encounterd in the line were. It would find "repb" in "rep drepa
|
|
||||||
// qrepb". The regular expression "(..p)a" would find "repa qrepb"
|
|
||||||
// in "rep drepa qrepb"
|
|
||||||
//
|
|
||||||
// * The regular expression "d(..p)" matches something ending with p,
|
|
||||||
// beginning with d, and having two characters in between that are
|
|
||||||
// the same as the two characters before the first p encounterd in
|
|
||||||
// the line. It would match "drepa qrepb" in "rep drepa qrepb".
|
|
||||||
//
|
|
||||||
|
|
||||||
#include "cmRegularExpression.h" // Include class specification
|
#include "cmRegularExpression.h" // Include class specification
|
||||||
#include "cmStandardIncludes.h"
|
#include "cmStandardIncludes.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
|
||||||
// cmRegularExpression -- Copies the given regular expression.
|
// cmRegularExpression -- Copies the given regular expression.
|
||||||
|
|
||||||
cmRegularExpression::cmRegularExpression (const cmRegularExpression& rxp) {
|
cmRegularExpression::cmRegularExpression (const cmRegularExpression& rxp) {
|
||||||
int ind;
|
int ind;
|
||||||
this->progsize = rxp.progsize; // Copy regular expression size
|
this->progsize = rxp.progsize; // Copy regular expression size
|
||||||
|
@ -144,10 +60,8 @@ cmRegularExpression::cmRegularExpression (const cmRegularExpression& rxp) {
|
||||||
this->regmlen = rxp.regmlen; // Copy remaining private data
|
this->regmlen = rxp.regmlen; // Copy remaining private data
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// operator== -- Returns true if two regular expressions have the same
|
// operator== -- Returns true if two regular expressions have the same
|
||||||
// compiled program for pattern matching.
|
// compiled program for pattern matching.
|
||||||
|
|
||||||
bool cmRegularExpression::operator== (const cmRegularExpression& rxp) const {
|
bool cmRegularExpression::operator== (const cmRegularExpression& rxp) const {
|
||||||
if (this != &rxp) { // Same address?
|
if (this != &rxp) { // Same address?
|
||||||
int ind = this->progsize; // Get regular expression size
|
int ind = this->progsize; // Get regular expression size
|
||||||
|
@ -918,8 +832,9 @@ void regdump ();
|
||||||
static char* regprop ();
|
static char* regprop ();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool cmRegularExpression::find (std::string const& s) {
|
bool cmRegularExpression::find (std::string const& s)
|
||||||
return find(s.c_str());
|
{
|
||||||
|
return find(s.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
See COPYRIGHT.txt for copyright details.
|
See COPYRIGHT.txt for copyright details.
|
||||||
|
|
||||||
=========================================================================*/
|
=========================================================================*/
|
||||||
/// Original Copyright notice:
|
// Original Copyright notice:
|
||||||
// Copyright (C) 1991 Texas Instruments Incorporated.
|
// Copyright (C) 1991 Texas Instruments Incorporated.
|
||||||
//
|
//
|
||||||
// Permission is granted to any individual or institution to use, copy, modify,
|
// Permission is granted to any individual or institution to use, copy, modify,
|
||||||
|
@ -24,11 +24,13 @@
|
||||||
// Texas Instruments Incorporated provides this software "as is" without
|
// Texas Instruments Incorporated provides this software "as is" without
|
||||||
// express or implied warranty.
|
// express or implied warranty.
|
||||||
//
|
//
|
||||||
// .LIBRARY vbl
|
// Created: MNF 06/13/89 Initial Design and Implementation
|
||||||
// .HEADER Basics Package
|
// Updated: LGO 08/09/89 Inherit from Generic
|
||||||
// .INCLUDE cmRegularExpression.h
|
// Updated: MBN 09/07/89 Added conditional exception handling
|
||||||
// .FILE cmRegularExpression.cxx
|
// Updated: MBN 12/15/89 Sprinkled "const" qualifiers all over the place!
|
||||||
|
// Updated: DLS 03/22/91 New lite version
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef cmRegularExpression_h
|
#ifndef cmRegularExpression_h
|
||||||
#define cmRegularExpression_h
|
#define cmRegularExpression_h
|
||||||
|
|
||||||
|
@ -36,83 +38,225 @@
|
||||||
|
|
||||||
const int NSUBEXP = 10;
|
const int NSUBEXP = 10;
|
||||||
|
|
||||||
//: Pattern matching with regular expressions
|
/** \class cmRegularExpression
|
||||||
// A regular expression allows a programmer to specify complex
|
* \brief Implements pattern matching with regular expressions.
|
||||||
// patterns that can be searched for and matched against the
|
*
|
||||||
// character string of a string object. In its simplest form, a
|
* This is the header file for the regular expression class. An object of
|
||||||
// regular expression is a sequence of characters used to
|
* this class contains a regular expression, in a special "compiled" format.
|
||||||
// search for exact character matches. However, many times the
|
* This compiled format consists of several slots all kept as the objects
|
||||||
// exact sequence to be found is not known, or only a match at
|
* private data. The cmRegularExpression class provides a convenient way to
|
||||||
// the beginning or end of a string is desired. The vbl regu-
|
* represent regular expressions. It makes it easy to search for the same
|
||||||
// lar expression class implements regular expression pattern
|
* regular expression in many different strings without having to compile a
|
||||||
// matching as is found and implemented in many UNIX commands
|
* string to regular expression format more than necessary.
|
||||||
// and utilities.
|
*
|
||||||
//
|
* This class implements pattern matching via regular expressions.
|
||||||
// Example: The perl code
|
* A regular expression allows a programmer to specify complex
|
||||||
//
|
* patterns that can be searched for and matched against the
|
||||||
// $filename =~ m"([a-z]+)\.cc";
|
* character string of a string object. In its simplest form, a
|
||||||
// print $1;
|
* regular expression is a sequence of characters used to
|
||||||
//
|
* search for exact character matches. However, many times the
|
||||||
// Is written as follows in C++
|
* exact sequence to be found is not known, or only a match at
|
||||||
//
|
* the beginning or end of a string is desired. The vbl regu-
|
||||||
// vbl_reg_exp re("([a-z]+)\\.cc");
|
* lar expression class implements regular expression pattern
|
||||||
// re.find(filename);
|
* matching as is found and implemented in many UNIX commands
|
||||||
// cerr << re.match(1);
|
* and utilities.
|
||||||
//
|
*
|
||||||
//
|
* Example: The perl code
|
||||||
// The regular expression class provides a convenient mechanism
|
*
|
||||||
// for specifying and manipulating regular expressions. The
|
* $filename =~ m"([a-z]+)\.cc";
|
||||||
// regular expression object allows specification of such pat-
|
* print $1;
|
||||||
// terns by using the following regular expression metacharac-
|
*
|
||||||
// ters:
|
* Is written as follows in C++
|
||||||
//
|
*
|
||||||
// ^ Matches at beginning of a line
|
* vbl_reg_exp re("([a-z]+)\\.cc");
|
||||||
//
|
* re.find(filename);
|
||||||
// $ Matches at end of a line
|
* cerr << re.match(1);
|
||||||
//
|
*
|
||||||
// . Matches any single character
|
*
|
||||||
//
|
* The regular expression class provides a convenient mechanism
|
||||||
// [ ] Matches any character(s) inside the brackets
|
* for specifying and manipulating regular expressions. The
|
||||||
//
|
* regular expression object allows specification of such pat-
|
||||||
// [^ ] Matches any character(s) not inside the brackets
|
* terns by using the following regular expression metacharac-
|
||||||
//
|
* ters:
|
||||||
// - Matches any character in range on either side of a dash
|
*
|
||||||
//
|
* ^ Matches at beginning of a line
|
||||||
// * Matches preceding pattern zero or more times
|
*
|
||||||
//
|
* $ Matches at end of a line
|
||||||
// + Matches preceding pattern one or more times
|
*
|
||||||
//
|
* . Matches any single character
|
||||||
// ? Matches preceding pattern zero or once only
|
*
|
||||||
//
|
* [ ] Matches any character(s) inside the brackets
|
||||||
// () Saves a matched expression and uses it in a later match
|
*
|
||||||
//
|
* [^ ] Matches any character(s) not inside the brackets
|
||||||
// Note that more than one of these metacharacters can be used
|
*
|
||||||
// in a single regular expression in order to create complex
|
* - Matches any character in range on either side of a dash
|
||||||
// search patterns. For example, the pattern [^ab1-9] says to
|
*
|
||||||
// match any character sequence that does not begin with the
|
* * Matches preceding pattern zero or more times
|
||||||
// characters "ab" followed by numbers in the series one
|
*
|
||||||
// through nine.
|
* + Matches preceding pattern one or more times
|
||||||
//
|
*
|
||||||
class cmRegularExpression {
|
* ? Matches preceding pattern zero or once only
|
||||||
|
*
|
||||||
|
* () Saves a matched expression and uses it in a later match
|
||||||
|
*
|
||||||
|
* Note that more than one of these metacharacters can be used
|
||||||
|
* in a single regular expression in order to create complex
|
||||||
|
* search patterns. For example, the pattern [^ab1-9] says to
|
||||||
|
* match any character sequence that does not begin with the
|
||||||
|
* characters "ab" followed by numbers in the series one
|
||||||
|
* through nine.
|
||||||
|
*
|
||||||
|
* There are three constructors for cmRegularExpression. One just creates an
|
||||||
|
* empty cmRegularExpression object. Another creates a cmRegularExpression
|
||||||
|
* object and initializes it with a regular expression that is given in the
|
||||||
|
* form of a char*. The third takes a reference to a cmRegularExpression
|
||||||
|
* object as an argument and creates an object initialized with the
|
||||||
|
* information from the given cmRegularExpression object.
|
||||||
|
*
|
||||||
|
* The find member function finds the first occurence of the regualr
|
||||||
|
* expression of that object in the string given to find as an argument. Find
|
||||||
|
* returns a boolean, and if true, mutates the private data appropriately.
|
||||||
|
* Find sets pointers to the beginning and end of the thing last found, they
|
||||||
|
* are pointers into the actual string that was searched. The start and end
|
||||||
|
* member functions return indicies into the searched string that correspond
|
||||||
|
* to the beginning and end pointers respectively. The compile member
|
||||||
|
* function takes a char* and puts the compiled version of the char* argument
|
||||||
|
* into the object's private data fields. The == and != operators only check
|
||||||
|
* the to see if the compiled regular expression is the same, and the
|
||||||
|
* deep_equal functions also checks to see if the start and end pointers are
|
||||||
|
* the same. The is_valid function returns false if program is set to NULL,
|
||||||
|
* (i.e. there is no valid compiled exression). The set_invalid function sets
|
||||||
|
* the program to NULL (Warning: this deletes the compiled expression). The
|
||||||
|
* following examples may help clarify regular expression usage:
|
||||||
|
*
|
||||||
|
* * The regular expression "^hello" matches a "hello" only at the
|
||||||
|
* beginning of a line. It would match "hello there" but not "hi,
|
||||||
|
* hello there".
|
||||||
|
*
|
||||||
|
* * The regular expression "long$" matches a "long" only at the end
|
||||||
|
* of a line. It would match "so long\0", but not "long ago".
|
||||||
|
*
|
||||||
|
* * The regular expression "t..t..g" will match anything that has a
|
||||||
|
* "t" then any two characters, another "t", any two characters and
|
||||||
|
* then a "g". It will match "testing", or "test again" but would
|
||||||
|
* not match "toasting"
|
||||||
|
*
|
||||||
|
* * The regular expression "[1-9ab]" matches any number one through
|
||||||
|
* nine, and the characters "a" and "b". It would match "hello 1"
|
||||||
|
* or "begin", but would not match "no-match".
|
||||||
|
*
|
||||||
|
* * The regular expression "[^1-9ab]" matches any character that is
|
||||||
|
* not a number one through nine, or an "a" or "b". It would NOT
|
||||||
|
* match "hello 1" or "begin", but would match "no-match".
|
||||||
|
*
|
||||||
|
* * The regular expression "br* " matches something that begins with
|
||||||
|
* a "b", is followed by zero or more "r"s, and ends in a space. It
|
||||||
|
* would match "brrrrr ", and "b ", but would not match "brrh ".
|
||||||
|
*
|
||||||
|
* * The regular expression "br+ " matches something that begins with
|
||||||
|
* a "b", is followed by one or more "r"s, and ends in a space. It
|
||||||
|
* would match "brrrrr ", and "br ", but would not match "b " or
|
||||||
|
* "brrh ".
|
||||||
|
*
|
||||||
|
* * The regular expression "br? " matches something that begins with
|
||||||
|
* a "b", is followed by zero or one "r"s, and ends in a space. It
|
||||||
|
* would match "br ", and "b ", but would not match "brrrr " or
|
||||||
|
* "brrh ".
|
||||||
|
*
|
||||||
|
* * The regular expression "(..p)b" matches something ending with pb
|
||||||
|
* and beginning with whatever the two characters before the first p
|
||||||
|
* encounterd in the line were. It would find "repb" in "rep drepa
|
||||||
|
* qrepb". The regular expression "(..p)a" would find "repa qrepb"
|
||||||
|
* in "rep drepa qrepb"
|
||||||
|
*
|
||||||
|
* * The regular expression "d(..p)" matches something ending with p,
|
||||||
|
* beginning with d, and having two characters in between that are
|
||||||
|
* the same as the two characters before the first p encounterd in
|
||||||
|
* the line. It would match "drepa qrepb" in "rep drepa qrepb".
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
class cmRegularExpression
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
inline cmRegularExpression (); // cmRegularExpression with program=NULL
|
/**
|
||||||
inline cmRegularExpression (char const*); // cmRegularExpression with compiled char*
|
* Instantiate cmRegularExpression with program=NULL.
|
||||||
cmRegularExpression (cmRegularExpression const&); // Copy constructor
|
*/
|
||||||
inline ~cmRegularExpression(); // Destructor
|
inline cmRegularExpression ();
|
||||||
|
|
||||||
void compile (char const*); // Compiles char* --> regexp
|
/**
|
||||||
bool find (char const*); // true if regexp in char* arg
|
* Instantiate cmRegularExpression with compiled char*.
|
||||||
bool find (std::string const&); // true if regexp in char* arg
|
*/
|
||||||
inline long start() const; // Index to start of first find
|
inline cmRegularExpression (char const*);
|
||||||
inline long end() const; // Index to end of first find
|
|
||||||
|
|
||||||
bool operator== (cmRegularExpression const&) const; // Equality operator
|
|
||||||
inline bool operator!= (cmRegularExpression const&) const; // Inequality operator
|
|
||||||
bool deep_equal (cmRegularExpression const&) const; // Same regexp and state?
|
|
||||||
|
|
||||||
inline bool is_valid() const; // true if compiled regexp
|
/**
|
||||||
inline void set_invalid(); // Invalidates regexp
|
* Instantiate cmRegularExpression as a copy of another regular expression.
|
||||||
|
*/
|
||||||
|
cmRegularExpression (cmRegularExpression const&);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Destructor.
|
||||||
|
*/
|
||||||
|
inline ~cmRegularExpression();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compile a regular expression into internal code
|
||||||
|
* for later pattern matching.
|
||||||
|
*/
|
||||||
|
void compile (char const*);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Matches the regular expression to the given string.
|
||||||
|
* Returns true if found, and sets start and end indexes accordingly.
|
||||||
|
*/
|
||||||
|
bool find (char const*);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Matches the regular expression to the given std string.
|
||||||
|
* Returns true if found, and sets start and end indexes accordingly.
|
||||||
|
*/
|
||||||
|
bool find (std::string const&);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Index to start of first find.
|
||||||
|
*/
|
||||||
|
inline long start() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Index to end of first find.
|
||||||
|
*/
|
||||||
|
inline long end() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if two regular expressions have the same
|
||||||
|
* compiled program for pattern matching.
|
||||||
|
*/
|
||||||
|
bool operator== (cmRegularExpression const&) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if two regular expressions have different
|
||||||
|
* compiled program for pattern matching.
|
||||||
|
*/
|
||||||
|
inline bool operator!= (cmRegularExpression const&) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if have the same compiled regular expressions
|
||||||
|
* and the same start and end pointers.
|
||||||
|
*/
|
||||||
|
bool deep_equal (cmRegularExpression const&) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* True if the compiled regexp is valid.
|
||||||
|
*/
|
||||||
|
inline bool is_valid() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Marks the regular expression as invalid.
|
||||||
|
*/
|
||||||
|
inline void set_invalid();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Destructor.
|
||||||
|
*/
|
||||||
// awf added
|
// awf added
|
||||||
int start(int n) const;
|
int start(int n) const;
|
||||||
int end(int n) const;
|
int end(int n) const;
|
||||||
|
@ -130,82 +274,98 @@ private:
|
||||||
const char* searchstring;
|
const char* searchstring;
|
||||||
};
|
};
|
||||||
|
|
||||||
// cmRegularExpression -- Creates an empty regular expression.
|
/**
|
||||||
|
* Create an empty regular expression.
|
||||||
inline cmRegularExpression::cmRegularExpression () {
|
*/
|
||||||
|
inline cmRegularExpression::cmRegularExpression ()
|
||||||
|
{
|
||||||
this->program = NULL;
|
this->program = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
// cmRegularExpression -- Creates a regular expression from string s, and
|
* Creates a regular expression from string s, and
|
||||||
// compiles s.
|
* compiles s.
|
||||||
|
*/
|
||||||
|
inline cmRegularExpression::cmRegularExpression (const char* s)
|
||||||
inline cmRegularExpression::cmRegularExpression (const char* s) {
|
{
|
||||||
this->program = NULL;
|
this->program = NULL;
|
||||||
compile(s);
|
compile(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ~cmRegularExpression -- Frees space allocated for regular expression.
|
/**
|
||||||
|
* Destroys and frees space allocated for the regular expression.
|
||||||
inline cmRegularExpression::~cmRegularExpression () {
|
*/
|
||||||
|
inline cmRegularExpression::~cmRegularExpression ()
|
||||||
|
{
|
||||||
//#ifndef WIN32
|
//#ifndef WIN32
|
||||||
delete [] this->program;
|
delete [] this->program;
|
||||||
//#endif
|
//#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start --
|
/**
|
||||||
|
* Set the start position for the regular expression.
|
||||||
inline long cmRegularExpression::start () const {
|
*/
|
||||||
|
inline long cmRegularExpression::start () const
|
||||||
|
{
|
||||||
return(this->startp[0] - searchstring);
|
return(this->startp[0] - searchstring);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// End -- Returns the start/end index of the last item found.
|
/**
|
||||||
|
* Returns the start/end index of the last item found.
|
||||||
|
*/
|
||||||
inline long cmRegularExpression::end () const {
|
inline long cmRegularExpression::end () const
|
||||||
|
{
|
||||||
return(this->endp[0] - searchstring);
|
return(this->endp[0] - searchstring);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
// operator!= //
|
* Returns true if two regular expressions have different
|
||||||
|
* compiled program for pattern matching.
|
||||||
inline bool cmRegularExpression::operator!= (const cmRegularExpression& r) const {
|
*/
|
||||||
|
inline bool cmRegularExpression::operator!= (const cmRegularExpression& r) const
|
||||||
|
{
|
||||||
return(!(*this == r));
|
return(!(*this == r));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
// is_valid -- Returns true if a valid regular expression is compiled
|
* Returns true if a valid regular expression is compiled
|
||||||
// and ready for pattern matching.
|
* and ready for pattern matching.
|
||||||
|
*/
|
||||||
inline bool cmRegularExpression::is_valid () const {
|
inline bool cmRegularExpression::is_valid () const
|
||||||
|
{
|
||||||
return (this->program != NULL);
|
return (this->program != NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// set_invalid -- Invalidates regular expression.
|
inline void cmRegularExpression::set_invalid ()
|
||||||
|
{
|
||||||
inline void cmRegularExpression::set_invalid () {
|
|
||||||
//#ifndef WIN32
|
//#ifndef WIN32
|
||||||
delete [] this->program;
|
delete [] this->program;
|
||||||
//#endif
|
//#endif
|
||||||
this->program = NULL;
|
this->program = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// -- Return start index of nth submatch. start(0) is the start of the full match.
|
/**
|
||||||
|
* Return start index of nth submatch. start(0) is the start of the full match.
|
||||||
|
*/
|
||||||
inline int cmRegularExpression::start(int n) const
|
inline int cmRegularExpression::start(int n) const
|
||||||
{
|
{
|
||||||
return this->startp[n] - searchstring;
|
return this->startp[n] - searchstring;
|
||||||
}
|
}
|
||||||
|
|
||||||
// -- Return end index of nth submatch. end(0) is the end of the full match.
|
|
||||||
|
/**
|
||||||
|
* Return end index of nth submatch. end(0) is the end of the full match.
|
||||||
|
*/
|
||||||
inline int cmRegularExpression::end(int n) const
|
inline int cmRegularExpression::end(int n) const
|
||||||
{
|
{
|
||||||
return this->endp[n] - searchstring;
|
return this->endp[n] - searchstring;
|
||||||
}
|
}
|
||||||
|
|
||||||
// -- Return nth submatch as a string.
|
/**
|
||||||
|
* Return nth submatch as a string.
|
||||||
|
*/
|
||||||
inline std::string cmRegularExpression::match(int n) const
|
inline std::string cmRegularExpression::match(int n) const
|
||||||
{
|
{
|
||||||
return std::string(this->startp[n], this->endp[n] - this->startp[n]);
|
return std::string(this->startp[n], this->endp[n] - this->startp[n]);
|
||||||
|
|
|
@ -1,3 +1,22 @@
|
||||||
|
/*=========================================================================
|
||||||
|
|
||||||
|
Program: Insight Segmentation & Registration Toolkit
|
||||||
|
Module: $RCSfile$
|
||||||
|
Language: C++
|
||||||
|
Date: $Date$
|
||||||
|
Version: $Revision$
|
||||||
|
|
||||||
|
|
||||||
|
Copyright (c) 2000 National Library of Medicine
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
See COPYRIGHT.txt for copyright details.
|
||||||
|
|
||||||
|
=========================================================================*/
|
||||||
|
/**
|
||||||
|
* Include header files as a function of the build process, compiler,
|
||||||
|
* and operating system.
|
||||||
|
*/
|
||||||
#ifndef cmStandardIncludes_h
|
#ifndef cmStandardIncludes_h
|
||||||
#define cmStandardIncludes_h
|
#define cmStandardIncludes_h
|
||||||
|
|
||||||
|
|
|
@ -79,13 +79,13 @@ bool cmSystemTools::FileExists(const char* filename)
|
||||||
{
|
{
|
||||||
struct stat fs;
|
struct stat fs;
|
||||||
if (stat(filename, &fs) != 0)
|
if (stat(filename, &fs) != 0)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -13,14 +13,17 @@
|
||||||
See COPYRIGHT.txt for copyright details.
|
See COPYRIGHT.txt for copyright details.
|
||||||
|
|
||||||
=========================================================================*/
|
=========================================================================*/
|
||||||
/**
|
|
||||||
* cmSystemTools - a collection of useful functions for CMake.
|
|
||||||
*/
|
|
||||||
#ifndef cmSystemTools_h
|
#ifndef cmSystemTools_h
|
||||||
#define cmSystemTools_h
|
#define cmSystemTools_h
|
||||||
|
|
||||||
#include "cmStandardIncludes.h"
|
#include "cmStandardIncludes.h"
|
||||||
|
|
||||||
|
/** \class cmSystemTools
|
||||||
|
* \brief A collection of useful functions for CMake.
|
||||||
|
*
|
||||||
|
* cmSystemTools is a class that provides helper functions
|
||||||
|
* for the CMake build system.
|
||||||
|
*/
|
||||||
class cmSystemTools
|
class cmSystemTools
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -30,47 +33,54 @@ public:
|
||||||
* prior to calling this function.
|
* prior to calling this function.
|
||||||
*/
|
*/
|
||||||
static bool MakeDirectory(const char* path);
|
static bool MakeDirectory(const char* path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Replace replace all occurances of the string in in
|
* Replace replace all occurances of the string in
|
||||||
* souce string.
|
* the source string.
|
||||||
*/
|
*/
|
||||||
static void ReplaceString(std::string& source,
|
static void ReplaceString(std::string& source,
|
||||||
const char* replace,
|
const char* replace,
|
||||||
const char* with);
|
const char* with);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Replace windows slashes with unix style slashes
|
* Replace Windows file system slashes with Unix-style slashes.
|
||||||
*/
|
*/
|
||||||
static void ConvertToUnixSlashes(std::string& path);
|
static void ConvertToUnixSlashes(std::string& path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return true if a file exists
|
* Return true if a file exists in the current directory.
|
||||||
*/
|
*/
|
||||||
static bool FileExists(const char* filename);
|
static bool FileExists(const char* filename);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the number of times expression occurs in file in dir
|
* Return the number of times the given expression occurs in the file
|
||||||
|
* specified by the concatenation of dir/file.
|
||||||
*/
|
*/
|
||||||
static int Grep(const char* dir, const char* file, const char* expression);
|
static int Grep(const char* dir, const char* file, const char* expression);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* remove /cygdrive/d and replace with d:/
|
* Convert a path containing a cygwin drive specifier to its natural
|
||||||
|
* equivalent.
|
||||||
*/
|
*/
|
||||||
static void ConvertCygwinPath(std::string& pathname);
|
static void ConvertCygwinPath(std::string& pathname);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read a cmake function from an input file. This
|
* Read a CMake rule (or function) from an input file. This
|
||||||
* returns the name of the function and a list of its
|
* returns the name of the function and a list of its
|
||||||
* arguments.
|
* arguments.
|
||||||
*/
|
*/
|
||||||
static bool ParseFunction(std::ifstream&,
|
static bool ParseFunction(std::ifstream&,
|
||||||
std::string& name,
|
std::string& name,
|
||||||
std::vector<std::string>& arguments);
|
std::vector<std::string>& arguments);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extract space separated arguments from a string.
|
* Extract white-space separated arguments from a string.
|
||||||
* Double quoted strings are accepted with spaces.
|
* Double quoted strings are accepted with spaces.
|
||||||
* This is called by ParseFunction.
|
* This is called by ParseFunction.
|
||||||
*/
|
*/
|
||||||
static void GetArguments(std::string& line,
|
static void GetArguments(std::string& line,
|
||||||
std::vector<std::string>& arguments);
|
std::vector<std::string>& arguments);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Display an error message.
|
* Display an error message.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,3 +1,18 @@
|
||||||
|
/*=========================================================================
|
||||||
|
|
||||||
|
Program: Insight Segmentation & Registration Toolkit
|
||||||
|
Module: $RCSfile$
|
||||||
|
Language: C++
|
||||||
|
Date: $Date$
|
||||||
|
Version: $Revision$
|
||||||
|
|
||||||
|
|
||||||
|
Copyright (c) 2000 National Library of Medicine
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
See COPYRIGHT.txt for copyright details.
|
||||||
|
|
||||||
|
=========================================================================*/
|
||||||
#include "cmUnixMakefileGenerator.h"
|
#include "cmUnixMakefileGenerator.h"
|
||||||
#include "cmMakefile.h"
|
#include "cmMakefile.h"
|
||||||
#include "cmStandardIncludes.h"
|
#include "cmStandardIncludes.h"
|
||||||
|
@ -13,7 +28,6 @@ void cmUnixMakefileGenerator::GenerateMakefile()
|
||||||
this->OutputMakefile("CMakeTargets.make");
|
this->OutputMakefile("CMakeTargets.make");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Output the depend information for all the classes
|
// Output the depend information for all the classes
|
||||||
// in the makefile. These would have been generated
|
// in the makefile. These would have been generated
|
||||||
// by the class cmMakeDepend GenerateMakefile
|
// by the class cmMakeDepend GenerateMakefile
|
||||||
|
|
|
@ -13,23 +13,33 @@
|
||||||
See COPYRIGHT.txt for copyright details.
|
See COPYRIGHT.txt for copyright details.
|
||||||
|
|
||||||
=========================================================================*/
|
=========================================================================*/
|
||||||
/**
|
|
||||||
* itkUnixMakefile is used generate unix makefiles.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef cmUnixMakefileGenerator_h
|
#ifndef cmUnixMakefileGenerator_h
|
||||||
#define cmUnixMakefileGenerator_h
|
#define cmUnixMakefileGenerator_h
|
||||||
|
|
||||||
#include "cmMakefile.h"
|
#include "cmMakefile.h"
|
||||||
#include "cmMakefileGenerator.h"
|
#include "cmMakefileGenerator.h"
|
||||||
|
|
||||||
|
/** \class cmUnixMakefileGenerator
|
||||||
|
* \brief Write a Unix makefiles.
|
||||||
|
*
|
||||||
|
* cmUnixMakefileGenerator produces a Unix makefile from its
|
||||||
|
* member m_Makefile.
|
||||||
|
*/
|
||||||
class cmUnixMakefileGenerator : public cmMakefileGenerator
|
class cmUnixMakefileGenerator : public cmMakefileGenerator
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* Write the makefile to the named file
|
* Produce the makefile (in this case a Unix makefile).
|
||||||
*/
|
*/
|
||||||
virtual void GenerateMakefile();
|
virtual void GenerateMakefile();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Output the depend information for all the classes
|
||||||
|
* in the makefile. These would have been generated
|
||||||
|
* by the class cmMakeDepend.
|
||||||
|
*/
|
||||||
void OutputDepends(std::ostream&);
|
void OutputDepends(std::ostream&);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void OutputMakefile(const char* file);
|
void OutputMakefile(const char* file);
|
||||||
void OutputDependLibraries(std::ostream&);
|
void OutputDependLibraries(std::ostream&);
|
||||||
|
|
|
@ -1,3 +1,18 @@
|
||||||
|
/*=========================================================================
|
||||||
|
|
||||||
|
Program: Insight Segmentation & Registration Toolkit
|
||||||
|
Module: $RCSfile$
|
||||||
|
Language: C++
|
||||||
|
Date: $Date$
|
||||||
|
Version: $Revision$
|
||||||
|
|
||||||
|
|
||||||
|
Copyright (c) 2000 National Library of Medicine
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
See COPYRIGHT.txt for copyright details.
|
||||||
|
|
||||||
|
=========================================================================*/
|
||||||
#include "cmWindowsConfigure.h"
|
#include "cmWindowsConfigure.h"
|
||||||
#include "cmStandardIncludes.h"
|
#include "cmStandardIncludes.h"
|
||||||
#include "cmSystemTools.h"
|
#include "cmSystemTools.h"
|
||||||
|
|
|
@ -13,34 +13,43 @@
|
||||||
See COPYRIGHT.txt for copyright details.
|
See COPYRIGHT.txt for copyright details.
|
||||||
|
|
||||||
=========================================================================*/
|
=========================================================================*/
|
||||||
/**
|
|
||||||
* cmWindowsConfigure : a class that configures the build
|
|
||||||
* on windows where autoconf configure can not be used.
|
|
||||||
* The system specific .h files normal generated by autoconf
|
|
||||||
* should be generated by sub-classes of this class.
|
|
||||||
*/
|
|
||||||
#ifndef cmWindowsConfigure_h
|
#ifndef cmWindowsConfigure_h
|
||||||
#define cmWindowsConfigure_h
|
#define cmWindowsConfigure_h
|
||||||
|
|
||||||
#include "cmStandardIncludes.h"
|
#include "cmStandardIncludes.h"
|
||||||
|
|
||||||
|
/** \class cmWindowsConfigure
|
||||||
|
* \brief Configure the build process on Windows systems.
|
||||||
|
*
|
||||||
|
* cmWindowsConfigure configures the build process
|
||||||
|
* on windows where the Unix autoconf configure can not be used.
|
||||||
|
* The system specific .h files normally generated by autoconf
|
||||||
|
* should be generated by sub-classes of this class.
|
||||||
|
*/
|
||||||
class cmWindowsConfigure
|
class cmWindowsConfigure
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* Set the path to the top level of the source directory
|
* Set the path to the top level of the source directory.
|
||||||
*/
|
*/
|
||||||
void SetWhereSource(const char* dir)
|
void SetWhereSource(const char* dir)
|
||||||
{
|
{
|
||||||
m_WhereSource = dir;
|
m_WhereSource = dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the path to the top level of the build directory
|
* Set the path to the top level of the build directory.
|
||||||
*/
|
*/
|
||||||
void SetWhereBuild(const char* dir)
|
void SetWhereBuild(const char* dir)
|
||||||
{
|
{
|
||||||
m_WhereBuild = dir;
|
m_WhereBuild = dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Perform the configure process.
|
||||||
|
*/
|
||||||
virtual bool Configure(const char* input);
|
virtual bool Configure(const char* input);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::string m_WhereSource;
|
std::string m_WhereSource;
|
||||||
std::string m_WhereBuild;
|
std::string m_WhereBuild;
|
||||||
|
|
Loading…
Reference in New Issue