Cheetah Software  1.0
utilities.cpp File Reference
#include "include/Utilities/utilities.h"
#include <ctime>
#include <iomanip>
#include <iostream>
+ Include dependency graph for utilities.cpp:

Go to the source code of this file.

Functions

void writeStringToFile (const std::string &fileName, const std::string &fileData)
 
std::string getCurrentTimeAndDate ()
 
std::string getConfigDirectoryPath ()
 
std::string getLcmUrl (s64 ttl)
 

Function Documentation

std::string getConfigDirectoryPath ( )

Todo: do something better to keep track of where we are relative to the config directory

Definition at line 30 of file utilities.cpp.

30 { return "../config/"; }

+ Here is the caller graph for this function:

std::string getCurrentTimeAndDate ( )

Definition at line 18 of file utilities.cpp.

18  {
19  auto t = std::time(nullptr);
20  auto tm = *std::localtime(&t);
21  std::ostringstream ss;
22  ss << std::put_time(&tm, "%c");
23  return ss.str();
24 }

+ Here is the caller graph for this function:

std::string getLcmUrl ( s64  ttl)

Definition at line 32 of file utilities.cpp.

32  {
33  assert(ttl >= 0 && ttl <= 255);
34  return "udpm://239.255.76.67:7667?ttl=" + std::to_string(ttl);
35 }

+ Here is the caller graph for this function:

void writeStringToFile ( const std::string &  fileName,
const std::string &  fileData 
)

Definition at line 7 of file utilities.cpp.

8  {
9  FILE* fp = fopen(fileName.c_str(), "w");
10  if (!fp) {
11  printf("Failed to fopen %s\n", fileName.c_str());
12  throw std::runtime_error("Failed to open file");
13  }
14  fprintf(fp, "%s", fileData.c_str());
15  fclose(fp);
16 }

+ Here is the caller graph for this function: