Treehopper C++ API
Utility.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <string>
4 
5 #include "Treehopper.h"
6 #include <stdexcept>
7 #include <vector>
8 
9 namespace Treehopper {
11  public:
12  static void error(std::runtime_error &message, bool fatal = false);
13 
14  static void error(std::string message, bool fatal = false) {
15  auto err = std::runtime_error(message);
16  error(err, fatal);
17  }
18 
19  static bool closeTo(double a, double b, double error = 0.001);
20 
21  static bool isBigEndian();
22 
23  static int nthOccurrence(const std::wstring &str, const std::wstring &findMe, int nth);
24 
25  static std::vector<uint8_t> getBytes(uint64_t value, int width, bool isBigEndian = false);
26 
27  static uint64_t getValue(std::vector<uint8_t> bytes, bool isBigEndian = false);
28  };
29 }
static void error(std::string message, bool fatal=false)
Definition: Utility.h:14
Definition: AdcPin.h:3
#define TREEHOPPER_API
Definition: Treehopper.h:17
Definition: Utility.h:10