ENH:Documentation and cleanups

This commit is contained in:
Will Schroeder 2001-01-11 14:47:38 -05:00
parent 336f3e80db
commit 88bbc0c30d
24 changed files with 882 additions and 403 deletions

View File

@ -54,11 +54,11 @@ int main(int ac, char** av)
cmMSProjectGenerator* pg = new cmMSProjectGenerator;
if(arg.find("-DSP", 0) != std::string::npos)
{
pg->SetBuildDSP();
pg->BuildDSPOff();
}
else
{
pg->SetBuildDSW();
pg->BuildDSWOn();
}
builder.SetMakefileGenerator(pg);
builder.ReadMakefile(av[1]);

View File

@ -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"
// cmAddTargetRule

View File

@ -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 "cmDirectory.h"

View File

@ -13,39 +13,66 @@
See COPYRIGHT.txt for copyright details.
=========================================================================*/
/**
* cmClassFile a structure that represents a class loaded from
* a makefile.
*/
#ifndef cmClassFile_h
#define cmClassFile_h
#include "cmStandardIncludes.h"
struct cmClassFile
/** \class 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()
{
m_AbstractClass = false;
m_HeaderFileOnly = false;
m_AbstractClass = false;
m_HeaderFileOnly = false;
}
/**
* Set the name of the file, given the directory
* the file should be in. Extensions are tried on
* the name in the directory to find the actual file.
* the file should be in. Various extensions are tried on
* the name (e.g., .cxx, .cpp) in the directory to find the actual file.
*/
void SetName(const char* name, const char* dir);
/**
* print the structure to cout
* Print the structure to std::cout.
*/
void Print();
bool m_AbstractClass; // is this an abstract class
bool m_HeaderFileOnly; // is this file only a header file
std::string m_FullPath; // full path to the file
std::string m_ClassName; // class name
// list of files that this file depends on
/**
* Indicate whether the class is abstract (non-instantiable).
*/
bool m_AbstractClass;
/**
* 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;
};

View File

@ -70,7 +70,7 @@ cmDSWMakefile
{
// Create a new cmDSPMakefile to read the currentDir CMakeLists.txt file
cmMSProjectGenerator* pg = new cmMSProjectGenerator;
pg->SetBuildDSP();
pg->BuildDSPOff();
cmMakefile* mf = new cmMakefile;
mf->SetMakefileGenerator(pg);
// add it to the vector

View File

@ -13,22 +13,33 @@
See COPYRIGHT.txt for copyright details.
=========================================================================*/
/**
* cmDSWMakefile - class to write a microsoft DSW file.
*/
#ifndef cmDSWMakefile_h
#define cmDSWMakefile_h
#include "cmStandardIncludes.h"
#include "cmMakefile.h"
class cmDSPMakefile;
class cmMSProjectGenerator;
/** \class cmDSWMakefile
* \brief Write a Microsoft Visual C++ DSW (workspace) file.
*
* cmDSWMakefile produces a Microsoft Visual C++ DSW (workspace) file.
*/
class cmDSWMakefile
{
public:
/**
* Constructor.
*/
cmDSWMakefile(cmMakefile*);
/**
* Generate the DSW workspace file.
*/
virtual void OutputDSWFile();
private:
void FindAllCMakeListsFiles(const char* subdir,
std::vector<cmMSProjectGenerator*>&);

View File

@ -70,7 +70,7 @@ cmDSWMakefile
{
// Create a new cmDSPMakefile to read the currentDir CMakeLists.txt file
cmMSProjectGenerator* pg = new cmMSProjectGenerator;
pg->SetBuildDSP();
pg->BuildDSPOff();
cmMakefile* mf = new cmMakefile;
mf->SetMakefileGenerator(pg);
// add it to the vector

View File

@ -13,22 +13,33 @@
See COPYRIGHT.txt for copyright details.
=========================================================================*/
/**
* cmDSWMakefile - class to write a microsoft DSW file.
*/
#ifndef cmDSWMakefile_h
#define cmDSWMakefile_h
#include "cmStandardIncludes.h"
#include "cmMakefile.h"
class cmDSPMakefile;
class cmMSProjectGenerator;
/** \class cmDSWMakefile
* \brief Write a Microsoft Visual C++ DSW (workspace) file.
*
* cmDSWMakefile produces a Microsoft Visual C++ DSW (workspace) file.
*/
class cmDSWMakefile
{
public:
/**
* Constructor.
*/
cmDSWMakefile(cmMakefile*);
/**
* Generate the DSW workspace file.
*/
virtual void OutputDSWFile();
private:
void FindAllCMakeListsFiles(const char* subdir,
std::vector<cmMSProjectGenerator*>&);

View File

@ -18,20 +18,19 @@
#include "cmStandardIncludes.h"
#include "cmSystemTools.h"
/** \class cmDirectory
* \brief Portable directory/filename traversal.
*
* cmDirectory provides a portable way of finding the names of the files
* in a system directory.
*
* cmDirectory works with windows and unix only.
* cmDirectory currently works with Windows and Unix operating systems.
*/
class cmDirectory
{
public:
/**
* Load the specified directory and load the names of the files
* in that directory. 0 is returned if the directory can not be
@ -52,7 +51,7 @@ public:
private:
std::vector<std::string> m_Files; // Array of Files
std::string m_Path; // Path to Open'ed directory
}; // End Class: cmDirectory
#endif

View File

@ -24,7 +24,8 @@
*
* cmFindProgramRule is used to define a CMake variable
* 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
{
@ -74,7 +75,7 @@ public:
virtual const char* FullDocumentation()
{
return
"FIND_PROGRAM(NAME try1 try2 ...)";
"FIND_PROGRAM(NAME executable1 executable2 ...)";
}
};

View File

@ -6,7 +6,7 @@ cmMSProjectGenerator::cmMSProjectGenerator()
{
m_DSWMakefile = 0;
m_DSPMakefile = 0;
SetBuildDSW();
BuildDSWOn();
}
void cmMSProjectGenerator::GenerateMakefile()

View File

@ -13,28 +13,62 @@
See COPYRIGHT.txt for copyright details.
=========================================================================*/
/**
* cmMSProjectGenerator - class to write a microsoft DSW file.
*/
#ifndef cmMSProjectGenerator_h
#define cmMSProjectGenerator_h
#include "cmStandardIncludes.h"
#include "cmMakefileGenerator.h"
class cmDSPMakefile;
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
{
public:
/**
* Constructor sets the generation of DSW files on.
*/
cmMSProjectGenerator();
/**
* Destructor.
*/
~cmMSProjectGenerator();
/**
* Produce the makefile (in this case a Microsoft Visual C++ project).
*/
virtual void GenerateMakefile();
void SetBuildDSP() { m_BuildDSW = false;}
void SetBuildDSW() { m_BuildDSW = true;}
cmDSWMakefile* GetDSWMakefile() { return m_DSWMakefile;}
cmDSPMakefile* GetDSPMakefile() { return m_DSPMakefile;}
/**
* Turn off the generation of a Microsoft Visual C++ DSP file.
*/
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:
cmDSWMakefile* m_DSWMakefile;
cmDSPMakefile* m_DSPMakefile;

View File

@ -13,9 +13,6 @@
See COPYRIGHT.txt for copyright details.
=========================================================================*/
/**
* cmMakeDepend
*/
#ifndef cmMakeDepend_h
#define cmMakeDepend_h
@ -24,39 +21,59 @@
#include "cmRegularExpression.h"
#include "cmStandardIncludes.h"
// This structure stores the depend information
// for a single source file
/** \class cmDependInformation
* \brief Store dependency information for a single source file.
*
* This structure stores the depend information for a single source file.
*/
struct cmDependInformation
{
/**
* Construct with dependency generation marked not done; instance
* not placed in cmMakefile's list.
*/
cmDependInformation()
{
m_DependDone = false;
m_ClassFileIndex = -1;
m_DependDone = false;
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;
// full path to file
/**
* Full path to this file.
*/
std::string m_FullPath;
// name as include directive uses
/**
* Name that the include directive uses.
*/
std::string m_IncludeName;
// refers back to the index of the cmMakefile's array
// of cmClassFile objects which this class class describes,
// -1 for files not in the array
/**
* The index into the cmMakefile::m_Classes list.
* The index value of -1 indicates that it is not in the list.
*/
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;
// 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*);
// remove duplicate depends from the index list
/**
* This method removes duplicate depends from the index list.
*/
void RemoveDuplicateIndices();
};
@ -66,43 +83,60 @@ struct cmDependInformation
class cmMakeDepend
{
public:
/**
* Construct the object with verbose turned off.
*/
cmMakeDepend();
/**
* Destructor.
*/
~cmMakeDepend();
/**
* Set the makefile that is used as a source of classes.
*/
void SetMakefile(cmMakefile* makefile);
/**
* Generate the depend information
*/
void DoDepends();
/**
* 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);
/**
* Add a directory to the search path for include files
* Add a directory to the search path for include files.
*/
void AddSearchPath(const char*);
private:
/**
* Add a source file to the search path.
*/
void AddFileToSearchPath(const char* filepath);
/**
* 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);
/**
* Compute the depend information for this class
* Compute the depend information for this class.
*/
void Depend(cmDependInformation* info);
/**
* 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*);
private:
cmMakefile* m_Makefile;
bool m_Verbose;
cmRegularExpression m_IncludeFileRegularExpression;

View File

@ -13,162 +13,293 @@
See COPYRIGHT.txt for copyright details.
=========================================================================*/
/**
* cmMakefile - used to parse and store the contents of a
* CMakeLists.txt makefile in memory.
*/
#ifndef cmMakefile_h
#define cmMakefile_h
#include "cmStandardIncludes.h"
#include "cmClassFile.h"
#include "cmSystemTools.h"
class cmRuleMaker;
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
{
public:
/**
* Construct an empty makefile.
*/
cmMakefile();
/**
* Destructor.
*/
~cmMakefile();
// Parse a CMakeLists.txt file
/**
* Read and parse a CMakeLists.txt file.
*/
bool ReadMakefile(const char* makefile, bool inheriting = false);
// Add a wrap generator
/**
* Add a wrapper generator.
*/
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*);
// Generate the output file
/**
* Produce the output makefile.
*/
void GenerateMakefile();
// Print useful stuff to stdout
/**
* Print the object state to std::cout.
*/
void Print();
// cmRuleMaker interfaces
/**
* Add a custom rule to the build.
*/
void AddCustomRule(const char* source,
const char* result,
const char* command,
std::vector<std::string>& depends);
/**
* Add a define flag to the build.
*/
void AddDefineFlag(const char* definition);
/**
* 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*);
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();
}
/**
* Get the name of the project for this build.
*/
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)
{
m_OutputDirectory = lib;
m_OutputDirectory = lib;
}
/**
* Get the name of the library that is built by this makefile.
*/
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)
{
m_OutputHomeDirectory = lib;
m_OutputHomeDirectory = lib;
}
/**
* Get the name of the current output directory.
*/
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()
{
return m_SubDirectories;
return m_SubDirectories;
}
/**
* Return a boolean flag indicating whether the build generates
* any executables.
*/
bool HasExecutables()
{
return m_Executables;
return m_Executables;
}
/**
* Get a list of include directories in the build.
*/
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()
{
return m_LinkDirectories;
return m_LinkDirectories;
}
/**
* Get a list of link libraries in the build.
*/
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()
{
return m_LinkLibrariesWin32;
return m_LinkLibrariesWin32;
}
/**
* Get a list of Unix link libraries in the build.
*/
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()
{ return m_AuxSourceDirectories; }
{return m_AuxSourceDirectories;}
/**
* Do not use this.
*/
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* 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();
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();
const char* GetDefineFlags()
{return m_DefineFlags.c_str();}
protected:
bool m_Executables;
std::string m_Prefix;
@ -203,6 +334,26 @@ protected:
StringRuleMakerMap m_RuleMakers;
std::vector<cmRuleMaker*> m_UsedRuleMakers;
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();
};

View File

@ -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"
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
{
public:
// use the m_Makefile and the m_CustomRules and m_ExtraSourceFiles
// to generate the makefile
virtual void GenerateMakefile() = 0;
/**
* Set the cmMakefile instance from which to generate the makefile.
*/
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:
cmMakefile* m_Makefile;
};

View File

@ -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.
//
@ -16,111 +31,12 @@
// Updated: MBN 12/15/89 Sprinkled "const" qualifiers all over the place!
// 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 "cmStandardIncludes.h"
#include <stdio.h>
// cmRegularExpression -- Copies the given regular expression.
cmRegularExpression::cmRegularExpression (const cmRegularExpression& rxp) {
int ind;
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
}
// operator== -- Returns true if two regular expressions have the same
// compiled program for pattern matching.
bool cmRegularExpression::operator== (const cmRegularExpression& rxp) const {
if (this != &rxp) { // Same address?
int ind = this->progsize; // Get regular expression size
@ -918,8 +832,9 @@ void regdump ();
static char* regprop ();
#endif
bool cmRegularExpression::find (std::string const& s) {
return find(s.c_str());
bool cmRegularExpression::find (std::string const& s)
{
return find(s.c_str());
}

View File

@ -13,7 +13,7 @@
See COPYRIGHT.txt for copyright details.
=========================================================================*/
/// Original Copyright notice:
// Original Copyright notice:
// Copyright (C) 1991 Texas Instruments Incorporated.
//
// 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
// express or implied warranty.
//
// .LIBRARY vbl
// .HEADER Basics Package
// .INCLUDE cmRegularExpression.h
// .FILE cmRegularExpression.cxx
// Created: MNF 06/13/89 Initial Design and Implementation
// Updated: LGO 08/09/89 Inherit from Generic
// Updated: MBN 09/07/89 Added conditional exception handling
// Updated: MBN 12/15/89 Sprinkled "const" qualifiers all over the place!
// Updated: DLS 03/22/91 New lite version
//
#ifndef cmRegularExpression_h
#define cmRegularExpression_h
@ -36,83 +38,225 @@
const int NSUBEXP = 10;
//: Pattern matching with regular expressions
// 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 form, a
// regular expression is a sequence of characters used to
// search for exact character matches. However, many times the
// 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-
// lar expression class implements regular expression pattern
// matching as is found and implemented in many UNIX commands
// and utilities.
//
// Example: The perl code
//
// $filename =~ m"([a-z]+)\.cc";
// print $1;
//
// Is written as follows in C++
//
// vbl_reg_exp re("([a-z]+)\\.cc");
// re.find(filename);
// cerr << re.match(1);
//
//
// The regular expression class provides a convenient mechanism
// for specifying and manipulating regular expressions. The
// regular expression object allows specification of such pat-
// terns by using the following regular expression metacharac-
// ters:
//
// ^ Matches at beginning of a line
//
// $ Matches at end of a line
//
// . Matches any single character
//
// [ ] Matches any character(s) inside the brackets
//
// [^ ] Matches any character(s) not inside the brackets
//
// - Matches any character in range on either side of a dash
//
// * Matches preceding pattern zero or more times
//
// + Matches preceding pattern one or more times
//
// ? 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.
//
class cmRegularExpression {
/** \class cmRegularExpression
* \brief Implements pattern matching with regular expressions.
*
* 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.
*
* This class implements pattern matching via regular expressions.
* 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 form, a
* regular expression is a sequence of characters used to
* search for exact character matches. However, many times the
* 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-
* lar expression class implements regular expression pattern
* matching as is found and implemented in many UNIX commands
* and utilities.
*
* Example: The perl code
*
* $filename =~ m"([a-z]+)\.cc";
* print $1;
*
* Is written as follows in C++
*
* vbl_reg_exp re("([a-z]+)\\.cc");
* re.find(filename);
* cerr << re.match(1);
*
*
* The regular expression class provides a convenient mechanism
* for specifying and manipulating regular expressions. The
* regular expression object allows specification of such pat-
* terns by using the following regular expression metacharac-
* ters:
*
* ^ Matches at beginning of a line
*
* $ Matches at end of a line
*
* . Matches any single character
*
* [ ] Matches any character(s) inside the brackets
*
* [^ ] Matches any character(s) not inside the brackets
*
* - Matches any character in range on either side of a dash
*
* * Matches preceding pattern zero or more times
*
* + Matches preceding pattern one or more times
*
* ? 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:
inline cmRegularExpression (); // cmRegularExpression with program=NULL
inline cmRegularExpression (char const*); // cmRegularExpression with compiled char*
cmRegularExpression (cmRegularExpression const&); // Copy constructor
inline ~cmRegularExpression(); // Destructor
/**
* Instantiate cmRegularExpression with program=NULL.
*/
inline cmRegularExpression ();
void compile (char const*); // Compiles char* --> regexp
bool find (char const*); // true if regexp in char* arg
bool find (std::string const&); // true if regexp in char* arg
inline long start() const; // Index to start of first find
inline long end() const; // Index to end of first find
/**
* Instantiate cmRegularExpression with compiled char*.
*/
inline cmRegularExpression (char const*);
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?
/**
* Instantiate cmRegularExpression as a copy of another regular expression.
*/
cmRegularExpression (cmRegularExpression const&);
inline bool is_valid() const; // true if compiled regexp
inline void set_invalid(); // Invalidates regexp
/**
* 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
int start(int n) const;
int end(int n) const;
@ -130,82 +274,98 @@ private:
const char* searchstring;
};
// cmRegularExpression -- Creates an empty regular expression.
inline cmRegularExpression::cmRegularExpression () {
/**
* Create an empty regular expression.
*/
inline cmRegularExpression::cmRegularExpression ()
{
this->program = NULL;
}
// cmRegularExpression -- Creates a regular expression from string s, and
// compiles s.
inline cmRegularExpression::cmRegularExpression (const char* s) {
/**
* Creates a regular expression from string s, and
* compiles s.
*/
inline cmRegularExpression::cmRegularExpression (const char* s)
{
this->program = NULL;
compile(s);
}
// ~cmRegularExpression -- Frees space allocated for regular expression.
inline cmRegularExpression::~cmRegularExpression () {
/**
* Destroys and frees space allocated for the regular expression.
*/
inline cmRegularExpression::~cmRegularExpression ()
{
//#ifndef WIN32
delete [] this->program;
//#endif
}
// Start --
inline long cmRegularExpression::start () const {
/**
* Set the start position for the regular expression.
*/
inline long cmRegularExpression::start () const
{
return(this->startp[0] - searchstring);
}
// End -- Returns the start/end index of the last item found.
inline long cmRegularExpression::end () const {
/**
* Returns the start/end index of the last item found.
*/
inline long cmRegularExpression::end () const
{
return(this->endp[0] - searchstring);
}
// operator!= //
inline bool cmRegularExpression::operator!= (const cmRegularExpression& r) const {
/**
* Returns true if two regular expressions have different
* compiled program for pattern matching.
*/
inline bool cmRegularExpression::operator!= (const cmRegularExpression& r) const
{
return(!(*this == r));
}
// is_valid -- Returns true if a valid regular expression is compiled
// and ready for pattern matching.
inline bool cmRegularExpression::is_valid () const {
/**
* Returns true if a valid regular expression is compiled
* and ready for pattern matching.
*/
inline bool cmRegularExpression::is_valid () const
{
return (this->program != NULL);
}
// set_invalid -- Invalidates regular expression.
inline void cmRegularExpression::set_invalid () {
inline void cmRegularExpression::set_invalid ()
{
//#ifndef WIN32
delete [] this->program;
//#endif
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
{
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
{
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
{
return std::string(this->startp[n], this->endp[n] - this->startp[n]);

View File

@ -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
#define cmStandardIncludes_h

View File

@ -79,13 +79,13 @@ bool cmSystemTools::FileExists(const char* filename)
{
struct stat fs;
if (stat(filename, &fs) != 0)
{
{
return false;
}
}
else
{
{
return true;
}
}
}

View File

@ -13,14 +13,17 @@
See COPYRIGHT.txt for copyright details.
=========================================================================*/
/**
* cmSystemTools - a collection of useful functions for CMake.
*/
#ifndef cmSystemTools_h
#define cmSystemTools_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
{
public:
@ -30,47 +33,54 @@ public:
* prior to calling this function.
*/
static bool MakeDirectory(const char* path);
/**
* Replace replace all occurances of the string in in
* souce string.
* Replace replace all occurances of the string in
* the source string.
*/
static void ReplaceString(std::string& source,
const char* replace,
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);
/**
* Return true if a file exists
* Return true if a file exists in the current directory.
*/
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);
/**
* 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);
/**
* 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
* arguments.
*/
static bool ParseFunction(std::ifstream&,
std::string& name,
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.
* This is called by ParseFunction.
*/
static void GetArguments(std::string& line,
std::vector<std::string>& arguments);
/**
* Display an error message.
*/

View File

@ -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 "cmMakefile.h"
#include "cmStandardIncludes.h"
@ -13,7 +28,6 @@ void cmUnixMakefileGenerator::GenerateMakefile()
this->OutputMakefile("CMakeTargets.make");
}
// Output the depend information for all the classes
// in the makefile. These would have been generated
// by the class cmMakeDepend GenerateMakefile

View File

@ -13,23 +13,33 @@
See COPYRIGHT.txt for copyright details.
=========================================================================*/
/**
* itkUnixMakefile is used generate unix makefiles.
*/
#ifndef cmUnixMakefileGenerator_h
#define cmUnixMakefileGenerator_h
#include "cmMakefile.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
{
public:
/**
* Write the makefile to the named file
* Produce the makefile (in this case a Unix makefile).
*/
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&);
protected:
void OutputMakefile(const char* file);
void OutputDependLibraries(std::ostream&);

View File

@ -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 "cmStandardIncludes.h"
#include "cmSystemTools.h"

View File

@ -13,34 +13,43 @@
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
#define cmWindowsConfigure_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
{
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)
{
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)
{
m_WhereBuild = dir;
}
/**
* Perform the configure process.
*/
virtual bool Configure(const char* input);
protected:
std::string m_WhereSource;
std::string m_WhereBuild;