Skip to content

Commit 8646d9f

Browse files
refactor(core): move trim helper into src/core/Core/funcs.hpp
1 parent 8255a76 commit 8646d9f

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

src/core/Core/Application.cpp

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -169,14 +169,7 @@ ExitStatus App::Application::run() {
169169

170170
// (f(t), g(t))
171171
std::string func_str(function);
172-
auto trim = [](std::string s) {
173-
const char* ws = " \t\n\r";
174-
size_t start = s.find_first_not_of(ws);
175-
size_t end = s.find_last_not_of(ws);
176-
if (start == std::string::npos)
177-
return std::string();
178-
return s.substr(start, end - start + 1);
179-
};
172+
180173

181174
bool plotted = false;
182175

src/core/Core/funcs.hpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
#ifndef IMGRAPH_FUNCS_HPP
66
#define IMGRAPH_FUNCS_HPP
77
#include <numbers>
8-
8+
#include <string>
9+
#include <cctype>
910
#include "exprtk.hpp"
1011

1112
inline void addConstants(exprtk::symbol_table<double> &symbolTable) {
@@ -18,4 +19,14 @@ inline void addConstants(exprtk::symbol_table<double> &symbolTable) {
1819
symbolTable.add_constant("γ", std::numbers::egamma);
1920
}
2021

22+
inline std::string trim(const std::string& s) {
23+
const char* ws = " \t\n\r";
24+
size_t start = s.find_first_not_of(ws);
25+
size_t end = s.find_last_not_of(ws);
26+
if (start == std::string::npos)
27+
return std::string();
28+
return s.substr(start, end - start + 1);
29+
}
30+
2131
#endif // IMGRAPH_FUNCS_HPP
32+

0 commit comments

Comments
 (0)