Utility.cpp
Go to the documentation of this file.
1 
10 #include <cstdlib>
12 
13 #if defined(_MSC_VER)
14 // Squelch warnings about unsafe use of getenv
15 # pragma warning (disable: 4996)
16 #endif
17 
18 namespace GeographicLib {
19 
20  using namespace std;
21 
22  bool Utility::ParseLine(const std::string& line,
23  std::string& key, std::string& val) {
24  const char* spaces = " \t\n\v\f\r";
25  string::size_type n0 = line.find_first_not_of(spaces);
26  if (n0 == string::npos)
27  return false; // Blank line
28  string::size_type n1 = line.find_first_of('#', n0);
29  if (n0 == n1)
30  return false; // Only a comment
31  val = line.substr(n0, n1 == string::npos ? n1 : n1 - n0);
32  n0 = val.find_first_of(spaces);
33  key = val.substr(0, n0);
34  if (n0 == string::npos) {
35  val = "";
36  return true;
37  }
38  n0 = val.find_first_not_of(spaces, n0);
39  if (n0 == string::npos) {
40  val = "";
41  return true;
42  }
43  n1 = val.find_last_not_of(spaces);
44  val = val.substr(n0, n1 + 1 - n0);
45  return true;
46  }
47 
48  int Utility::set_digits(int ndigits) {
49 #if GEOGRAPHICLIB_PRECISION == 5
50  if (ndigits <= 0) {
51  char* digitenv = getenv("GEOGRAPHICLIB_DIGITS");
52  if (digitenv)
53  ndigits = strtol(digitenv, NULL, 0);
54  if (ndigits <= 0)
55  ndigits = 256;
56  }
57 #endif
58  return Math::set_digits(ndigits);
59  }
60 
61 } // namespace GeographicLib
const gtsam::Symbol key('X', 0)
static int set_digits(int ndigits)
Definition: Math.hpp:163
Header for GeographicLib::Utility class.
Definition: BFloat16.h:88
Namespace for GeographicLib.
#define NULL
Definition: ccolamd.c:609
static int set_digits(int ndigits=0)
Definition: Utility.cpp:48
static bool ParseLine(const std::string &line, std::string &key, std::string &val)
Definition: Utility.cpp:22


gtsam
Author(s):
autogenerated on Tue Jul 4 2023 02:40:43