Arkanjo 0.1
A tool for find code duplicated functions in codebases
Loading...
Searching...
No Matches
utils.hpp File Reference

Defines utility functions used across all files. More...

#include <iostream>
#include <iomanip>
#include <cassert>
#include <string>
#include <vector>
#include <fstream>
#include <sstream>
#include <cctype>
#include <sys/stat.h>
#include "../third-party/json.hpp"
+ Include dependency graph for utils.hpp:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  Utils
 

Enumerations

enum  Utils::COLOR {
  Utils::RESET , Utils::RED , Utils::GREEN , Utils::YELLOW ,
  Utils::BLUE , Utils::MAGENTA , Utils::CYAN , Utils::GRAY ,
  Utils::WHITE , Utils::BRIGHT_YELLOW , Utils::BLACK
}
 Enumeration of available colors for formatted messages. More...
 

Functions

void Utils::ensure_file_is_open (std::ifstream &file, string file_name)
 Ensures that a file stream is successfully opened.
 
vector< string > Utils::read_file_generic (string string_path)
 Reads a file line by line into a vector of strings.
 
void Utils::write_file_generic (string file_path, vector< string > content)
 Writes content to a file at specified path.
 
void Utils::create_parents_folder_of_file_path (string file_path)
 Creates all parent directories for a given file path.
 
json Utils::read_json (string string_path)
 Reads and parses a JSON file, uses nlohmann json library.
 
bool Utils::does_file_exist (string file_path)
 Checks if a file exists at the given path.
 
bool Utils::is_regular_file (string path)
 Determines if a path refers to a regular file.
 
string Utils::format_colored_message (string message, COLOR color)
 Formats a message with ANSI color codes.
 
bool Utils::is_empty_char (char c)
 Checks if a character is considered empty/whitespace.
 
bool Utils::is_special_char (char c)
 Checks if a character is special (non-alphanumeric and not underscore)
 
vector< string > Utils::split_string (string s, char delimiter)
 Splits a string by a delimiter into tokens.
 

Variables

const string Utils::LIMITER_PRINT = "---------------------"
 Constant string used as a visual delimiter/separator in prints.
 
const int Utils::MKDIR_FLAG = 0700
 Permission flags used when creating directories (rwx for owner)
 
const vector< string > Utils::COLOR_TOKENS_UTILS_LIGTH
 ANSI color codes for light terminal backgrounds.
 
const vector< string > Utils::COLOR_TOKENS_UTILS_DARK
 ANSI color codes for dark terminal backgrounds.
 

Detailed Description

Defines utility functions used across all files.

This header provides generic utility functions that are not project-specific. Includes file operations, string manipulation, and colored output utilities.

Definition in file utils.hpp.