ExchangeFileContents
Loading...
Searching...
No Matches
EfcApp Class Reference

The application class of ExchangeFileContents. More...

#include <EfcApp.h>

Collaboration diagram for EfcApp:

Classes

class  EfcCallBackFileFount
 Class to process found files; passed to eut::FileHelper::iterateDirectory( const fs::path & rIterPath, bool bRecursive, CallBackFileDirFount & rProcessingObject ). More...
 

Public Member Functions

 EfcApp (const std::vector< std::wstring > &rArgVector)
 
virtual ~EfcApp ()
 
int exec ()
 

Private Member Functions

 EfcApp ()
 
 EfcApp (const EfcApp &)
 
void showResult (int iResultCode, const std::string &rsCurrentFile)
 
void showHelp ()
 
void getFileNameAndExtension (std::wstring &rsFileName, std::wstring &rsExtension, const fs::path &rFileSystemPath)
 
EfcAppoperator= (const EfcApp &)
 

Private Attributes

std::vector< std::wstring > m_ParaVector
 
int m_iVerboseMode
 
bool m_bStopOnError
 
bool m_bSimulate
 
std::wstring m_sFileNameFilter
 
std::wstring m_sFileExtensionFilter
 
std::string m_sLanguage
 

Detailed Description

The application class of ExchangeFileContents.

Constructor & Destructor Documentation

◆ EfcApp() [1/3]

EfcApp::EfcApp ( const std::vector< std::wstring > & rArgVector)

Constructor with parameter passing.

Parameters
[in]rArgVectorThe arguments (parameters) passed to the application.
Structur:
  • rArgVector[0] The file whose content is to be changed (e.g. 'c:/dir/filename.txt').
  • rArgVector[1] The expression to be exchanged in the data from rArgVector[0] with the data from rArgVector[2]. Format: The parameter rArgVector[1] must always begin with 'text:' or 't:', 'hex:' or 'h:' or 'file:' or 'f:'.
    • If the expression starts with 'text:' or 't:', the following Text taken as text to be exchanged. For example 'text:old text'. results in 'old text'.
    • If the expression begins with 'hex:' or 'h:', the following text after 'hex:' or 'h:' is interpreted as a hexadecimal number sequence, which is to be replaced. The hex values must have two digits, must be transferred separated by commas (e.g. "h:0D,0A").
    • If the expression begins with 'file:' or 'f:', the contents of of the file whose name follows 'file:' or 'f:'. If e.g. 'file:D:/dir/filename.txt', the content of the file 'D:/dir/filename.txt' as text to be exchanged.
  • rArgVector[2] The content to be exchanged.
    Format: The parameter rArgVector[2] must always be terminated with 'text:'. or 't:' or 'file:' or 'f:'.
    • If the expression starts with 'text:' or 't:', the following Text taken as new text. For example 'text:new text'. results in 'new text' as new text.
    • If the expression begins with 'hex:' or 'h:', the original content (the second parameter 'AgeContent') by the hexadecimal number sequence after 'hex:' or 'h:' replaced. The hex values must have two digits, must be transferred separated by commas (e.g. "h:0D,0A").
    • If the expression begins with 'file:' or 'f:', the contents of of the file whose name follows 'file:' or 'f:'. If e.g. 'file:D:/dir/filename.txt', the content of the file 'D:/dir/filename.txt' taken as new text
  • rArgVector[3] Optional the file into which the changed content from rArgVector[0] should be saved. If the file already exists,
  • rArgVector[n] Furthermore, the following parameters can be passed:
    • -r The subdirctorys are also searched recursively.
    • <v>-v
Indicates wheter an how often the content of the file has been changed.
  • -v+ Also displays the skipped files.
  • -s Stops in case of an error and waits for a keystroke.
  • -f If the parameter [targetfile] is set, an existing target file will only be overwritten if this parameter is passed.
  • -nop The processing is only simulated, no files are changed or created.

◆ ~EfcApp()

virtual EfcApp::~EfcApp ( )
virtual

Destructor, the memory is cleaned up.

◆ EfcApp() [2/3]

EfcApp::EfcApp ( )
private

The standard constructor is not available.

◆ EfcApp() [3/3]

EfcApp::EfcApp ( const EfcApp & )
private

The copy constructor is not available.

Member Function Documentation

◆ exec()

int EfcApp::exec ( )

Starts the application. The parameters will be checked and adjusted and then eut::FileHelper::iterateDirectory(const fs::path &, bool, CallBackFileDirFount &) will be called (among others with passing an EfcApp::EfcCallBackFileFount as parameter).

Returns
A return value < 0 indicates an error.

◆ getFileNameAndExtension()

void EfcApp::getFileNameAndExtension ( std::wstring & rsFileName,
std::wstring & rsExtension,
const fs::path & rFileSystemPath )
private

Returns the file name and extension from the given filesystem path. This function exists, so that with a file name == "*" an extension ".*" is also delivered.

Parameters
[in,out]rsFileNameThe determined file name.
[in,out]rsExtensionThe determined extension name.
[in]rFileSystemPathThe path from which the file and extension name is to be determined.

◆ operator=()

EfcApp & EfcApp::operator= ( const EfcApp & )
private

The assignment operator is not available.

◆ showHelp()

void EfcApp::showHelp ( )
private

Shows the command syntax of efc.

◆ showResult()

void EfcApp::showResult ( int iResultCode,
const std::string & rsCurrentFile )
private

Shows how often an exchange has taken place or, if an error has occurred, an error message.

Parameters
[in]iResultCodeThe error code.
[in]rsCurrentFileThe name of the currently processed file.

Member Data Documentation

◆ m_bSimulate

bool EfcApp::m_bSimulate
private

If true, the processing is only simulated, i.e. no change is stored (default is 'false').

◆ m_bStopOnError

bool EfcApp::m_bStopOnError
private

Wenn true, processing stops on errors and wait for a key press (default is 'false').

◆ m_iVerboseMode

int EfcApp::m_iVerboseMode
private

The output mode (default is 0).

  • 0 -> Show nothing
  • 1 -> show only found files
  • 2 -> show all (also skipped)

◆ m_ParaVector

std::vector<std::wstring> EfcApp::m_ParaVector
private

A vector with the parameters.

◆ m_sFileExtensionFilter

std::wstring EfcApp::m_sFileExtensionFilter
private

The file extension filter can also contain wildcard characters ('*' and '?').

◆ m_sFileNameFilter

std::wstring EfcApp::m_sFileNameFilter
private

The file name filter can also contain wildcard characters ('*' and '?').

◆ m_sLanguage

std::string EfcApp::m_sLanguage
private

The determined language (default is "en" for English).


The documentation for this class was generated from the following file: