From 6787fdd7ebcf33da082af2c5b883936c9232b4b5 Mon Sep 17 00:00:00 2001 From: rail5 Date: Sun, 26 Mar 2023 20:20:15 -0400 Subject: [PATCH] Cleaned up includes --- edit/src/includes.h | 42 +++++++++++++++++++++----- shared_functions/parse_block_units.cpp | 5 +++ 2 files changed, 39 insertions(+), 8 deletions(-) diff --git a/edit/src/includes.h b/edit/src/includes.h index 8275b3c..cdaec1e 100644 --- a/edit/src/includes.h +++ b/edit/src/includes.h @@ -49,22 +49,48 @@ #include #endif + /* inline bool file_exists(std::string name) returns true if the file exists */ -#include "../../shared_functions/file_exists.cpp" +#ifndef FN_FILE_EXISTS + #define FN_FILE_EXISTS + #include "../../shared_functions/file_exists.cpp" +#endif /* inline std::string isolate_path_from_filename(std::string filename) returns the path to the directory a given file is in */ -#include "../../shared_functions/isolate_path_from_filename.cpp" +#ifndef FN_ISOLATE_PATH_FROM_FILENAME + #define FN_ISOLATE_PATH_FROM_FILENAME + #include "../../shared_functions/isolate_path_from_filename.cpp" +#endif /* inline bool file_is_writable(std::string filename) returns true if current UID has write permissions to that path */ -#include "../../shared_functions/file_is_writable.cpp" +#ifndef FN_IS_WRITABLE + #define FN_IS_WRITABLE + #include "../../shared_functions/file_is_writable.cpp" +#endif /* inline std::string to_lower(std::string &input) returns the input string in all-lowercase */ -#include "../../shared_functions/to_lower.cpp" +#ifndef FN_TO_LOWER + #define FN_TO_LOWER + #include "../../shared_functions/to_lower.cpp" +#endif /* std::vector explode(std::string const &input, char delimiter, int maximum_number_of_elements = 0) returns a vector split based on the given delimiter. Similar to PHP's explode() */ -#include "../../shared_functions/explode.cpp" +#ifndef FN_EXPLODE + #define FN_EXPLODE + #include "../../shared_functions/explode.cpp" +#endif /* inline bool is_number(const std::string &s) returns true if all chars in string are digits */ -#include "../../shared_functions/is_number.cpp" +#ifndef FN_IS_NUMBER + #define FN_IS_NUMBER + #include "../../shared_functions/is_number.cpp" +#endif /* inline int parse_block_units(const std::string &user_input) converts sizes such as '10K' or '16M' to equivalent in bytes */ -#include "../../shared_functions/parse_block_units.cpp" +#ifndef FN_PARSE_BLOCK_UNITS + #define FN_PARSE_BLOCK_UNITS + #include "../../shared_functions/parse_block_units.cpp" +#endif /* void remove_leading_whitespace(string &input) removes whitespace from the beginning of an input string */ -#include "../../shared_functions/remove_leading_whitespace.cpp" +#ifndef FN_REMOVE_LEADING_WHITESPACE + #define FN_REMOVE_LEADING_WHITESPACE + #include "../../shared_functions/remove_leading_whitespace.cpp" +#endif + /* Contains the 'meat' of the program */ #include "namespace_editor.h" diff --git a/shared_functions/parse_block_units.cpp b/shared_functions/parse_block_units.cpp index 8756b01..d7b7688 100644 --- a/shared_functions/parse_block_units.cpp +++ b/shared_functions/parse_block_units.cpp @@ -1,3 +1,8 @@ +#ifndef FN_IS_NUMBER + #define FN_IS_NUMBER + #include "is_number.cpp" +#endif + inline int parse_block_units(const std::string &user_input) { /*** inline int parse_block_units(std::string user_input):