about
11/30/2022
CppUtilities Repo
CppUtilities code

CppUtilities  Repository

Small helper utility classes - Command line, strings, time-dates, testing

Quick Status Code functions correctly no known defects Demonstration code yes Documentation yes Test cases no Static library no Build requires C++17 option Planned design changes refactor CodeUtilities

1.0 Concept

This repository holds codes that provide simple services to many C++ programs.

1.1 Usage

Fig 1. CppUtilities Folders
The intent is that, for any program that needs one or more of the services, the designer simply drops a CppUtilities folder into the project folder and provides include statements for the headers of used services in the project files. If the program will need several of the services, the developer can drop in the entire CppUtilities folder. If only a single service is needed, the folder for that service can be dropped in. Many of these utilities are header only. In that case the designer doesn't need to do anything else. Should a utility that requires an implementation file be used, then the designer can either include the implementation file in the project being built, or can build the utilities as a static library and make a reference to that in the program's project.

1.2 Requirements

Each utility should:
  • Have no, or very few small and simple, packages on which it depends.
  • Provide its functionality through inline definitions in its header file. There may be occasional utilities for which that isn't the preferred structure, usually because the utility already existed with implementation in its cpp file.
  • Provide a simple interface that doesn't require knowledge of the utility's design.
  • Have broad applicability.

2.0 Design

CppUtilities contains several packages, each with its own Visual Studio project:
  • CodeUtilities provides ProcessCmdLine and Converter classes with all definitions inline in its header file. ProcessCmdLine provides facilities for parsing command line arguments, returning path, file patterns, and options, via methods of the class. The intent is that a using program create an instance of ProcessCmdLine, invoke its processing, and use that instance to access information about the command line rather than provide its own storage and accessors. Converter supports converting instances between string representations and their values.
  • StringUtilities defines functions that write console titles, trim strings, and provide string splits. All definitions are inline in its header file.
  • TestUtilities provides a simple single-user test harness for building regression tests. Runs sequences of tests, defined as functors or lambdas, using a single try-catch block and pass fail enunciation.
  • UtilitiesEnvironment provides commonly used type aliases embedded in the Utilities namespace.
  • DateTime provides a DateTime class that uses code defined in std::chrono.
  • DirExplorer-Events definds structs IDirEvent and IFileEvent and class DirExploreE. Will be moved to another repository
  • DirExplorer-Template defines class DirExplorerT<App> App is an application specific class that defines processing for file and directory discovery. Will be moved to another repository
  • Properties defines a class Property<T>
  • SingletonLogger provides a struct ISingletonLogger<Category, Locker>, and classes SingletonLogger<T> and SingletonLoggerFactory<Category, Locker>. All of these are defined inline in the header files.
  • WindowsHelpers provides string conversions and error message retrieval for the Windows API.
CppUtilities also provides packages FileSystem and FileUtilities, both of which have their own repositories.

3.0 Status

  • CodeUtilities contains a ProcessCmdLine class. I recently made changes to the interface it exposes in order to make it more flexible - driven by the creation of the tool FileFinder. ProcessCmdLine now expects paths as /P [somePath], provides default options for paths and patterns, e.g., "." and "*.*" respectively. It also parses /R regexp with default ".*", e.g., match anything.
  • Code was built with Visual Studio Community Edition - 2019, and tested on Windows 10.
  Next Prev Pages Sections About Keys