A lightweight command-line text processing tool written in C++. It provides utilities for searching, replacing, transforming and analyzing text files directly from the terminal. Architecture & Design Patterns
This tool was built with scalability and performance in mind:
- Pattern: Implements a Strategy Pattern via a common transformation interface, allowing easy extension of new features.
- Extensibility: Uses a Dispatch Map (Registry) for flag handling, enabling O(1) command lookup and modular integration.
- Efficiency: Employs Stream-based processing to handle large files with minimal memory overhead (processing line-by-line).
- Principles: Adheres to the Open/Closed Principle, making it easy to add new flags without modifying the core logic.
- Find occurrences of words in text files
- Replace text with optional match limits
- Convert text case (uppercase / lowercase)
- Remove duplicate lines, words or characters
- Count words and characters
- Limit number of matches using the -t flag
Use this command on the root project folder:
cmake -S . -B build
cmake --build buildFind all occurrences of a word in a file:
txtprocessor -i input.txt -f wordLimit the number of matches:
txtprocessor -i input.txt -f word -t 3Replace a word with another one:
txtprocessor -i input.txt -r word newWordLimit the number to replace:
txtprocessor -i input.txt -r word newWord -t 5Convert text to uppercase:
txtprocessor -i input.txt -case -upConvert text to lowercase:
txtprocessor -i input.txt -case -lowRemove duplicate lines:
txtprocessor -i input.txt -d -lRemove duplicate words and characters:
txtprocessor -i input.txt -d -wchCount words:
txtprocessor -i input.txt -c -wCount words and characters:
txtprocessor -i input.txt -c -wch