]> Creatis software - cpPlugins.git/blobdiff - bash/Config.h.in
Moved to version 1.0
[cpPlugins.git] / bash / Config.h.in
diff --git a/bash/Config.h.in b/bash/Config.h.in
deleted file mode 100644 (file)
index 1d53531..0000000
+++ /dev/null
@@ -1,274 +0,0 @@
-#ifndef __cpPlugins__bash__Config__h__
-#define __cpPlugins__bash__Config__h__
-
-// -------------------------------------------------------------------------
-#include <cmath>
-#include <cstring>
-#include <deque>
-#include <fstream>
-#include <iostream>
-#include <map>
-#include <queue>
-#include <sstream>
-#include <string>
-
-// -------------------------------------------------------------------------
-#define cpPlugins_PROCESS_DIMS    "@cpPlugins_PROCESS_DIMS@"
-#define cpPlugins_VISUAL_DIMS     "@cpPlugins_VISUAL_DIMS@"
-#define cpPlugins_ALL_CONFIGS     "@cpPlugins_ALL_CONFIGS@"
-#define cpPlugins_NUMBER_OF_FILES @cpPlugins_NUMBER_OF_FILES@
-
-// -------------------------------------------------------------------------
-#define cpPlugins_bash_OS_@CMAKE_SYSTEM_NAME@
-#ifdef cpPlugins_bash_OS_Windows
-#  define cpPlugins_bash_STRTOK( A, B, N )  strtok_s(  A, B, N )
-#  define cpPlugins_bash_SPRINTF( B, S, O ) sprintf_s( B, S, "%s", O );
-#else // cpPlugins_bash_OS_Windows
-#  define cpPlugins_bash_STRTOK( A, B, N )  std::strtok( A, B )
-#  define cpPlugins_bash_SPRINTF( B, S, O ) std::sprintf( B, "%s", O );
-#endif // cpPlugins_bash_OS_Windows
-
-// -------------------------------------------------------------------------
-typedef std::deque< std::string > TStrings;
-typedef std::map< std::string, TStrings > TCommands;
-
-/**
- */
-namespace cpPlugins_bash
-{
-  // -----------------------------------------------------------------------
-  template< class _TTokens >
-  inline void Tokenize(
-    _TTokens& tokens, const std::string& str, const std::string& delims
-    )
-  {
-    tokens.clear( );
-    if( str.size( ) > 0 )
-    {
-      auto ssize = str.size( );
-      char* buffer = new char[ ssize + 1 ];
-      for( unsigned long i = 0; i < ssize; ++i )
-        buffer[ i ] = str[ i ];
-      buffer[ ssize ] = '\0';
-      char* next;
-      char* it = cpPlugins_bash_STRTOK( buffer, delims.c_str( ), &next );
-      while( it != NULL )
-      {
-        tokens.push_back( std::string( it ) );
-        it = cpPlugins_bash_STRTOK( NULL, delims.c_str( ), &next );
-
-      } // elihw
-      delete [] buffer;
-
-    } // fi
-  }
-
-  // -----------------------------------------------------------------------
-  inline std::string Replace(
-    const std::string& str, const std::string& sub, const std::string& nsub
-    )
-  {
-    std::string res = str;
-    size_t index;
-    while( ( index = res.find( sub ) ) != std::string::npos )
-      res.replace( index, sub.size( ), nsub );
-    return( res );
-  }
-
-  // -----------------------------------------------------------------------
-  inline bool Read( std::string& buffer, const std::string& fname )
-  {
-    buffer = "";
-    std::ifstream file_stream( fname.c_str( ) );
-    if( !file_stream )
-      return( false );
-    file_stream.seekg( 0, std::ios::end );
-    buffer.reserve( ( unsigned int )( file_stream.tellg( ) ) );
-    file_stream.seekg( 0, std::ios::beg );
-    buffer.assign(
-      ( std::istreambuf_iterator< char >( file_stream ) ),
-      std::istreambuf_iterator< char >( )
-      );
-    file_stream.close( );
-    return( true );
-  }
-
-  // -----------------------------------------------------------------------
-  inline bool Write( const std::string& buffer, const std::string& fname )
-  {
-    std::ofstream file_stream( fname.c_str( ), std::ofstream::binary );
-    if( !file_stream )
-      return( false );
-    file_stream.write( buffer.c_str( ), buffer.size( ) );
-    return( true );
-  }
-
-  // -----------------------------------------------------------------------
-  inline void Parse( TCommands& commands, const TStrings& lines )
-  {
-    for( auto l = lines.begin( ); l != lines.end( ); ++l )
-    {
-      auto line = l->substr( l->find_first_not_of( " " ) );
-      if( line != "" )
-      {
-        if( line[ 0 ] != '*' )
-        {
-          auto cmd = line.substr( 0, line.find( " " ) );
-          auto args = line.substr( line.find( " " ) + 1 );
-          commands[ cmd ].push_back( args );
-
-        } // fi
-
-      } // fi
-
-    } // rof
-  }
-
-  // -----------------------------------------------------------------------
-  inline void LoadDefinitions( TCommands& commands )
-  {
-    // Dimensions
-    commands[ "define" ].push_back(
-      std::string( "pdims=" ) +
-      std::string( cpPlugins_PROCESS_DIMS )
-      );
-    commands[ "define" ].push_back(
-      std::string( "vdims=" ) +
-      std::string( cpPlugins_VISUAL_DIMS )
-      );
-
-    // Base c++ types
-    commands[ "define" ].push_back(
-      std::string( "int_types=char;short;int;long" )
-      );
-    commands[ "define" ].push_back(
-      std::string( "uint_types=unsigned #int_types#" )
-      );
-    commands[ "define" ].push_back(
-      std::string( "sint_types=signed char" )
-      );
-    commands[ "define" ].push_back(
-      std::string( "real_types=float;double" )
-      );
-    commands[ "define" ].push_back(
-      std::string(
-        "scalar_types=#int_types#;#uint_types#;#real_types#"
-        )
-      );
-  }
-
-  // -----------------------------------------------------------------------
-  inline void ExpandDefinitions(
-    TCommands& definitions, const TCommands& commands
-    )
-  {
-    definitions.clear( );
-    auto defs = commands.find( "define" );
-    if( defs == commands.end( ) )
-      return;
-
-    std::map< std::string, std::string > values;
-    for( auto dIt = defs->second.begin( ); dIt != defs->second.end( ); ++dIt )
-    {
-      TStrings toks;
-      cpPlugins_bash::Tokenize( toks, *dIt, "=" );
-      if( toks.size( ) == 2 )
-      {
-        auto name = toks[ 0 ].substr( toks[ 0 ].find_first_not_of( " " ) );
-        auto val = toks[ 1 ].substr( toks[ 1 ].find_first_not_of( " " ) );
-        values[ name ] = val;
-
-      } // fi
-
-    } // rof
-    for( auto vIt = values.begin( ); vIt != values.end( ); ++vIt )
-    {
-      TStrings toks;
-      cpPlugins_bash::Tokenize( toks, vIt->second, ";" );
-      for( auto tIt = toks.begin( ); tIt != toks.end( ); ++tIt )
-        definitions[ vIt->first ].push_back( *tIt );
-
-    } // rof
-    for( auto dIt = definitions.begin( ); dIt != definitions.end( ); ++dIt )
-    {
-      auto name = std::string( "#" ) + dIt->first + std::string( "#" );
-      for( auto eIt = definitions.begin( ); eIt != definitions.end( ); ++eIt )
-      {
-        if( eIt != dIt )
-        {
-          auto vIt = eIt->second.begin( );
-          while( vIt != eIt->second.end( ) )
-          {
-            if( vIt->find( name ) != std::string::npos )
-            {
-              for(
-                auto wIt = dIt->second.begin( );
-                wIt != dIt->second.end( );
-                ++wIt
-                )
-                eIt->second.push_back(
-                  cpPlugins_bash::Replace( *vIt, name, *wIt )
-                  );
-              vIt = eIt->second.erase( vIt );
-            }
-            else
-              ++vIt;
-
-          } // elihw
-
-        } // fi
-
-      } // rof
-
-    } // rof
-  }
-
-  // -----------------------------------------------------------------------
-  inline void Expand(
-    TStrings& tfiles,
-    const TCommands& definitions,
-    const TCommands& commands,
-    const std::string& cmd
-    )
-  {
-    tfiles.clear( );
-    auto tIt = commands.find( cmd );
-    if( tIt == commands.end( ) )
-      return;
-
-    for( auto fIt = tIt->second.begin( ); fIt != tIt->second.end( ); ++fIt )
-    {
-      std::queue< std::string > q;
-      q.push( *fIt );
-      while( q.size( ) > 0 )
-      {
-        auto value = q.front( );
-        q.pop( );
-        auto spos = value.find( "#" );
-        if( spos != std::string::npos )
-        {
-          auto name = value.substr( spos + 1 );
-          auto epos = name.find( "#" );
-          name = name.substr( 0, epos );
-          auto dIt = definitions.find( name );
-          if( dIt != definitions.end( ) )
-          {
-            name = std::string( "#" ) + name + std::string( "#" );
-            for( auto vIt = dIt->second.begin( ); vIt != dIt->second.end( ); ++vIt )
-              q.push( cpPlugins_bash::Replace( value, name, *vIt ) );
-
-          } // fi
-        }
-        else
-          tfiles.push_back( value );
-
-      } // rof
-
-    } // rof
-  }
-
-} // ecapseman
-
-#endif // __cpPlugins__bash__Config__h__
-
-// eof - $RCSfile$