- 中文文档 - Chinese Documentation
Tiny.cpp is an extremely tiny, lightweight, and easy-to-use foundational library. It provides core functionalities including an event system, file operations, system information retrieval, command-line parsing, and Terminal User Interface (TUI). The library is designed with modern C++ and supports Windows and Unix-like systems (Linux, macOS, etc.).
- Modular Architecture: Each module in the
srcdirectory can be reused independently without any configuration - Zero Dependencies: No third-party library dependencies, only cross-platform architectural design
- Easy to Use: Adopts modern C++ standards (minimum C++11 support)
| Module | Path | Description | Documentation |
|---|---|---|---|
| TUI | src/TUI |
Terminal User Interface, provides basic terminal drawing functionality for easier terminal rendering | en/TUI/TUI.md |
| OS | src/OS |
Operating System, supports basic file and path operations as well as system information viewing | en/OS/File.md, en/OS/System.md |
| Net | src/Net |
Network communication, provides Socket, Address, hostname resolution, and advanced socket options | en/Net/Net.md |
| CommandParser | src/Parser |
Command parser, provides basic command parameter parsing functionality for easy implementation of command-line tools | en/Parser/CommandParser.md |
| IniParser | src/Parser |
INI configuration file parser, supports parsing, manipulating, and serializing INI files | en/Parser/IniParser.md |
| DateTime | src/DateTime |
Date and time utilities, supporting construction, formatting, arithmetic, and timestamp conversion | en/DateTime/DateTime.md |
| Events | src/Events |
Event system, provides basic components for easy implementation of timers, asynchronous functions, etc. | en/Events/Event.md |
You can directly download the latest pre-built release from Github Release.
-
Download project source code via Github:
git clone https://github.com/CatIsNotFound/Tiny.cpp.git
For non-stable versions, execute:
git clone https://github.com/CatIsNotFound/Tiny.cpp.git -b beta
-
Configure project via CMake
cd Tiny.cpp mkdir build ; cd build cmake .. -DCMAKE_INSTALL_PREFIX=/path/to/Tiny.cpp -DCMAKE_BUILD_TYPE=Release -DTINY_BUILD_TEST=OFF
Note: Please replace
/path/to/Tiny.cppwith your actual installation path. -
Build and install to local
cmake --build . --target install
If XMake is not installed, execute the following command in the terminal to quickly install XMake:
Linux/MacOS/Unix-like:
curl -fsSL https://xmake.io/shget.text | bashwget https://xmake.io/shget.text -O - | bashWindows:
irm https://xmake.io/psget.text | iex
-
Download project source code via Github:
git clone https://github.com/CatIsNotFound/Tiny.cpp.git
For non-stable versions, execute:
git clone https://github.com/CatIsNotFound/Tiny.cpp.git -b beta
-
Configure project via XMake
cd Tiny.cpp xmake f --build_test=n -
Build and install to local
xmake xmake package -o /path/to/install
Note: Please replace
/path/to/installwith your actual installation path.
Directly copy any directory corresponding to a module from the src directory to your own project. Each module contains a header file (*.hpp) and source file (*.cpp).
If using CMake as your primary project management tool, it is recommended to import the Tiny project directly via CMake.
Note: Use Tiny as the project library name under CMake, not Tiny.cpp!
-
Download pre-built binary library or manually build from source to your local machine.
-
Refer to the following example:
cmake_minimum_required(VERSION 3.24)
project(HelloWorld)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_PREFIX_PATH "/path/to/Tiny.cpp")
find_package(Tiny REQUIRED)
add_executable(${CMAKE_PROJECT_NAME}
main.cpp
# ....
)
target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE
Tiny::Tiny
)Starting from version 1.2.0, Tiny.cpp supports importing via XMake.
To use XMake to import the Tiny.cpp project, you need to first configure the XMake project, then add Tiny.cpp as a dependency in your project.
-
Download and manually build from source to your local machine.
-
Manually set up the local repository
xmake repo -g -a local_repo /path/to/packageNote: Please replace /path/to/package with the actual absolute path of the installation package.
You can check if the local repository was added successfully with the following command:
xmake repo -l- Refer to the following example:
add_rules("mode.debug", "mode.release")
set_languages("c++20")
add_requires("tiny.cpp")
target("HelloWorld")
set_kind("binary")
add_files("**.cpp")
add_packages("tiny.cpp")Taking the TUI module as an example, assuming you want to use the Terminal module to simply output Hello, Tiny.cpp!, execute the following code:
// If importing via CMake method, use the following import:
#include <Tiny/TUI/Terminal.hpp>
// If directly copying the TUI directory to your project, it might be imported like this:
#include "TUI/Terminal.hpp"
using ter = Tiny::TUI::Terminal;
int main() {
ter::printLine("Hello, Tiny.cpp!");
return 0;
}If using CMake to install this project, use the following include methods:
// Main header file, includes all modules
#include <Tiny/Tiny.hpp>
// Or include specific modules separately
#include <Tiny/DateTime/DateTime.hpp>
#include <Tiny/Events/Events.hpp>
#include <Tiny/OS/File.hpp>
#include <Tiny/OS/System.hpp>
#include <Tiny/Parser/CommandParser.hpp>
#include <Tiny/Parser/IniParser.hpp>
#include <Tiny/Net/Socket.hpp>
#include <Tiny/TUI/TUI.hpp>If directly copying the src directory source code, use the following include methods:
// Main header file, includes all modules
#include "Tiny.hpp"
// Or include specific modules separately
#include "DateTime/DateTime.hpp"
#include "Events/Events.hpp"
#include "OS/File.hpp"
#include "OS/System.hpp"
#include "Parser/CommandParser.hpp"
#include "Parser/IniParser.hpp"
#include "Net/Socket.hpp"
#include "TUI/TUI.hpp"# Linux/macOS
g++ -std=c++17 -I./src main.cpp src/Tiny.cpp \
src/DateTime/DateTime.cpp \
src/Events/Events.cpp \
src/OS/File.cpp \
src/OS/System.cpp \
src/Parser/CommandParser.cpp \
src/Parser/IniParser.cpp \
src/Net/Socket.cpp \
src/TUI/TUI.cpp \
src/TUI/Terminal.cpp \
-o myapp
# Windows (MinGW)
g++ -std=c++17 -I./src main.cpp src/*.cpp src/*/*.cpp -o myapp.exe| Macro | Description | Auto-define Condition |
|---|---|---|
TINY_CPP_MY_OS_WINDOWS |
Enable Windows platform code | _WIN32 or _WIN64 defined |
TINY_CPP_MY_OS_UNIX |
Enable Unix platform code | __APPLE__, __linux__, or __unix__ defined |
Manually specify platform:
// Manually define before including header files
#define TINY_CPP_MY_OS_WINDOWS
#include <Tiny/Tiny.hpp>| Namespace | Description |
|---|---|
Tiny |
Root namespace |
Tiny::OS |
Operating system related functions (files, system info) |
Tiny::DT |
Date and time utilities |
Tiny::TUI |
Terminal user interface functions |
Tiny::Net |
Network communication functions (Socket, Address, hostname resolution) |
- C++ Standard: C++ 11 or higher
- Operating Systems: Windows (Windows 7+), Linux, macOS, Unix-like systems
- Compilers: GCC 7+, Clang 5+, MSVC 2017+
- Windows: Depends on
windows.h,shlobj.h,pdh.h(performance counters) - Unix/Linux: Depends on standard POSIX interfaces,
termios,sys/ioctl.h - macOS: Additional dependencies on
mach/mach.hand other system interfaces
Date and time handling utilities.
Asynchronous event management system.
Operating system related functions.
Network communication utilities.
Command-line argument parser and INI file parser.
Terminal user interface.
- Current Version: Unreleased
- Release Date: 2026
- License: MIT License
- Author: CatIsNotFound
| Platform | Support Status | Tested Version |
|---|---|---|
| Windows 10/11 | Fully supported | Tested |
| Windows 7/8 | Partially supported | Not tested |
| Linux (x86_64) | Fully supported | Ubuntu 22.04 |
| Linux (ARM64) | Fully supported | Not tested |
| macOS (Intel) | Fully supported | Not tested |
| macOS (Apple Silicon) | Fully supported | Not tested |
| Compiler | Minimum Version | Support Status |
|---|---|---|
| GCC | 7.0 | Fully supported |
| Clang | 5.0 | Fully supported |
| MSVC | 2017 | Fully supported |
| MinGW-w64 | 8.0 | Fully supported |
- Required: C++11 or higher
- Recommended: C++20
- Tested Standards: C++11, C++20
- Windows 7: Some system information retrieval APIs may not be available
- macOS: CPU usage calculation differs slightly from Linux
- Terminal: TUI module requires terminal supporting ANSI escape sequences
- Encoding: File paths use UTF-8 encoding on Windows
Tiny.cpp is licensed under the MIT License. You can view detailed information in the LICENSE file or any other header or source file.