YARP
Yet Another Robot Platform
utility.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2020 Istituto Italiano di Tecnologia (IIT)
3  * All rights reserved.
4  *
5  * This software may be modified and distributed under the terms of the
6  * BSD-3-Clause license. See the accompanying LICENSE file for details.
7  */
8 
9 #ifndef YARP_MANAGER_UTILITY
10 #define YARP_MANAGER_UTILITY
11 
12 #include <algorithm>
13 #include <cctype>
14 #include <string>
15 #include <vector>
16 #include <cstring>
17 #include <iostream>
18 #include <sstream>
19 
20 #include <yarp/manager/ymm-types.h>
21 
22 namespace yarp {
23 namespace manager {
24 
25 
26 class StrStream
27 {
28 public:
30  StrStream(const std::string str);
32  std::string str();
34  StrStream& operator<<(const std::string &str);
35  StrStream& operator<<(int n);
36  StrStream& operator<<(double n);
37  StrStream& operator = (const char* sz);
38  StrStream& operator = (char* sz);
39  StrStream& operator = (const std::string &str);
41  StrStream& operator = (int n);
42  friend std::ostream& operator << (std::ostream &os , StrStream& sstr);
43 
44 private:
45  std::string dummyStr;
46 };
47 
48 
49 #if defined(_MSC_VER) && (_MSC_VER == 1600)
50  typedef StrStream OSTRINGSTREAM;
51 #else
52  typedef std::stringstream OSTRINGSTREAM;
53 #endif
54 
55 
60 {
61 public:
62  static ErrorLogger* Instance();
63 
64  void addWarning(const char* szWarning);
65  void addWarning(const std::string &str);
66  void addWarning(OSTRINGSTREAM &stream);
67  void addError(const char* szError);
68  void addError(const std::string &str);
69  void addError(OSTRINGSTREAM &stream);
70  const char* getLastError();
71  const char* getLastWarning();
72  const char* getFormatedErrorString();
73  const char* getFormatedWarningString();
74  void clear();
75  int errorCount();
76  int warningCount();
77 
78 private:
79  ErrorLogger(){}
80  ErrorLogger(ErrorLogger const&){}
81  std::vector<std::string> errors;
82  std::vector<std::string> warnings;
83 };
84 
85 
86 bool compareString(const char* szFirst, const char* szSecond);
87 void trimString(std::string& str);
88 OS strToOS(const char* szOS);
89 
90 class Graph;
91 bool exportDotGraph(Graph& graph, const char* szFileName);
92 
93 } // namespace yarp
94 } // namespace manager
95 
96 
97 #endif // __YARP_MANAGER_UTILITY__
yarp::manager::ErrorLogger::getLastWarning
const char * getLastWarning()
Definition: utility.cpp:151
yarp::manager::ErrorLogger::clear
void clear()
Definition: utility.cpp:169
yarp::manager::ErrorLogger::getLastError
const char * getLastError()
Definition: utility.cpp:134
yarp::manager::OSTRINGSTREAM
std::stringstream OSTRINGSTREAM
Definition: utility.h:52
yarp::manager::ErrorLogger
Singleton class ErrorLogger.
Definition: utility.h:60
yarp::manager::Graph
Class Graph.
Definition: graph.h:31
yarp::manager::compareString
bool compareString(const char *szFirst, const char *szSecond)
Definition: utility.cpp:305
yarp::manager::trimString
void trimString(std::string &str)
Definition: utility.cpp:323
yarp::manager::StrStream::operator=
StrStream & operator=(const char *sz)
Definition: utility.cpp:62
yarp::manager::ErrorLogger::Instance
static ErrorLogger * Instance()
Singleton class ErrorLogger.
Definition: utility.cpp:102
yarp::manager::StrStream
Definition: utility.h:27
yarp::manager::ErrorLogger::addError
void addError(const char *szError)
Definition: utility.cpp:121
yarp::manager::StrStream::~StrStream
~StrStream()
yarp::manager::OS
enum yarp::manager::__OS OS
ymm-types.h
yarp::manager::StrStream::str
std::string str()
Definition: utility.cpp:33
yarp::manager::StrStream::StrStream
StrStream()
yarp::manager::ErrorLogger::addWarning
void addWarning(const char *szWarning)
Definition: utility.cpp:108
yarp::manager::exportDotGraph
bool exportDotGraph(Graph &graph, const char *szFileName)
Definition: utility.cpp:337
yarp::manager::ErrorLogger::warningCount
int warningCount()
Definition: utility.cpp:177
yarp::manager::StrStream::operator<<
StrStream & operator<<(StrStream &oss)
Definition: utility.cpp:37
yarp
The main, catch-all namespace for YARP.
Definition: environment.h:18
yarp::manager::ErrorLogger::errorCount
int errorCount()
Definition: utility.cpp:173
yarp::manager::ErrorLogger::getFormatedErrorString
const char * getFormatedErrorString()
Definition: utility.cpp:143
yarp::manager::ErrorLogger::getFormatedWarningString
const char * getFormatedWarningString()
Definition: utility.cpp:160
yarp::manager::strToOS
OS strToOS(const char *szOS)
Definition: utility.cpp:290