// Utility.hpp // // Copyright (C) 2011 ARM Research Labs, LLC. // See www.armresearch.com for the copyright terms. // // This file defines the interface used by the configuration utilities. // #ifndef Utilityhpp_included #define Utilityhpp_included #include #include /// Base class for the Sniffer configuration. // // This class provides capability common to the configuration classes. // ////////////////////////////////////////////////////////////////////////////////////////////////////////// class Utility { public: /// Default constructor. Utility(); /// Check whether a file exists. // // \returns true if the file exists, false otherwise. // bool FileExists(std::string File); /// Copy a file. // // \param[in] From is the name of the source file. // // \param[in] To is the name of the destination file. // void Copy(std::string From, std::string To); /// Set the owner and group of the specified file. // // This function sets the owner and group of the specified file to the // value specified in Utility.cpp. // // \param[in] File is the specified file. // // \see SNFUserName. // // \see SNFGroupName. // void SetOwnerGroup(std::string &File); /// Set the mode of a file. // // This function sets the mode of the specified file. If an error // occurs, an exception is thrown. // // \param[in] File is the specified file. // // \param[in] is the mode. // void SetMode(std::string &File, mode_t mode); /// Create a directory. // // This function creates the specified directory. If an error // occurs, an exception is thrown. // // \param[in] Dir is the directory to create. // void MkDir(std::string &Dir); /// Check for a specified string at the beginning of a line. // // This function checks for the specified string at the beginning of a // line. Leading whitespace in the line is ignored. // // \param[in] Line is the line. // // \param[in] SearchString is the string to check for. // static bool CheckForString(std::string Line, std::string SearchString); /// Store the Verbose mode. // // \param[in] Mode stores the Verbose mode. // void SetVerbose(bool Mode); /// Provide verbose output? // // \returns true if the application is to provide verbose output. // bool Verbose(); /// Store the Explain mode. // // \param[in] Mode stores the Explain mode. // void SetExplain(bool Mode); /// Provide an explanation of the actions only? // // \returns true if the application is to provide an explanation // of the actions without executing any commands. // bool Explain(); /// Store the Help mode. // // \param[in] Mode stores the Help mode. // void SetHelp(bool Mode); /// Provide help? // // \returns true if the application is to output a help message. // bool Help(); /// Output the end of a verbose output line. void OutputVerboseEnd(); /// Directory separator. static const std::string DirectorySeparator; private: bool VerboseRequested; ///< User requested verbose processing. bool ExplainRequested; ///< User requested verbose processing but without actually executing the commands. bool HelpRequested; ///< User requested help. }; #endif