PMT Renovated main
Partition Manager Tool is a fast, reliable, and feature-rich CLI application for Android devices that enables advanced partition operations such as backup, flashing, erasing, information retrieval, and more.
Loading...
Searching...
No Matches
definations.hpp File Reference

Some concept definitions, descriptions, etc. of the library. More...

#include <concepts>
#include <unistd.h>

Go to the source code of this file.

Classes

struct  Helper::DeepConst< T >
 Add the const qualifier to the input type. More...
 
struct  Helper::ConstIfCharPointer< T >
 Add the const qualifier if input type is char*. More...
 

Namespaces

namespace  Helper
 Main namespace of libhelper library.
 

Concepts

concept  Helper::HasCStrFunction
 Checks whether the input type provides a c_str() member function.
 
concept  Helper::Invocable
 Checks whether the input is invocable and returns requested type.
 

Macros

#define HELPER   "libhelper"
 Name shorcut for logging.
 
#define B(x)   (static_cast<uint64_t(x)> * 8)
 Take x byte as bits.
 
#define KB(x)   (static_cast<uint64_t>(x) * 1024)
 Take x kilobyte as bytes.
 
#define MB(x)   (KB(x) * 1024)
 Take x megabyte as bytes.
 
#define GB(x)   (MB(x) * 1024)
 Take x gigabyte as bytes.
 
#define TO_KB(x)   (x / 1024)
 Convert x byte to kilobyte.
 
#define TO_MB(x)   (TO_KB(x) / 1024)
 Convert x byte to megabyte.
 
#define TO_GB(x)   (TO_MB(x) / 1024)
 Convert x byte to gigabyte.
 
#define ABORT(msg)
 
#define ERROR(msg, code)
 
#define WARNING(msg)   fprintf(stderr, "%s%sWARNING%s: %s", BOLD, YELLOW, STYLE_RESET, msg);
 
#define INFO(msg)   fprintf(stdout, "%s%sINFO%s: %s", BOLD, GREEN, STYLE_RESET, msg);
 
#define MKVERSION(name)
 Generate version string and return.
 
Terminal ANSI Style Codes

Macros for text formatting in ANSI-compatible terminals.

#define STYLE_RESET   "\033[0m"
 Resets all formatting to default.
 
#define BOLD   "\033[1m"
 Makes the text bold or high intensity.
 
#define FAINT   "\033[2m"
 Makes the text faint (dimmed).
 
#define ITALIC   "\033[3m"
 Italicizes the text (not supported by all terminals).
 
#define UNDERLINE   "\033[4m"
 Draws a line under the text.
 
#define BLINC   "\033[5m"
 Slow blink (less than 150 per minute).
 
#define FAST_BLINC   "\033[6m"
 Rapid blink (not widely supported).
 
#define STRIKE_THROUGHT   "\033[9m"
 Draws a line through the text.
 
#define NO_UNDERLINE   "\033[24m"
 Disables underlining.
 
#define NO_BLINC   "\033[25m"
 Disables blinking.
 
Terminal ANSI Color Codes

Macros for foreground (text) and background coloring.

#define BLACK   "\033[30m"
 Black text.
 
#define RED   "\033[31m"
 Red text.
 
#define GREEN   "\033[32m"
 Green text.
 
#define YELLOW   "\033[33m"
 Yellow text.
 
#define BLUE   "\033[34m"
 Blue text.
 
#define MAGENTA   "\033[35m"
 Magenta (Purple) text.
 
#define CYAN   "\033[36m"
 Cyan (Light Blue) text.
 
#define WHITE   "\033[37m"
 White text.
 
#define BRIGHT_BLACK   "\033[90m"
 Bright Black (Gray) text.
 
#define BRIGHT_RED   "\033[91m"
 Bright Red text.
 
#define BRIGHT_GREEN   "\033[92m"
 Bright Green text.
 
#define BRIGHT_YELLOW   "\033[93m"
 Bright Yellow text.
 
#define BRIGHT_BLUE   "\033[94m"
 Bright Blue text.
 
#define BRIGHT_MAGENTA   "\033[95m"
 Bright Magenta text.
 
#define BRIGHT_CYAN   "\033[96m"
 Bright Cyan text.
 
#define BRIGHT_WHITE   "\033[97m"
 Bright White text.
 
#define BG_BLACK   "\033[40m"
 Black background.
 
#define BG_RED   "\033[41m"
 Red background.
 
#define BG_GREEN   "\033[42m"
 Green background.
 
#define BG_YELLOW   "\033[43m"
 Yellow background.
 
#define BG_BLUE   "\033[44m"
 Blue background.
 
#define BG_MAGENTA   "\033[45m"
 Magenta background.
 
#define BG_CYAN   "\033[46m"
 Cyan background.
 
#define BG_WHITE   "\033[47m"
 White background.
 

Enumerations

enum  sizeCastTypes { B = static_cast<int>('B') , KB = static_cast<int>('K') , MB = static_cast<int>('M') , GB = static_cast<int>('G') }
 Short names used in dimension type conversions.
 

Variables

constexpr mode_t DEFAULT_FILE_PERMS = 0644
 Default file permissions.
 
constexpr mode_t DEFAULT_EXTENDED_FILE_PERMS = 0755
 Extended file permissions (using by executables etc).
 
constexpr mode_t DEFAULT_DIR_PERMS = 0755
 Default directory permissions.
 
constexpr int YES = 1
 Alternative of true.
 
constexpr int NO = 0
 Alternative of false.
 

Detailed Description

Some concept definitions, descriptions, etc. of the library.

Author
Yağız Zengin (YZBruh)

Macro Definition Documentation

◆ ABORT

#define ABORT (   msg)
Value:
do { \
fprintf(stderr, "%s%sCRITICAL ERROR%s: %s\nAborting...\n", BOLD, RED, STYLE_RESET, msg); \
abort(); \
} while (0)
#define STYLE_RESET
Resets all formatting to default.
Definition definations.hpp:232
#define BOLD
Makes the text bold or high intensity.
Definition definations.hpp:233
#define RED
Red text.
Definition definations.hpp:252

◆ B

#define B (   x)    (static_cast<uint64_t(x)> * 8)

Take x byte as bits.

uint64_t size = B(4); // 32, 4 * 8
#define B(x)
Take x byte as bits.
Definition definations.hpp:159
Parameters
xSize in bytes.

◆ ERROR

#define ERROR (   msg,
  code 
)
Value:
do { \
fprintf(stderr, "%s%sERROR%s: %s", BOLD, RED, STYLE_RESET, msg); \
exit(code); \
} while (0)

◆ GB

#define GB (   x)    (MB(x) * 1024)

Take x gigabyte as bytes.

uint64_t size = GB(1); // 1073741824, MB(1) * 1024
#define GB(x)
Take x gigabyte as bytes.
Definition definations.hpp:192
Parameters
xSize in gigabytes.

◆ KB

#define KB (   x)    (static_cast<uint64_t>(x) * 1024)

Take x kilobyte as bytes.

uint64_t size = KB(8); // 8192, 8 * 1024
#define KB(x)
Take x kilobyte as bytes.
Definition definations.hpp:170
Parameters
xSize in kilobytes.

◆ MB

#define MB (   x)    (KB(x) * 1024)

Take x megabyte as bytes.

uint64_t size = MB(4); // 4194304, KB(4) * 1024
#define MB(x)
Take x megabyte as bytes.
Definition definations.hpp:181
Parameters
xSize in megabytes.

◆ MKVERSION

#define MKVERSION (   name)
Value:
char vinfo[512]; \
sprintf(vinfo, \
"%s %s-%s [%s %s]\nBuild type: %s\nCMake version: %s\nCompiler version: " \
"%s\nCompiler flags: %s", \
name, BUILD_VERSION, COMMIT_ID, BUILD_DATE, BUILD_TIME, BUILD_TYPE, BUILD_CMAKE_VERSION, BUILD_COMPILER_VERSION, \
BUILD_FLAGS); \
return std::string(vinfo)

Generate version string and return.

std::string getLibVersion(void) { MKVERSION("libhelper"); }
#define MKVERSION(name)
Generate version string and return.
Definition definations.hpp:313
Parameters
nameTarget name.
Note
This is a complete function body!!!

◆ TO_GB

#define TO_GB (   x)    (TO_MB(x) / 1024)

Convert x byte to gigabyte.

uint32_t size = TO_GB(1048576); // 1, TO_MB(1048576) / 1024
#define TO_GB(x)
Convert x byte to gigabyte.
Definition definations.hpp:225
Parameters
xSize in bytes.

◆ TO_KB

#define TO_KB (   x)    (x / 1024)

Convert x byte to kilobyte.

uint32_t size = TO_KB(1024); // 1, 1024 / 1024
#define TO_KB(x)
Convert x byte to kilobyte.
Definition definations.hpp:203
Parameters
xSize in bytes.

◆ TO_MB

#define TO_MB (   x)    (TO_KB(x) / 1024)

Convert x byte to megabyte.

uint32_t size = TO_KB(2048); // 2, TO_KB(2048) / 1024
Parameters
xSize in bytes.