Coverage Report

Created: 2026-12-03 06:40

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/poco/Foundation/src/Environment.cpp
Line
Count
Source
1
//
2
// Environment.cpp
3
//
4
// Library: Foundation
5
// Package: Core
6
// Module:  Environment
7
//
8
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
9
// and Contributors.
10
//
11
// SPDX-License-Identifier: BSL-1.0
12
//
13
14
15
#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS)
16
#define _CRT_SECURE_NO_WARNINGS
17
#endif
18
19
20
#include "Poco/Environment.h"
21
#include "Poco/Version.h"
22
#include <cstdlib>
23
#include <cstdio> // snprintf()
24
25
26
#if defined(POCO_VXWORKS)
27
#include "Environment_VX.cpp"
28
#elif defined(POCO_OS_FAMILY_UNIX)
29
#include "Environment_UNIX.cpp"
30
#elif defined(POCO_OS_FAMILY_WINDOWS)
31
#include "Environment_WIN32U.cpp"
32
#endif
33
34
35
namespace Poco {
36
37
38
std::string Environment::get(const std::string& name)
39
0
{
40
0
  return EnvironmentImpl::getImpl(name);
41
0
}
42
43
44
std::string Environment::get(const std::string& name, const std::string& defaultValue)
45
0
{
46
0
  if (has(name))
47
0
    return get(name);
48
0
  else
49
0
    return defaultValue;
50
0
}
51
52
53
bool Environment::has(const std::string& name)
54
0
{
55
0
  return EnvironmentImpl::hasImpl(name);
56
0
}
57
58
59
void Environment::set(const std::string& name, const std::string& value)
60
0
{
61
0
  EnvironmentImpl::setImpl(name, value);
62
0
}
63
64
65
std::string Environment::osName()
66
0
{
67
0
  return EnvironmentImpl::osNameImpl();
68
0
}
69
70
71
std::string Environment::osDisplayName()
72
0
{
73
0
  return EnvironmentImpl::osDisplayNameImpl();
74
0
}
75
76
77
std::string Environment::osVersion()
78
0
{
79
0
  return EnvironmentImpl::osVersionImpl();
80
0
}
81
82
83
std::string Environment::osArchitecture()
84
0
{
85
0
  return EnvironmentImpl::osArchitectureImpl();
86
0
}
87
88
89
std::string Environment::nodeName()
90
0
{
91
0
  return EnvironmentImpl::nodeNameImpl();
92
0
}
93
94
95
std::string Environment::nodeId()
96
0
{
97
0
  NodeId id;
98
0
  nodeId(id);
99
0
  char result[18];
100
0
  std::snprintf(result, sizeof(result), "%02x:%02x:%02x:%02x:%02x:%02x",
101
0
    id[0],
102
0
    id[1],
103
0
    id[2],
104
0
    id[3],
105
0
    id[4],
106
0
    id[5]);
107
0
  return std::string(result);
108
0
}
109
110
111
void Environment::nodeId(NodeId& id)
112
0
{
113
0
  return EnvironmentImpl::nodeIdImpl(id);
114
0
}
115
116
117
unsigned Environment::processorCount()
118
0
{
119
0
  return EnvironmentImpl::processorCountImpl();
120
0
}
121
122
123
Poco::UInt32 Environment::libraryVersion()
124
1.88k
{
125
1.88k
  return POCO_VERSION;
126
1.88k
}
127
128
129
Poco::Int32 Environment::os()
130
0
{
131
0
  return POCO_OS;
132
0
}
133
134
135
Poco::Int32 Environment::arch()
136
0
{
137
0
  return POCO_ARCH;
138
0
}
139
140
141
bool Environment::isUnix()
142
0
{
143
0
#if defined(POCO_OS_FAMILY_UNIX)
144
0
  return true;
145
#else
146
  return false;
147
#endif
148
0
}
149
150
151
bool Environment::isWindows()
152
0
{
153
#if defined(POCO_OS_FAMILY_WINDOWS)
154
  return true;
155
#else
156
0
  return false;
157
0
#endif
158
0
}
159
160
161
} // namespace Poco