Cheetah Software  1.0
save_file.h File Reference
#include <Configuration.h>
#include <cppTypes.h>
#include <stdio.h>
#include <sys/stat.h>
#include <algorithm>
#include <fstream>
#include <iostream>
#include <list>
#include <string>
+ Include dependency graph for save_file.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void cleaning_file (const std::string &folder_name, const std::string &file_name, std::string &full_ret_file)
 
void create_folder (const std::string &folder_name)
 
template<typename T >
void saveVector (const DVec< T > &_vec, const std::string &folder_name, const std::string &file_name)
 
template<typename T >
void saveVector (const Vec3< T > &_vec, const std::string &folder_name, const std::string &file_name)
 
template<typename T >
void saveVector (const std::vector< T > &_vec, const std::string &folder_name, const std::string &file_name)
 
template<typename T >
void saveVector (T *_vec, const std::string &folder_name, const std::string &file_name, int size)
 
template<typename T >
void saveValue (T _value, const std::string &folder_name, const std::string &file_name)
 

Variables

static std::list< std::string > gs_fileName_string
 

Function Documentation

void cleaning_file ( const std::string &  folder_name,
const std::string &  file_name,
std::string &  full_ret_file 
)

Definition at line 3 of file save_file.cpp.

References gs_fileName_string.

4  {
5  full_ret_file = THIS_COM + folder_name + file_name;
6  full_ret_file += ".txt";
7 
8  std::list<std::string>::iterator iter = std::find(
9  gs_fileName_string.begin(), gs_fileName_string.end(), full_ret_file);
10  if (gs_fileName_string.end() == iter) {
11  gs_fileName_string.push_back(full_ret_file);
12  remove(full_ret_file.c_str());
13  }
14 }
static std::list< std::string > gs_fileName_string
Definition: save_file.h:14
std::string folder_name
Definition: test_spline.cpp:13

+ Here is the caller graph for this function:

void create_folder ( const std::string &  folder_name)

Definition at line 16 of file save_file.cpp.

References folder_name.

16  {
17  std::string full_path = THIS_COM + folder_name;
18 
19  if (mkdir(full_path.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) == -1) {
20  if (errno == EEXIST) {
21  // alredy exists
22  // printf("%s is already exist\n", full_path.c_str());
23  } else {
24  // something else
25  std::cout << "cannot create session name folder error:" << strerror(errno)
26  << std::endl;
27  exit(0);
28  }
29  }
30 }
std::string folder_name
Definition: test_spline.cpp:13
template<typename T >
void saveValue ( _value,
const std::string &  folder_name,
const std::string &  file_name 
)

Definition at line 69 of file save_file.h.

References cleaning_file().

70  {
71  std::string full_file_name;
72  cleaning_file(folder_name, file_name, full_file_name);
73  std::ofstream savefile(full_file_name.c_str(), std::ios::app);
74 
75  savefile << _value << "\n";
76  savefile.flush();
77 }
void cleaning_file(const std::string &folder_name, const std::string &file_name, std::string &full_ret_file)
Definition: save_file.cpp:3
std::string folder_name
Definition: test_spline.cpp:13

+ Here is the call graph for this function:

template<typename T >
void saveVector ( const DVec< T > &  _vec,
const std::string &  folder_name,
const std::string &  file_name 
)

Definition at line 22 of file save_file.h.

References cleaning_file().

23  {
24  std::string full_file_name;
25  cleaning_file(folder_name, file_name, full_file_name);
26 
27  std::ofstream savefile(full_file_name.c_str(), std::ios::app);
28  for (int i(0); i < _vec.rows(); ++i) {
29  savefile << _vec(i) << "\t";
30  }
31  savefile << "\n";
32  savefile.flush();
33 }
void cleaning_file(const std::string &folder_name, const std::string &file_name, std::string &full_ret_file)
Definition: save_file.cpp:3
std::string folder_name
Definition: test_spline.cpp:13

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<typename T >
void saveVector ( const Vec3< T > &  _vec,
const std::string &  folder_name,
const std::string &  file_name 
)

Definition at line 36 of file save_file.h.

References saveVector().

37  {
38  saveVector((DVec<T>)_vec, folder_name, file_name);
39 }
void saveVector(const DVec< T > &_vec, const std::string &folder_name, const std::string &file_name)
Definition: save_file.h:22
std::string folder_name
Definition: test_spline.cpp:13
typename Eigen::Matrix< T, Eigen::Dynamic, 1 > DVec
Definition: cppTypes.h:102

+ Here is the call graph for this function:

template<typename T >
void saveVector ( const std::vector< T > &  _vec,
const std::string &  folder_name,
const std::string &  file_name 
)

Definition at line 42 of file save_file.h.

References cleaning_file().

43  {
44  std::string full_file_name;
45  cleaning_file(folder_name, file_name, full_file_name);
46  std::ofstream savefile(full_file_name.c_str(), std::ios::app);
47 
48  for (unsigned int i(0); i < _vec.size(); ++i) {
49  savefile << _vec[i] << "\t";
50  }
51  savefile << "\n";
52  savefile.flush();
53 }
void cleaning_file(const std::string &folder_name, const std::string &file_name, std::string &full_ret_file)
Definition: save_file.cpp:3
std::string folder_name
Definition: test_spline.cpp:13

+ Here is the call graph for this function:

template<typename T >
void saveVector ( T *  _vec,
const std::string &  folder_name,
const std::string &  file_name,
int  size 
)

Definition at line 56 of file save_file.h.

References cleaning_file().

57  {
58  std::string full_file_name;
59  cleaning_file(folder_name, file_name, full_file_name);
60  std::ofstream savefile(full_file_name.c_str(), std::ios::app);
61  for (int i(0); i < size; ++i) {
62  savefile << _vec[i] << "\t";
63  }
64  savefile << "\n";
65  savefile.flush();
66 }
void cleaning_file(const std::string &folder_name, const std::string &file_name, std::string &full_ret_file)
Definition: save_file.cpp:3
std::string folder_name
Definition: test_spline.cpp:13

+ Here is the call graph for this function:

Variable Documentation

std::list<std::string> gs_fileName_string
static

Definition at line 14 of file save_file.h.