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})
|
||||
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)
|
||||
INCLUDE_DIRECTORIES(${PROJECT_BINARY_DIR}/..)
|
||||
ADD_EXECUTABLE(test1 test1.cxx)
|
||||
|
@ -7,4 +7,10 @@
|
||||
#cmakedefine KWSYS_NO_ANSI_STRING_STREAM
|
||||
#cmakedefine KWSYS_NO_ANSI_FOR_SCOPE
|
||||
|
||||
#if defined(KWSYS_NO_STD_NAMESPACE)
|
||||
# define kwsys_std
|
||||
#else
|
||||
# define kwsys_std std
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -16,6 +16,53 @@
|
||||
=========================================================================*/
|
||||
#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
|
||||
|
||||
#ifdef _MSC_VER
|
||||
@ -60,10 +107,10 @@ bool Directory::Load(const char* name)
|
||||
// Loop through names
|
||||
do
|
||||
{
|
||||
m_Files.push_back(data.name);
|
||||
this->Internal->Files.push_back(data.name);
|
||||
}
|
||||
while ( _findnext(srchHandle, &data) != -1 );
|
||||
m_Path = name;
|
||||
this->Internal->Path = name;
|
||||
return _findclose(srchHandle) != -1;
|
||||
}
|
||||
|
||||
@ -75,7 +122,7 @@ bool Directory::Load(const char* name)
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <dirent.h>
|
||||
|
||||
|
||||
namespace KWSYS_NAMESPACE
|
||||
{
|
||||
|
||||
@ -90,27 +137,13 @@ bool Directory::Load(const char* name)
|
||||
|
||||
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);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
} // namespace KWSYS_NAMESPACE
|
||||
|
||||
#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
|
||||
#define @KWSYS_NAMESPACE@_Directory_hxx
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning ( disable : 4786 )
|
||||
#endif
|
||||
|
||||
#include <@KWSYS_NAMESPACE@/StandardIncludes.hxx>
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <@KWSYS_NAMESPACE@/Configure.hxx>
|
||||
|
||||
namespace @KWSYS_NAMESPACE@
|
||||
{
|
||||
|
||||
class DirectoryInternals;
|
||||
|
||||
/** \class Directory
|
||||
* \brief Portable directory/filename traversal.
|
||||
*
|
||||
@ -37,33 +32,34 @@ namespace @KWSYS_NAMESPACE@
|
||||
*
|
||||
* Directory currently works with Windows and Unix operating systems.
|
||||
*/
|
||||
|
||||
class Directory
|
||||
{
|
||||
public:
|
||||
Directory();
|
||||
~Directory();
|
||||
|
||||
/**
|
||||
* Load the specified directory and load the names of the files
|
||||
* in that directory. 0 is returned if the directory can not be
|
||||
* opened, 1 if it is opened.
|
||||
*/
|
||||
bool Load(const char* dir);
|
||||
|
||||
bool Load(const char*);
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
const char* GetFile(size_t );
|
||||
|
||||
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
|
||||
const char* GetFile(unsigned long);
|
||||
|
||||
private:
|
||||
// Private implementation details.
|
||||
DirectoryInternals* Internal;
|
||||
}; // End Class: Directory
|
||||
|
||||
} // namespace @KWSYS_NAMESPACE@
|
||||
|
||||
#endif
|
||||
|
@ -35,9 +35,9 @@
|
||||
#ifndef @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@
|
||||
{
|
||||
|
@ -35,10 +35,4 @@
|
||||
# include <strstream.h>
|
||||
#endif
|
||||
|
||||
#if defined(KWSYS_NO_STD_NAMESPACE)
|
||||
# define kwsys_std
|
||||
#else
|
||||
# define kwsys_std std
|
||||
#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