cpp-terminal
1.0.0
Small C++ library for writing multiplatform terminal applications
Loading...
Searching...
No Matches
return_code.cpp
Go to the documentation of this file.
1
/*
2
* cpp-terminal
3
* C++ library for writing multi-platform terminal applications.
4
*
5
* SPDX-FileCopyrightText: 2019-2024 cpp-terminal
6
*
7
* SPDX-License-Identifier: MIT
8
*/
9
10
#include "
cpp-terminal/private/return_code.hpp
"
11
12
#include "
cpp-terminal/private/env.hpp
"
13
14
#include <cstdlib>
15
#include <string>
16
#include <utility>
17
18
std::uint16_t
Term::returnCode
() noexcept
19
{
20
static
std::uint16_t code{EXIT_FAILURE};
21
const
std::pair<bool, std::string>
returnCode
{Private::getenv(
"CPP_TERMINAL_BADSTATE"
)};
22
try
23
{
24
if
(
returnCode
.first && (std::stoi(
returnCode
.second) != EXIT_SUCCESS)) { code =
static_cast<
std::uint16_t
>
(std::stoi(
returnCode
.second)); }
25
}
26
catch
(...)
27
{
28
code = EXIT_FAILURE;
29
}
30
return
code;
31
}
env.hpp
Term::returnCode
std::uint16_t returnCode() noexcept
Definition
return_code.cpp:18
return_code.hpp
cpp-terminal
private
return_code.cpp
Generated by
1.11.0