ENH: Reduced header dependencies and cleaned up inclusion of standard headers.
This commit is contained in:
parent
332f402191
commit
43419192cb
@ -51,6 +51,20 @@ IF(KWSYS_INCLUDE_INSTALL_DIR)
|
|||||||
FILES ${KWSYS_INCLUDES})
|
FILES ${KWSYS_INCLUDES})
|
||||||
ENDIF(KWSYS_INCLUDE_INSTALL_DIR)
|
ENDIF(KWSYS_INCLUDE_INSTALL_DIR)
|
||||||
|
|
||||||
|
#-----------------------------------------------------------------------------
|
||||||
|
# Create STL header wrappers to block warnings in the STL headers.
|
||||||
|
FOREACH(header algorithm deque iterator list map numeric queue set stack string
|
||||||
|
utility vector)
|
||||||
|
SET(KWSYS_STL_HEADER "${header}")
|
||||||
|
CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/kwsys_std.h.in
|
||||||
|
${PROJECT_BINARY_DIR}/../${KWSYS_NAMESPACE}/std/${header}
|
||||||
|
@ONLY IMMEDIATE)
|
||||||
|
IF(KWSYS_INCLUDE_INSTALL_DIR)
|
||||||
|
INSTALL_FILES(${KWSYS_INCLUDE_INSTALL_DIR}/${KWSYS_NAMESPACE}
|
||||||
|
FILES ${PROJECT_BINARY_DIR}/../${KWSYS_NAMESPACE}/std/${header})
|
||||||
|
ENDIF(KWSYS_INCLUDE_INSTALL_DIR)
|
||||||
|
ENDFOREACH(header)
|
||||||
|
|
||||||
IF(KWSYS_DEFAULTS)
|
IF(KWSYS_DEFAULTS)
|
||||||
INCLUDE_DIRECTORIES(${PROJECT_BINARY_DIR}/..)
|
INCLUDE_DIRECTORIES(${PROJECT_BINARY_DIR}/..)
|
||||||
ADD_EXECUTABLE(test1 test1.cxx)
|
ADD_EXECUTABLE(test1 test1.cxx)
|
||||||
|
@ -7,4 +7,10 @@
|
|||||||
#cmakedefine KWSYS_NO_ANSI_STRING_STREAM
|
#cmakedefine KWSYS_NO_ANSI_STRING_STREAM
|
||||||
#cmakedefine KWSYS_NO_ANSI_FOR_SCOPE
|
#cmakedefine KWSYS_NO_ANSI_FOR_SCOPE
|
||||||
|
|
||||||
|
#if defined(KWSYS_NO_STD_NAMESPACE)
|
||||||
|
# define kwsys_std
|
||||||
|
#else
|
||||||
|
# define kwsys_std std
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -16,6 +16,53 @@
|
|||||||
=========================================================================*/
|
=========================================================================*/
|
||||||
#include <Directory.hxx>
|
#include <Directory.hxx>
|
||||||
|
|
||||||
|
#include <std/string>
|
||||||
|
#include <std/vector>
|
||||||
|
|
||||||
|
namespace KWSYS_NAMESPACE
|
||||||
|
{
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
class DirectoryInternals
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
// Array of Files
|
||||||
|
kwsys_std::vector<kwsys_std::string> Files;
|
||||||
|
|
||||||
|
// Path to Open'ed directory
|
||||||
|
kwsys_std::string Path;
|
||||||
|
};
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
Directory::Directory()
|
||||||
|
{
|
||||||
|
this->Internal = new DirectoryInternals;
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
Directory::~Directory()
|
||||||
|
{
|
||||||
|
delete this->Internal;
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
unsigned long Directory::GetNumberOfFiles()
|
||||||
|
{
|
||||||
|
return this->Internal->Files.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
const char* Directory::GetFile(unsigned long dindex)
|
||||||
|
{
|
||||||
|
if ( dindex >= this->Internal->Files.size() )
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return this->Internal->Files[dindex].c_str();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace KWSYS_NAMESPACE
|
||||||
|
|
||||||
// First microsoft compilers
|
// First microsoft compilers
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
@ -60,10 +107,10 @@ bool Directory::Load(const char* name)
|
|||||||
// Loop through names
|
// Loop through names
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
m_Files.push_back(data.name);
|
this->Internal->Files.push_back(data.name);
|
||||||
}
|
}
|
||||||
while ( _findnext(srchHandle, &data) != -1 );
|
while ( _findnext(srchHandle, &data) != -1 );
|
||||||
m_Path = name;
|
this->Internal->Path = name;
|
||||||
return _findclose(srchHandle) != -1;
|
return _findclose(srchHandle) != -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,7 +122,7 @@ bool Directory::Load(const char* name)
|
|||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
|
|
||||||
namespace KWSYS_NAMESPACE
|
namespace KWSYS_NAMESPACE
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -90,27 +137,13 @@ bool Directory::Load(const char* name)
|
|||||||
|
|
||||||
for (dirent* d = readdir(dir); d; d = readdir(dir) )
|
for (dirent* d = readdir(dir); d; d = readdir(dir) )
|
||||||
{
|
{
|
||||||
m_Files.push_back(d->d_name);
|
this->Internal->Files.push_back(d->d_name);
|
||||||
}
|
}
|
||||||
m_Path = name;
|
this->Internal->Path = name;
|
||||||
closedir(dir);
|
closedir(dir);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace KWSYS_NAMESPACE
|
} // namespace KWSYS_NAMESPACE
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace KWSYS_NAMESPACE
|
|
||||||
{
|
|
||||||
|
|
||||||
const char* Directory::GetFile(size_t dindex)
|
|
||||||
{
|
|
||||||
if ( dindex >= m_Files.size() )
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return m_Files[dindex].c_str();
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace KWSYS_NAMESPACE
|
|
||||||
|
@ -17,18 +17,13 @@
|
|||||||
#ifndef @KWSYS_NAMESPACE@_Directory_hxx
|
#ifndef @KWSYS_NAMESPACE@_Directory_hxx
|
||||||
#define @KWSYS_NAMESPACE@_Directory_hxx
|
#define @KWSYS_NAMESPACE@_Directory_hxx
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#include <@KWSYS_NAMESPACE@/Configure.hxx>
|
||||||
#pragma warning ( disable : 4786 )
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <@KWSYS_NAMESPACE@/StandardIncludes.hxx>
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
namespace @KWSYS_NAMESPACE@
|
namespace @KWSYS_NAMESPACE@
|
||||||
{
|
{
|
||||||
|
|
||||||
|
class DirectoryInternals;
|
||||||
|
|
||||||
/** \class Directory
|
/** \class Directory
|
||||||
* \brief Portable directory/filename traversal.
|
* \brief Portable directory/filename traversal.
|
||||||
*
|
*
|
||||||
@ -37,33 +32,34 @@ namespace @KWSYS_NAMESPACE@
|
|||||||
*
|
*
|
||||||
* Directory currently works with Windows and Unix operating systems.
|
* Directory currently works with Windows and Unix operating systems.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class Directory
|
class Directory
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
Directory();
|
||||||
|
~Directory();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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
|
||||||
* opened, 1 if it is opened.
|
* opened, 1 if it is opened.
|
||||||
*/
|
*/
|
||||||
bool Load(const char* dir);
|
bool Load(const char*);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the number of files in the current directory.
|
* Return the number of files in the current directory.
|
||||||
*/
|
*/
|
||||||
size_t GetNumberOfFiles() { return m_Files.size();}
|
unsigned long GetNumberOfFiles();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the file at the given index, the indexing is 0 based
|
* Return the file at the given index, the indexing is 0 based
|
||||||
*/
|
*/
|
||||||
const char* GetFile(size_t );
|
const char* GetFile(unsigned long);
|
||||||
|
|
||||||
private:
|
|
||||||
kwsys_std::vector<kwsys_std::string> m_Files; // Array of Files
|
|
||||||
kwsys_std::string m_Path; // Path to Open'ed directory
|
|
||||||
|
|
||||||
}; // End Class: Directory
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
// Private implementation details.
|
||||||
|
DirectoryInternals* Internal;
|
||||||
|
}; // End Class: Directory
|
||||||
|
|
||||||
} // namespace @KWSYS_NAMESPACE@
|
} // namespace @KWSYS_NAMESPACE@
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -35,9 +35,9 @@
|
|||||||
#ifndef @KWSYS_NAMESPACE@_RegularExpression_hxx
|
#ifndef @KWSYS_NAMESPACE@_RegularExpression_hxx
|
||||||
#define @KWSYS_NAMESPACE@_RegularExpression_hxx
|
#define @KWSYS_NAMESPACE@_RegularExpression_hxx
|
||||||
|
|
||||||
#include <@KWSYS_NAMESPACE@/StandardIncludes.hxx>
|
#include <@KWSYS_NAMESPACE@/Configure.hxx>
|
||||||
|
|
||||||
#include <string>
|
#include <@KWSYS_NAMESPACE@/std/string>
|
||||||
|
|
||||||
namespace @KWSYS_NAMESPACE@
|
namespace @KWSYS_NAMESPACE@
|
||||||
{
|
{
|
||||||
|
@ -35,10 +35,4 @@
|
|||||||
# include <strstream.h>
|
# include <strstream.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(KWSYS_NO_STD_NAMESPACE)
|
|
||||||
# define kwsys_std
|
|
||||||
#else
|
|
||||||
# define kwsys_std std
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
15
Source/kwsys/kwsys_std.h.in
Normal file
15
Source/kwsys/kwsys_std.h.in
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#ifndef @KWSYS_NAMESPACE@_std_@KWSYS_STL_HEADER@
|
||||||
|
#define @KWSYS_NAMESPACE@_std_@KWSYS_STL_HEADER@
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#pragma warning (push, 1)
|
||||||
|
#pragma warning (disable: 4702)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <@KWSYS_STL_HEADER@>
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#pragma warning(pop)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
Loading…
x
Reference in New Issue
Block a user