[DEV] change log system
This commit is contained in:
parent
e730ba434e
commit
7f2fe7980f
@ -197,12 +197,13 @@ namespace etk {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
etk::CCout& etk::operator <<(etk::CCout &_os, const etk::Color<uint8_t>& _obj) {
|
std::ostream& etk::operator <<(std::ostream& _os, const etk::Color<uint8_t>& _obj) {
|
||||||
_os << "#";
|
_os << "#";
|
||||||
_os << (std::to_string<uint32_t>(_obj.get(), std::hex)).c_str();
|
_os << (std::to_string<uint32_t>(_obj.get(), std::hex)).c_str();
|
||||||
return _os;
|
return _os;
|
||||||
}
|
}
|
||||||
etk::CCout& etk::operator <<(etk::CCout &_os, const etk::Color<float>& _obj)
|
|
||||||
|
std::ostream& etk::operator <<(std::ostream& _os, const etk::Color<float>& _obj)
|
||||||
{
|
{
|
||||||
_os << "rgba(";
|
_os << "rgba(";
|
||||||
_os << _obj.r();
|
_os << _obj.r();
|
||||||
@ -216,7 +217,7 @@ etk::CCout& etk::operator <<(etk::CCout &_os, const etk::Color<float>& _obj)
|
|||||||
return _os;
|
return _os;
|
||||||
}
|
}
|
||||||
|
|
||||||
etk::CCout& etk::operator <<(etk::CCout& _os, const std::vector<etk::Color<uint8_t> >& _obj) {
|
std::ostream& etk::operator <<(std::ostream& _os, const std::vector<etk::Color<uint8_t> >& _obj) {
|
||||||
for (size_t iii = 0; iii < _obj.size(); ++iii) {
|
for (size_t iii = 0; iii < _obj.size(); ++iii) {
|
||||||
if (iii != 0) {
|
if (iii != 0) {
|
||||||
_os << " ";
|
_os << " ";
|
||||||
@ -225,7 +226,7 @@ etk::CCout& etk::operator <<(etk::CCout& _os, const std::vector<etk::Color<uint8
|
|||||||
}
|
}
|
||||||
return _os;
|
return _os;
|
||||||
}
|
}
|
||||||
etk::CCout& etk::operator <<(etk::CCout& _os, const std::vector<etk::Color<float> >& _obj) {
|
std::ostream& etk::operator <<(std::ostream& _os, const std::vector<etk::Color<float> >& _obj) {
|
||||||
for (size_t iii = 0; iii < _obj.size(); ++iii) {
|
for (size_t iii = 0; iii < _obj.size(); ++iii) {
|
||||||
if (iii != 0) {
|
if (iii != 0) {
|
||||||
_os << " ";
|
_os << " ";
|
||||||
@ -236,8 +237,6 @@ etk::CCout& etk::operator <<(etk::CCout& _os, const std::vector<etk::Color<float
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const etk::Color<> etk::color::none((uint32_t)0x00000000);
|
const etk::Color<> etk::color::none((uint32_t)0x00000000);
|
||||||
const etk::Color<> etk::color::aliceBlue((uint32_t)0xF0F8FFFF);
|
const etk::Color<> etk::color::aliceBlue((uint32_t)0xF0F8FFFF);
|
||||||
const etk::Color<> etk::color::antiqueWhite((uint32_t)0xFAEBD7FF);
|
const etk::Color<> etk::color::antiqueWhite((uint32_t)0xFAEBD7FF);
|
||||||
|
10
etk/Color.h
10
etk/Color.h
@ -239,11 +239,13 @@ namespace etk {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
//! @not-in-doc
|
//! @not-in-doc
|
||||||
etk::CCout& operator <<(etk::CCout &_os, const Color<uint8_t>& _obj);
|
std::ostream& operator <<(std::ostream& _os, const Color<uint8_t>& _obj);
|
||||||
//! @not-in-doc
|
//! @not-in-doc
|
||||||
etk::CCout& operator <<(etk::CCout &_os, const Color<float>& _obj);
|
std::ostream& operator <<(std::ostream& _os, const Color<float>& _obj);
|
||||||
etk::CCout& operator <<(etk::CCout& _os, const std::vector<Color<uint8_t> >& _obj);
|
//! @not-in-doc
|
||||||
etk::CCout& operator <<(etk::CCout& _os, const std::vector<Color<float> >& _obj);
|
std::ostream& operator <<(std::ostream& _os, const std::vector<Color<uint8_t> >& _obj);
|
||||||
|
//! @not-in-doc
|
||||||
|
std::ostream& operator <<(std::ostream& _os, const std::vector<Color<float> >& _obj);
|
||||||
/**
|
/**
|
||||||
* @brief List of all native define colors ...
|
* @brief List of all native define colors ...
|
||||||
*/
|
*/
|
||||||
|
@ -64,38 +64,39 @@ const struct etk::convertionTable etk::constConvertionTable[] = {
|
|||||||
};
|
};
|
||||||
const int64_t etk::constConvertionTableSize = sizeof(etk::constConvertionTable) / sizeof(struct etk::convertionTable) ;
|
const int64_t etk::constConvertionTableSize = sizeof(etk::constConvertionTable) / sizeof(struct etk::convertionTable) ;
|
||||||
|
|
||||||
void etk::displayElem(const std::vector<char32_t>& _data, int64_t _start, int64_t _stop) {
|
std::ostream& etk::displayElem(std::ostream& _os, const std::vector<char32_t>& _data, int64_t _start, int64_t _stop) {
|
||||||
etk::cout<< ETK_BASH_COLOR_NORMAL;
|
_os << ETK_BASH_COLOR_NORMAL;
|
||||||
for (int64_t iii=_start; iii<(int64_t)_data.size() && iii<_stop ; iii++) {
|
for (int64_t iii=_start; iii<(int64_t)_data.size() && iii<_stop ; iii++) {
|
||||||
switch(_data[iii]) {
|
switch(_data[iii]) {
|
||||||
case regexpOpcodePTheseIn: etk::cout<<ETK_BASH_COLOR_RED << (char*)"(" << ETK_BASH_COLOR_NORMAL; break;
|
case regexpOpcodePTheseIn: _os <<ETK_BASH_COLOR_RED << (char*)"(" << ETK_BASH_COLOR_NORMAL; break;
|
||||||
case regexpOpcodePTheseOut: etk::cout<<ETK_BASH_COLOR_RED << (char*)")" << ETK_BASH_COLOR_NORMAL; break;
|
case regexpOpcodePTheseOut: _os<<ETK_BASH_COLOR_RED << (char*)")" << ETK_BASH_COLOR_NORMAL; break;
|
||||||
case regexpOpcodeBracketIn: etk::cout<<ETK_BASH_COLOR_YELLOW << (char*)"[" << ETK_BASH_COLOR_NORMAL; break;
|
case regexpOpcodeBracketIn: _os<<ETK_BASH_COLOR_YELLOW << (char*)"[" << ETK_BASH_COLOR_NORMAL; break;
|
||||||
case regexpOpcodeBracketOut: etk::cout<<ETK_BASH_COLOR_YELLOW << (char*)"]" << ETK_BASH_COLOR_NORMAL; break;
|
case regexpOpcodeBracketOut: _os<<ETK_BASH_COLOR_YELLOW << (char*)"]" << ETK_BASH_COLOR_NORMAL; break;
|
||||||
case regexpOpcodeTo: etk::cout<<ETK_BASH_COLOR_YELLOW << (char*)"-" << ETK_BASH_COLOR_NORMAL; break;
|
case regexpOpcodeTo: _os<<ETK_BASH_COLOR_YELLOW << (char*)"-" << ETK_BASH_COLOR_NORMAL; break;
|
||||||
case regexpOpcodeBracetIn: etk::cout<<ETK_BASH_COLOR_GREEN << (char*)"{" << ETK_BASH_COLOR_NORMAL; break;
|
case regexpOpcodeBracetIn: _os<<ETK_BASH_COLOR_GREEN << (char*)"{" << ETK_BASH_COLOR_NORMAL; break;
|
||||||
case regexpOpcodeBracetOut: etk::cout<<ETK_BASH_COLOR_GREEN << (char*)"}" << ETK_BASH_COLOR_NORMAL; break;
|
case regexpOpcodeBracetOut: _os<<ETK_BASH_COLOR_GREEN << (char*)"}" << ETK_BASH_COLOR_NORMAL; break;
|
||||||
case regexpOpcodeStar: etk::cout<<ETK_BASH_COLOR_BLUE << (char*)"*" << ETK_BASH_COLOR_NORMAL; break;
|
case regexpOpcodeStar: _os<<ETK_BASH_COLOR_BLUE << (char*)"*" << ETK_BASH_COLOR_NORMAL; break;
|
||||||
case regexpOpcodeDot: etk::cout<<ETK_BASH_COLOR_BLUE << (char*)"." << ETK_BASH_COLOR_NORMAL; break;
|
case regexpOpcodeDot: _os<<ETK_BASH_COLOR_BLUE << (char*)"." << ETK_BASH_COLOR_NORMAL; break;
|
||||||
case regexpOpcodeQuestion: etk::cout<<ETK_BASH_COLOR_BLUE << (char*)"?" << ETK_BASH_COLOR_NORMAL; break;
|
case regexpOpcodeQuestion: _os<<ETK_BASH_COLOR_BLUE << (char*)"?" << ETK_BASH_COLOR_NORMAL; break;
|
||||||
case regexpOpcodePlus: etk::cout<<ETK_BASH_COLOR_BLUE << (char*)"+" << ETK_BASH_COLOR_NORMAL; break;
|
case regexpOpcodePlus: _os<<ETK_BASH_COLOR_BLUE << (char*)"+" << ETK_BASH_COLOR_NORMAL; break;
|
||||||
case regexpOpcodePipe: etk::cout<<ETK_BASH_COLOR_BLUE << (char*)"|" << ETK_BASH_COLOR_NORMAL; break;
|
case regexpOpcodePipe: _os<<ETK_BASH_COLOR_BLUE << (char*)"|" << ETK_BASH_COLOR_NORMAL; break;
|
||||||
case regexpOpcodeNoChar: etk::cout<<ETK_BASH_COLOR_MAGENTA << (char*)"@" << ETK_BASH_COLOR_NORMAL; break;
|
case regexpOpcodeNoChar: _os<<ETK_BASH_COLOR_MAGENTA << (char*)"@" << ETK_BASH_COLOR_NORMAL; break;
|
||||||
case regexpOpcodeStartOfLine: etk::cout<<ETK_BASH_COLOR_MAGENTA << (char*)"^" << ETK_BASH_COLOR_NORMAL; break;
|
case regexpOpcodeStartOfLine: _os<<ETK_BASH_COLOR_MAGENTA << (char*)"^" << ETK_BASH_COLOR_NORMAL; break;
|
||||||
case regexpOpcodeEndOfLine: etk::cout<<ETK_BASH_COLOR_MAGENTA << (char*)"$" << ETK_BASH_COLOR_NORMAL; break;
|
case regexpOpcodeEndOfLine: _os<<ETK_BASH_COLOR_MAGENTA << (char*)"$" << ETK_BASH_COLOR_NORMAL; break;
|
||||||
case regexpOpcodeDigit: etk::cout<<ETK_BASH_COLOR_MAGENTA << (char*)"\\d" << ETK_BASH_COLOR_NORMAL; break;
|
case regexpOpcodeDigit: _os<<ETK_BASH_COLOR_MAGENTA << (char*)"\\d" << ETK_BASH_COLOR_NORMAL; break;
|
||||||
case regexpOpcodeDigitNot: etk::cout<<ETK_BASH_COLOR_MAGENTA << (char*)"\\D" << ETK_BASH_COLOR_NORMAL; break;
|
case regexpOpcodeDigitNot: _os<<ETK_BASH_COLOR_MAGENTA << (char*)"\\D" << ETK_BASH_COLOR_NORMAL; break;
|
||||||
case regexpOpcodeLetter: etk::cout<<ETK_BASH_COLOR_MAGENTA << (char*)"\\l" << ETK_BASH_COLOR_NORMAL; break;
|
case regexpOpcodeLetter: _os<<ETK_BASH_COLOR_MAGENTA << (char*)"\\l" << ETK_BASH_COLOR_NORMAL; break;
|
||||||
case regexpOpcodeLetterNot: etk::cout<<ETK_BASH_COLOR_MAGENTA << (char*)"\\L" << ETK_BASH_COLOR_NORMAL; break;
|
case regexpOpcodeLetterNot: _os<<ETK_BASH_COLOR_MAGENTA << (char*)"\\L" << ETK_BASH_COLOR_NORMAL; break;
|
||||||
case regexpOpcodeSpace: etk::cout<<ETK_BASH_COLOR_MAGENTA << (char*)"\\s" << ETK_BASH_COLOR_NORMAL; break;
|
case regexpOpcodeSpace: _os<<ETK_BASH_COLOR_MAGENTA << (char*)"\\s" << ETK_BASH_COLOR_NORMAL; break;
|
||||||
case regexpOpcodeSpaceNot: etk::cout<<ETK_BASH_COLOR_MAGENTA << (char*)"\\S" << ETK_BASH_COLOR_NORMAL; break;
|
case regexpOpcodeSpaceNot: _os<<ETK_BASH_COLOR_MAGENTA << (char*)"\\S" << ETK_BASH_COLOR_NORMAL; break;
|
||||||
case regexpOpcodeWord: etk::cout<<ETK_BASH_COLOR_MAGENTA << (char*)"\\w" << ETK_BASH_COLOR_NORMAL; break;
|
case regexpOpcodeWord: _os<<ETK_BASH_COLOR_MAGENTA << (char*)"\\w" << ETK_BASH_COLOR_NORMAL; break;
|
||||||
case regexpOpcodeWordNot: etk::cout<<ETK_BASH_COLOR_MAGENTA << (char*)"\\W" << ETK_BASH_COLOR_NORMAL; break;
|
case regexpOpcodeWordNot: _os<<ETK_BASH_COLOR_MAGENTA << (char*)"\\W" << ETK_BASH_COLOR_NORMAL; break;
|
||||||
case '\n': etk::cout<<ETK_BASH_COLOR_MAGENTA << (char*)"\\n" << ETK_BASH_COLOR_NORMAL; break;
|
case '\n': _os<<ETK_BASH_COLOR_MAGENTA << (char*)"\\n" << ETK_BASH_COLOR_NORMAL; break;
|
||||||
case '\t': etk::cout<<ETK_BASH_COLOR_MAGENTA << (char*)"\\t" << ETK_BASH_COLOR_NORMAL; break;
|
case '\t': _os<<ETK_BASH_COLOR_MAGENTA << (char*)"\\t" << ETK_BASH_COLOR_NORMAL; break;
|
||||||
default: etk::cout<< _data[iii]; break;
|
default: _os<< _data[iii]; break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return _os;
|
||||||
}
|
}
|
||||||
|
|
||||||
char * etk::levelSpace(uint32_t _level) {
|
char * etk::levelSpace(uint32_t _level) {
|
||||||
|
112
etk/RegExp.h
112
etk/RegExp.h
@ -19,6 +19,36 @@
|
|||||||
#define TK_REG_EXP_DBG_MODE TK_VERBOSE
|
#define TK_REG_EXP_DBG_MODE TK_VERBOSE
|
||||||
//#define TK_REG_EXP_DBG_MODE TK_DEBUG
|
//#define TK_REG_EXP_DBG_MODE TK_DEBUG
|
||||||
|
|
||||||
|
//regular colors
|
||||||
|
#define ETK_BASH_COLOR_BLACK "\e[0;30m"
|
||||||
|
#define ETK_BASH_COLOR_RED "\e[0;31m"
|
||||||
|
#define ETK_BASH_COLOR_GREEN "\e[0;32m"
|
||||||
|
#define ETK_BASH_COLOR_YELLOW "\e[0;33m"
|
||||||
|
#define ETK_BASH_COLOR_BLUE "\e[0;34m"
|
||||||
|
#define ETK_BASH_COLOR_MAGENTA "\e[0;35m"
|
||||||
|
#define ETK_BASH_COLOR_CYAN "\e[0;36m"
|
||||||
|
#define ETK_BASH_COLOR_WHITE "\e[0;37m"
|
||||||
|
//emphasized (bolded) colors
|
||||||
|
#define ETK_BASH_COLOR_BOLD_BLACK "\e[1;30m"
|
||||||
|
#define ETK_BASH_COLOR_BOLD_RED "\e[1;31m"
|
||||||
|
#define ETK_BASH_COLOR_BOLD_GREEN "\e[1;32m"
|
||||||
|
#define ETK_BASH_COLOR_BOLD_YELLOW "\e[1;33m"
|
||||||
|
#define ETK_BASH_COLOR_BOLD_BLUE "\e[1;34m"
|
||||||
|
#define ETK_BASH_COLOR_BOLD_MAGENTA "\e[1;35m"
|
||||||
|
#define ETK_BASH_COLOR_BOLD_CYAN "\e[1;36m"
|
||||||
|
#define ETK_BASH_COLOR_BOLD_WHITE "\e[1;37m"
|
||||||
|
//background colors
|
||||||
|
#define ETK_BASH_COLOR_BG_BLACK "\e[40m"
|
||||||
|
#define ETK_BASH_COLOR_BG_RED "\e[41m"
|
||||||
|
#define ETK_BASH_COLOR_BG_GREEN "\e[42m"
|
||||||
|
#define ETK_BASH_COLOR_BG_YELLOW "\e[43m"
|
||||||
|
#define ETK_BASH_COLOR_BG_BLUE "\e[44m"
|
||||||
|
#define ETK_BASH_COLOR_BG_MAGENTA "\e[45m"
|
||||||
|
#define ETK_BASH_COLOR_BG_CYAN "\e[46m"
|
||||||
|
#define ETK_BASH_COLOR_BG_WHITE "\e[47m"
|
||||||
|
// Return to the normal color setings
|
||||||
|
#define ETK_BASH_COLOR_NORMAL "\e[0m"
|
||||||
|
|
||||||
|
|
||||||
namespace etk {
|
namespace etk {
|
||||||
//in the unicode section we have : [E000..F8FF] private area ==> we will store element in this area:
|
//in the unicode section we have : [E000..F8FF] private area ==> we will store element in this area:
|
||||||
@ -90,7 +120,7 @@ extern const struct convertionTable constConvertionTable[];
|
|||||||
//! @not-in-doc
|
//! @not-in-doc
|
||||||
extern const int64_t constConvertionTableSize;
|
extern const int64_t constConvertionTableSize;
|
||||||
//! @not-in-doc
|
//! @not-in-doc
|
||||||
void displayElem(const std::vector<char32_t>& _data, int64_t _start=0, int64_t _stop=0x7FFFFFFF);
|
std::ostream& displayElem(std::ostream& _os, const std::vector<char32_t>& _data, int64_t _start=0, int64_t _stop=0x7FFFFFFF);
|
||||||
//! @not-in-doc
|
//! @not-in-doc
|
||||||
char * levelSpace(uint32_t _level);
|
char * levelSpace(uint32_t _level);
|
||||||
//! @not-in-doc
|
//! @not-in-doc
|
||||||
@ -156,7 +186,7 @@ template<class CLASS_TYPE> class RegExpNode {
|
|||||||
* @param[in] level of the node
|
* @param[in] level of the node
|
||||||
*/
|
*/
|
||||||
virtual void display(uint32_t _level) {
|
virtual void display(uint32_t _level) {
|
||||||
TK_INFO("Find NODE : " << levelSpace(_level) << "@???@ {" << getMultMin() << "," << getMultMax() << "} subdata="; displayElem(m_RegExpData););
|
TK_INFO("Find NODE : " << levelSpace(_level) << "@???@ {" << getMultMin() << "," << getMultMax() << "} subdata=" /*<< etk::displayElem(m_RegExpData) */);
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* @brief Set the multiplicity of this Node.
|
* @brief Set the multiplicity of this Node.
|
||||||
@ -205,7 +235,7 @@ template<class CLASS_TYPE> class RegExpNodeValue : public etk::RegExpNode<CLASS_
|
|||||||
|
|
||||||
int32_t generate(const std::vector<char32_t>& _data) {
|
int32_t generate(const std::vector<char32_t>& _data) {
|
||||||
RegExpNode<CLASS_TYPE>::m_RegExpData = _data;
|
RegExpNode<CLASS_TYPE>::m_RegExpData = _data;
|
||||||
TK_REG_EXP_DBG_MODE("Request Parse \"Value\" data="; displayElem(RegExpNode<CLASS_TYPE>::m_RegExpData););
|
TK_REG_EXP_DBG_MODE("Request Parse \"Value\" data=" /*<< etk::displayElem(RegExpNode<CLASS_TYPE>::m_RegExpData)*/ );
|
||||||
m_data.clear();
|
m_data.clear();
|
||||||
for (int32_t i=0; i<RegExpNode<CLASS_TYPE>::m_RegExpData.size(); i++) {
|
for (int32_t i=0; i<RegExpNode<CLASS_TYPE>::m_RegExpData.size(); i++) {
|
||||||
m_data.push_back(RegExpNode<CLASS_TYPE>::m_RegExpData[i]);
|
m_data.push_back(RegExpNode<CLASS_TYPE>::m_RegExpData[i]);
|
||||||
@ -258,9 +288,9 @@ template<class CLASS_TYPE> class RegExpNodeValue : public etk::RegExpNode<CLASS_
|
|||||||
void display(uint32_t _level) {
|
void display(uint32_t _level) {
|
||||||
TK_INFO("Find NODE : " << levelSpace(_level) << "@Value@ {"
|
TK_INFO("Find NODE : " << levelSpace(_level) << "@Value@ {"
|
||||||
<< RegExpNode<CLASS_TYPE>::m_multipleMin << ","
|
<< RegExpNode<CLASS_TYPE>::m_multipleMin << ","
|
||||||
<< RegExpNode<CLASS_TYPE>::m_multipleMax << "} subdata=";
|
<< RegExpNode<CLASS_TYPE>::m_multipleMax << "} subdata="
|
||||||
displayElem(RegExpNode<CLASS_TYPE>::m_RegExpData);
|
/*<< etk::displayElem(RegExpNode<CLASS_TYPE>::m_RegExpData)*/
|
||||||
etk::cout << " data: "; displayElem(m_data); );
|
<< " data: " /*<< etk::displayElem(m_data)*/ );
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
#undef __class__
|
#undef __class__
|
||||||
@ -284,7 +314,7 @@ template<class CLASS_TYPE> class RegExpNodeBracket : public etk::RegExpNode<CLAS
|
|||||||
~RegExpNodeBracket(void) { };
|
~RegExpNodeBracket(void) { };
|
||||||
int32_t generate(const std::vector<char32_t>& _data) {
|
int32_t generate(const std::vector<char32_t>& _data) {
|
||||||
RegExpNode<CLASS_TYPE>::m_RegExpData = _data;
|
RegExpNode<CLASS_TYPE>::m_RegExpData = _data;
|
||||||
TK_REG_EXP_DBG_MODE("Request Parse [...] data="; displayElem(_data););
|
TK_REG_EXP_DBG_MODE("Request Parse [...] data=" /*<< etk::displayElem(RegExpNode<CLASS_TYPE>::m_RegExpData)*/ );
|
||||||
m_data.clear();
|
m_data.clear();
|
||||||
|
|
||||||
char32_t lastElement = 'a';
|
char32_t lastElement = 'a';
|
||||||
@ -322,7 +352,7 @@ template<class CLASS_TYPE> class RegExpNodeBracket : public etk::RegExpNode<CLAS
|
|||||||
TK_ERROR("No data inside type elemTypeValue");
|
TK_ERROR("No data inside type elemTypeValue");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
TK_REG_EXP_DBG_MODE("one of element value List : "; displayElem(m_data););
|
TK_REG_EXP_DBG_MODE("one of element value List : " /*<< etk::displayElem(m_data)*/);
|
||||||
bool tmpFind = true;
|
bool tmpFind = true;
|
||||||
uint32_t jjj=0;
|
uint32_t jjj=0;
|
||||||
for (jjj=0; jjj<RegExpNode<CLASS_TYPE>::m_multipleMax && tmpFind ==true && jjj < _lenMax; jjj++) {
|
for (jjj=0; jjj<RegExpNode<CLASS_TYPE>::m_multipleMax && tmpFind ==true && jjj < _lenMax; jjj++) {
|
||||||
@ -350,8 +380,8 @@ template<class CLASS_TYPE> class RegExpNodeBracket : public etk::RegExpNode<CLAS
|
|||||||
void display(uint32_t _level) {
|
void display(uint32_t _level) {
|
||||||
TK_INFO("Find NODE : " << levelSpace(_level) << "@[...]@ {" << RegExpNode<CLASS_TYPE>::m_multipleMin
|
TK_INFO("Find NODE : " << levelSpace(_level) << "@[...]@ {" << RegExpNode<CLASS_TYPE>::m_multipleMin
|
||||||
<< "," << RegExpNode<CLASS_TYPE>::m_multipleMax
|
<< "," << RegExpNode<CLASS_TYPE>::m_multipleMax
|
||||||
<< "} subdata="; displayElem(RegExpNode<CLASS_TYPE>::m_RegExpData);
|
<< "} subdata=" /*<< etk::displayElem(RegExpNode<CLASS_TYPE>::m_RegExpData)*/
|
||||||
etk::cout << " data: "; displayElem(m_data); );
|
<< " data: " /*<< etk::displayElem(m_data)*/ );
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
#undef __class__
|
#undef __class__
|
||||||
@ -403,7 +433,7 @@ template<class CLASS_TYPE> class RegExpNodeDigit : public etk::RegExpNode<CLASS_
|
|||||||
TK_INFO("Find NODE : " << levelSpace(_level) << "@Digit@ {"
|
TK_INFO("Find NODE : " << levelSpace(_level) << "@Digit@ {"
|
||||||
<< RegExpNode<CLASS_TYPE>::m_multipleMin << ","
|
<< RegExpNode<CLASS_TYPE>::m_multipleMin << ","
|
||||||
<< RegExpNode<CLASS_TYPE>::m_multipleMax <<
|
<< RegExpNode<CLASS_TYPE>::m_multipleMax <<
|
||||||
"} subdata="; displayElem(RegExpNode<CLASS_TYPE>::m_RegExpData););
|
"} subdata=" /*<< etk::displayElem(RegExpNode<CLASS_TYPE>::m_RegExpData)*/);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
#undef __class__
|
#undef __class__
|
||||||
@ -448,7 +478,7 @@ template<class CLASS_TYPE> class RegExpNodeDigitNot : public etk::RegExpNode<CLA
|
|||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
void display(uint32_t _level) {
|
void display(uint32_t _level) {
|
||||||
TK_INFO("Find NODE : " << levelSpace(_level) << "@DigitNot@ {" << RegExpNode<CLASS_TYPE>::m_multipleMin << "," << RegExpNode<CLASS_TYPE>::m_multipleMax << "} subdata="; displayElem(RegExpNode<CLASS_TYPE>::m_RegExpData););
|
TK_INFO("Find NODE : " << levelSpace(_level) << "@DigitNot@ {" << RegExpNode<CLASS_TYPE>::m_multipleMin << "," << RegExpNode<CLASS_TYPE>::m_multipleMax << "} subdata=" /*<< etk::displayElem(RegExpNode<CLASS_TYPE>::m_RegExpData)*/ );
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
#undef __class__
|
#undef __class__
|
||||||
@ -497,8 +527,8 @@ template<class CLASS_TYPE> class RegExpNodeLetter : public etk::RegExpNode<CLASS
|
|||||||
void display(uint32_t _level) {
|
void display(uint32_t _level) {
|
||||||
TK_INFO("Find NODE : " << levelSpace(_level) << "@Letter@ {"
|
TK_INFO("Find NODE : " << levelSpace(_level) << "@Letter@ {"
|
||||||
<< RegExpNode<CLASS_TYPE>::m_multipleMin << ","
|
<< RegExpNode<CLASS_TYPE>::m_multipleMin << ","
|
||||||
<< RegExpNode<CLASS_TYPE>::m_multipleMax << "} subdata=";
|
<< RegExpNode<CLASS_TYPE>::m_multipleMax << "} subdata="
|
||||||
displayElem(RegExpNode<CLASS_TYPE>::m_RegExpData););
|
/*<< etk::displayElem(RegExpNode<CLASS_TYPE>::m_RegExpData) */);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
#undef __class__
|
#undef __class__
|
||||||
@ -547,8 +577,8 @@ template<class CLASS_TYPE> class RegExpNodeLetterNot : public etk::RegExpNode<CL
|
|||||||
void display(uint32_t _level) {
|
void display(uint32_t _level) {
|
||||||
TK_INFO("Find NODE : " << levelSpace(_level) << "@LetterNot@ {"
|
TK_INFO("Find NODE : " << levelSpace(_level) << "@LetterNot@ {"
|
||||||
<< RegExpNode<CLASS_TYPE>::m_multipleMin << ","
|
<< RegExpNode<CLASS_TYPE>::m_multipleMin << ","
|
||||||
<< RegExpNode<CLASS_TYPE>::m_multipleMax << "} subdata=";
|
<< RegExpNode<CLASS_TYPE>::m_multipleMax << "} subdata="
|
||||||
displayElem(RegExpNode<CLASS_TYPE>::m_RegExpData););
|
/*<< etk::displayElem(RegExpNode<CLASS_TYPE>::m_RegExpData)*/ );
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
#undef __class__
|
#undef __class__
|
||||||
@ -599,8 +629,8 @@ template<class CLASS_TYPE> class RegExpNodeWhiteSpace : public etk::RegExpNode<C
|
|||||||
void display(uint32_t _level) {
|
void display(uint32_t _level) {
|
||||||
TK_INFO("Find NODE : " << levelSpace(_level) << "@Space@ {"
|
TK_INFO("Find NODE : " << levelSpace(_level) << "@Space@ {"
|
||||||
<< RegExpNode<CLASS_TYPE>::m_multipleMin << ","
|
<< RegExpNode<CLASS_TYPE>::m_multipleMin << ","
|
||||||
<< RegExpNode<CLASS_TYPE>::m_multipleMax << "} subdata=";
|
<< RegExpNode<CLASS_TYPE>::m_multipleMax << "} subdata="
|
||||||
displayElem(RegExpNode<CLASS_TYPE>::m_RegExpData););
|
/*<< etk::displayElem(RegExpNode<CLASS_TYPE>::m_RegExpData)*/ );
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
#undef __class__
|
#undef __class__
|
||||||
@ -651,8 +681,8 @@ template<class CLASS_TYPE> class RegExpNodeWhiteSpaceNot : public etk::RegExpNod
|
|||||||
void display(uint32_t _level) {
|
void display(uint32_t _level) {
|
||||||
TK_INFO("Find NODE : " << levelSpace(_level) << "@SpaceNot@ {"
|
TK_INFO("Find NODE : " << levelSpace(_level) << "@SpaceNot@ {"
|
||||||
<< RegExpNode<CLASS_TYPE>::m_multipleMin << ","
|
<< RegExpNode<CLASS_TYPE>::m_multipleMin << ","
|
||||||
<< RegExpNode<CLASS_TYPE>::m_multipleMax << "} subdata=";
|
<< RegExpNode<CLASS_TYPE>::m_multipleMax << "} subdata="
|
||||||
displayElem(RegExpNode<CLASS_TYPE>::m_RegExpData););
|
/*<< etk::displayElem(RegExpNode<CLASS_TYPE>::m_RegExpData) */);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
#undef __class__
|
#undef __class__
|
||||||
@ -703,8 +733,8 @@ template<class CLASS_TYPE> class RegExpNodeWordChar : public etk::RegExpNode<CLA
|
|||||||
void display(uint32_t _level) {
|
void display(uint32_t _level) {
|
||||||
TK_INFO("Find NODE : " << levelSpace(_level) << "@Word@ {"
|
TK_INFO("Find NODE : " << levelSpace(_level) << "@Word@ {"
|
||||||
<< RegExpNode<CLASS_TYPE>::m_multipleMin << ","
|
<< RegExpNode<CLASS_TYPE>::m_multipleMin << ","
|
||||||
<< RegExpNode<CLASS_TYPE>::m_multipleMax << "} subdata=";
|
<< RegExpNode<CLASS_TYPE>::m_multipleMax << "} subdata="
|
||||||
displayElem(RegExpNode<CLASS_TYPE>::m_RegExpData););
|
/*<< etk::displayElem(RegExpNode<CLASS_TYPE>::m_RegExpData) */);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
#undef __class__
|
#undef __class__
|
||||||
@ -754,8 +784,8 @@ template<class CLASS_TYPE> class RegExpNodeWordCharNot : public etk::RegExpNode<
|
|||||||
void display(uint32_t _level) {
|
void display(uint32_t _level) {
|
||||||
TK_INFO("Find NODE : " << levelSpace(_level) << "@WordNot@ {"
|
TK_INFO("Find NODE : " << levelSpace(_level) << "@WordNot@ {"
|
||||||
<< RegExpNode<CLASS_TYPE>::m_multipleMin << ","
|
<< RegExpNode<CLASS_TYPE>::m_multipleMin << ","
|
||||||
<< RegExpNode<CLASS_TYPE>::m_multipleMax << "} subdata=";
|
<< RegExpNode<CLASS_TYPE>::m_multipleMax << "} subdata="
|
||||||
displayElem(RegExpNode<CLASS_TYPE>::m_RegExpData););
|
/*<< etk::displayElem(RegExpNode<CLASS_TYPE>::m_RegExpData) */);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
#undef __class__
|
#undef __class__
|
||||||
@ -807,8 +837,8 @@ template<class CLASS_TYPE> class RegExpNodeDot : public etk::RegExpNode<CLASS_TY
|
|||||||
void display(uint32_t _level) {
|
void display(uint32_t _level) {
|
||||||
TK_INFO("Find NODE : " << levelSpace(_level) << "@.@ {"
|
TK_INFO("Find NODE : " << levelSpace(_level) << "@.@ {"
|
||||||
<< RegExpNode<CLASS_TYPE>::m_multipleMin << ","
|
<< RegExpNode<CLASS_TYPE>::m_multipleMin << ","
|
||||||
<< RegExpNode<CLASS_TYPE>::m_multipleMax << "} subdata=";
|
<< RegExpNode<CLASS_TYPE>::m_multipleMax << "} subdata="
|
||||||
displayElem(RegExpNode<CLASS_TYPE>::m_RegExpData););
|
/*<< etk::displayElem(RegExpNode<CLASS_TYPE>::m_RegExpData) */);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -837,8 +867,8 @@ template<class CLASS_TYPE> class RegExpNodeSOL : public etk::RegExpNode<CLASS_TY
|
|||||||
void display(uint32_t _level) {
|
void display(uint32_t _level) {
|
||||||
TK_INFO("Find NODE : " << levelSpace(_level) << "@SOL@ {"
|
TK_INFO("Find NODE : " << levelSpace(_level) << "@SOL@ {"
|
||||||
<< RegExpNode<CLASS_TYPE>::m_multipleMin << ","
|
<< RegExpNode<CLASS_TYPE>::m_multipleMin << ","
|
||||||
<< RegExpNode<CLASS_TYPE>::m_multipleMax << "} subdata=";
|
<< RegExpNode<CLASS_TYPE>::m_multipleMax << "} subdata="
|
||||||
displayElem(RegExpNode<CLASS_TYPE>::m_RegExpData););
|
/*<< etk::displayElem(RegExpNode<CLASS_TYPE>::m_RegExpData) */);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -867,8 +897,8 @@ template<class CLASS_TYPE> class RegExpNodeEOL : public etk::RegExpNode<CLASS_TY
|
|||||||
void display(uint32_t _level) {
|
void display(uint32_t _level) {
|
||||||
TK_INFO("Find NODE : " << levelSpace(_level) << "@EOL@ {"
|
TK_INFO("Find NODE : " << levelSpace(_level) << "@EOL@ {"
|
||||||
<< RegExpNode<CLASS_TYPE>::m_multipleMin << ","
|
<< RegExpNode<CLASS_TYPE>::m_multipleMin << ","
|
||||||
<< RegExpNode<CLASS_TYPE>::m_multipleMax << "} subdata=";
|
<< RegExpNode<CLASS_TYPE>::m_multipleMax << "} subdata="
|
||||||
displayElem(RegExpNode<CLASS_TYPE>::m_RegExpData););
|
/*<< etk::displayElem(RegExpNode<CLASS_TYPE>::m_RegExpData) */);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -901,7 +931,7 @@ template<class CLASS_TYPE> class RegExpNodePTheseElem : public etk::RegExpNode<C
|
|||||||
~RegExpNodePTheseElem(void) { };
|
~RegExpNodePTheseElem(void) { };
|
||||||
int32_t generate(const std::vector<char32_t>& _data) {
|
int32_t generate(const std::vector<char32_t>& _data) {
|
||||||
RegExpNode<CLASS_TYPE>::m_RegExpData = _data;
|
RegExpNode<CLASS_TYPE>::m_RegExpData = _data;
|
||||||
TK_REG_EXP_DBG_MODE("Request Parse (elem) data="; displayElem(RegExpNode<CLASS_TYPE>::m_RegExpData););
|
TK_REG_EXP_DBG_MODE("Request Parse (elem) data=" /*<< etk::displayElem(RegExpNode<CLASS_TYPE>::m_RegExpData)*/ );
|
||||||
int64_t pos = 0;
|
int64_t pos = 0;
|
||||||
int64_t elementSize = 0;
|
int64_t elementSize = 0;
|
||||||
std::vector<char32_t> tmpData;
|
std::vector<char32_t> tmpData;
|
||||||
@ -1054,8 +1084,8 @@ template<class CLASS_TYPE> class RegExpNodePTheseElem : public etk::RegExpNode<C
|
|||||||
void display(uint32_t _level) {
|
void display(uint32_t _level) {
|
||||||
TK_INFO("Find NODE : " << levelSpace(_level) << "@(Elem)@ {"
|
TK_INFO("Find NODE : " << levelSpace(_level) << "@(Elem)@ {"
|
||||||
<< RegExpNode<CLASS_TYPE>::m_multipleMin << ","
|
<< RegExpNode<CLASS_TYPE>::m_multipleMin << ","
|
||||||
<< RegExpNode<CLASS_TYPE>::m_multipleMax << "} subdata=";
|
<< RegExpNode<CLASS_TYPE>::m_multipleMax << "} subdata="
|
||||||
displayElem(RegExpNode<CLASS_TYPE>::m_RegExpData););
|
/*<< etk::displayElem(RegExpNode<CLASS_TYPE>::m_RegExpData) */);
|
||||||
for(int64_t iii=0; iii<m_subNode.size(); iii++) {
|
for(int64_t iii=0; iii<m_subNode.size(); iii++) {
|
||||||
m_subNode[iii]->display(_level+1);
|
m_subNode[iii]->display(_level+1);
|
||||||
}
|
}
|
||||||
@ -1102,7 +1132,7 @@ template<class CLASS_TYPE> class RegExpNodePThese : public etk::RegExpNode<CLASS
|
|||||||
~RegExpNodePThese(void) { }
|
~RegExpNodePThese(void) { }
|
||||||
int32_t generate(const std::vector<char32_t>& _data) {
|
int32_t generate(const std::vector<char32_t>& _data) {
|
||||||
RegExpNode<CLASS_TYPE>::m_RegExpData = _data;
|
RegExpNode<CLASS_TYPE>::m_RegExpData = _data;
|
||||||
TK_REG_EXP_DBG_MODE("Request Parse (...) data="; displayElem(RegExpNode<CLASS_TYPE>::m_RegExpData););
|
TK_REG_EXP_DBG_MODE("Request Parse (...) data=" /*<< etk::displayElem(RegExpNode<CLASS_TYPE>::m_RegExpData)*/ );
|
||||||
//Find all the '|' in the string (and at the good level ...)
|
//Find all the '|' in the string (and at the good level ...)
|
||||||
int64_t pos = 0;
|
int64_t pos = 0;
|
||||||
int32_t elementSize = getLenOfPTheseElem(RegExpNode<CLASS_TYPE>::m_RegExpData, pos);
|
int32_t elementSize = getLenOfPTheseElem(RegExpNode<CLASS_TYPE>::m_RegExpData, pos);
|
||||||
@ -1118,7 +1148,7 @@ template<class CLASS_TYPE> class RegExpNodePThese : public etk::RegExpNode<CLASS
|
|||||||
// add to the subnode list :
|
// add to the subnode list :
|
||||||
m_subNode.push_back(myElem);
|
m_subNode.push_back(myElem);
|
||||||
pos += elementSize+1;
|
pos += elementSize+1;
|
||||||
TK_REG_EXP_DBG_MODE("plop="; displayElem(_data, pos, pos+1););
|
TK_REG_EXP_DBG_MODE("plop=" /*<< etk::displayElem(RegExpNode<CLASS_TYPE>::m_RegExpData, pos, pos+1)*/ );
|
||||||
elementSize = getLenOfPTheseElem(RegExpNode<CLASS_TYPE>::m_RegExpData, pos);
|
elementSize = getLenOfPTheseElem(RegExpNode<CLASS_TYPE>::m_RegExpData, pos);
|
||||||
TK_REG_EXP_DBG_MODE("find " << elementSize << " elements");
|
TK_REG_EXP_DBG_MODE("find " << elementSize << " elements");
|
||||||
}
|
}
|
||||||
@ -1162,12 +1192,12 @@ template<class CLASS_TYPE> class RegExpNodePThese : public etk::RegExpNode<CLASS
|
|||||||
|
|
||||||
void display(uint32_t _level) {
|
void display(uint32_t _level) {
|
||||||
if (-1 == _level) {
|
if (-1 == _level) {
|
||||||
TK_INFO("regExp :"; displayElem(RegExpNode<CLASS_TYPE>::m_RegExpData););
|
TK_INFO("regExp :" /*<< etk::displayElem(RegExpNode<CLASS_TYPE>::m_RegExpData) */);
|
||||||
} else {
|
} else {
|
||||||
TK_INFO("Find NODE : " << levelSpace(_level) << "@(...)@ {"
|
TK_INFO("Find NODE : " << levelSpace(_level) << "@(...)@ {"
|
||||||
<< RegExpNode<CLASS_TYPE>::m_multipleMin << ","
|
<< RegExpNode<CLASS_TYPE>::m_multipleMin << ","
|
||||||
<< RegExpNode<CLASS_TYPE>::m_multipleMax << "} subdata=";
|
<< RegExpNode<CLASS_TYPE>::m_multipleMax << "} subdata="
|
||||||
displayElem(RegExpNode<CLASS_TYPE>::m_RegExpData););
|
/*<< etk::displayElem(RegExpNode<CLASS_TYPE>::m_RegExpData) */);
|
||||||
for(int32_t i=0; i<m_subNode.size(); i++) {
|
for(int32_t i=0; i<m_subNode.size(); i++) {
|
||||||
m_subNode[i]->display(_level+1);
|
m_subNode[i]->display(_level+1);
|
||||||
}
|
}
|
||||||
@ -1177,7 +1207,7 @@ template<class CLASS_TYPE> class RegExpNodePThese : public etk::RegExpNode<CLASS
|
|||||||
* @brief Just display the regExp in color ...
|
* @brief Just display the regExp in color ...
|
||||||
*/
|
*/
|
||||||
void drawColoredRegEx(void) {
|
void drawColoredRegEx(void) {
|
||||||
TK_INFO("regExp :"; displayElem(RegExpNode<CLASS_TYPE>::m_RegExpData););
|
TK_INFO("regExp :" /*<< etk::displayElem(RegExpNode<CLASS_TYPE>::m_RegExpData)*/ );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
#undef __class__
|
#undef __class__
|
||||||
@ -1283,7 +1313,7 @@ template<class CLASS_TYPE> class RegExp {
|
|||||||
std::vector<char32_t> tmpExp;
|
std::vector<char32_t> tmpExp;
|
||||||
|
|
||||||
TK_REG_EXP_DBG_MODE("---------------------------------------------------------------------");
|
TK_REG_EXP_DBG_MODE("---------------------------------------------------------------------");
|
||||||
TK_REG_EXP_DBG_MODE("Parse RegExp : (" << _regexp << ")" );
|
TK_REG_EXP_DBG_MODE("Parse RegExp : (" << m_expressionRequested << ")" );
|
||||||
m_isOk = false;
|
m_isOk = false;
|
||||||
m_areaFind.start=0;
|
m_areaFind.start=0;
|
||||||
m_areaFind.stop=0;
|
m_areaFind.stop=0;
|
||||||
@ -1382,7 +1412,7 @@ template<class CLASS_TYPE> class RegExp {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
TK_REG_EXP_DBG_MODE("Main element :"; displayElem(tmpExp); );
|
//TK_REG_EXP_DBG_MODE("Main element :" /*<< etk::displayElem(tmpExp)*/ );
|
||||||
if ( tmpExp.size()>0
|
if ( tmpExp.size()>0
|
||||||
&& tmpExp[0] == regexpOpcodeNoChar)
|
&& tmpExp[0] == regexpOpcodeNoChar)
|
||||||
{
|
{
|
||||||
|
309
etk/Stream.cpp
309
etk/Stream.cpp
@ -1,309 +0,0 @@
|
|||||||
/**
|
|
||||||
* @author Edouard DUPIN
|
|
||||||
*
|
|
||||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
|
||||||
*
|
|
||||||
* @license BSD v3 (see license file)
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <etk/types.h>
|
|
||||||
#include <etk/Stream.h>
|
|
||||||
#include <etk/StreamIOs.h>
|
|
||||||
#include <etk/debug.h>
|
|
||||||
|
|
||||||
#if defined(__TARGET_OS__Linux) && DEBUG_LEVEL > 2
|
|
||||||
#include <execinfo.h>
|
|
||||||
#include <cxxabi.h>
|
|
||||||
#include <dlfcn.h>
|
|
||||||
#define MAX_DEPTH (256)
|
|
||||||
void etk::displayBacktrace(bool _breakAtEnd) {
|
|
||||||
// retrieve call-stack
|
|
||||||
void * trace[MAX_DEPTH];
|
|
||||||
int stack_depth = backtrace(trace, MAX_DEPTH);
|
|
||||||
|
|
||||||
TK_ERROR("Back-trace : ");
|
|
||||||
for (int32_t i = 1; i < stack_depth; i++) {
|
|
||||||
Dl_info dlinfo;
|
|
||||||
if(!dladdr(trace[i], &dlinfo)) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
const char * symname = dlinfo.dli_sname;
|
|
||||||
int status;
|
|
||||||
char * demangled = abi::__cxa_demangle(symname, NULL, 0, &status);
|
|
||||||
if(status == 0 && demangled) {
|
|
||||||
symname = demangled;
|
|
||||||
}
|
|
||||||
TK_WARNING(" " << dlinfo.dli_fname << ": ");
|
|
||||||
TK_ERROR(" " << symname);
|
|
||||||
if(NULL != demangled) {
|
|
||||||
free(demangled);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (_breakAtEnd == true) {
|
|
||||||
assert(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
void etk::displayBacktrace(bool _breakAtEnd) {
|
|
||||||
#if DEBUG_LEVEL > 2
|
|
||||||
assert(false);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
etk::CCout etk::cout;
|
|
||||||
etk::CEndl etk::endl;
|
|
||||||
etk::CStart etk::cstart;
|
|
||||||
|
|
||||||
|
|
||||||
#if defined(__TARGET_OS__Android)
|
|
||||||
# include <android/log.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
etk::CCout& etk::operator <<(etk::CCout &_os, const enum etk::logLevel _obj) {
|
|
||||||
switch (_obj) {
|
|
||||||
case logLevelCritical:
|
|
||||||
if (_os.m_enableColor == true) {
|
|
||||||
_os << ETK_BASH_COLOR_BOLD_RED;
|
|
||||||
}
|
|
||||||
#if defined(__TARGET_OS__Android)
|
|
||||||
_os.m_levelAndroid = ANDROID_LOG_FATAL;
|
|
||||||
#else
|
|
||||||
_os << "[C]";
|
|
||||||
#endif
|
|
||||||
break;
|
|
||||||
case logLevelError:
|
|
||||||
if (_os.m_enableColor == true) {
|
|
||||||
_os << ETK_BASH_COLOR_RED;
|
|
||||||
}
|
|
||||||
#if defined(__TARGET_OS__Android)
|
|
||||||
_os.m_levelAndroid = ANDROID_LOG_ERROR;
|
|
||||||
#else
|
|
||||||
_os << "[E]";
|
|
||||||
#endif
|
|
||||||
break;
|
|
||||||
case logLevelWarning:
|
|
||||||
if (_os.m_enableColor == true) {
|
|
||||||
_os << ETK_BASH_COLOR_MAGENTA;
|
|
||||||
}
|
|
||||||
#if defined(__TARGET_OS__Android)
|
|
||||||
_os.m_levelAndroid = ANDROID_LOG_WARN;
|
|
||||||
#else
|
|
||||||
_os << "[W]";
|
|
||||||
#endif
|
|
||||||
break;
|
|
||||||
case logLevelInfo:
|
|
||||||
if (_os.m_enableColor == true) {
|
|
||||||
_os << ETK_BASH_COLOR_CYAN;
|
|
||||||
}
|
|
||||||
#if defined(__TARGET_OS__Android)
|
|
||||||
_os.m_levelAndroid = ANDROID_LOG_INFO;
|
|
||||||
#else
|
|
||||||
_os << "[I]";
|
|
||||||
#endif
|
|
||||||
break;
|
|
||||||
case logLevelDebug:
|
|
||||||
if (_os.m_enableColor == true) {
|
|
||||||
_os << ETK_BASH_COLOR_YELLOW;
|
|
||||||
}
|
|
||||||
#if defined(__TARGET_OS__Android)
|
|
||||||
_os.m_levelAndroid = ANDROID_LOG_DEBUG;
|
|
||||||
#else
|
|
||||||
_os << "[D]";
|
|
||||||
#endif
|
|
||||||
break;
|
|
||||||
case logLevelVerbose:
|
|
||||||
if (_os.m_enableColor == true) {
|
|
||||||
_os << ETK_BASH_COLOR_WHITE;
|
|
||||||
}
|
|
||||||
#if defined(__TARGET_OS__Android)
|
|
||||||
_os.m_levelAndroid = ANDROID_LOG_VERBOSE;
|
|
||||||
#else
|
|
||||||
_os << "[V]";
|
|
||||||
#endif
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
#if !defined(__TARGET_OS__Android)
|
|
||||||
_os << "[?]";
|
|
||||||
#endif
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return _os;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void etk::CCout::setColor(bool _enable) {
|
|
||||||
m_enableColor = _enable;
|
|
||||||
}
|
|
||||||
|
|
||||||
void etk::CCout::setOutputFile(bool _enable) {
|
|
||||||
if (m_outputFile != NULL) {
|
|
||||||
fclose(m_outputFile);
|
|
||||||
m_outputFile = NULL;
|
|
||||||
}
|
|
||||||
m_outputFile = fopen("/Users/edouarddupin/dev/perso/output.log", "w");
|
|
||||||
if (m_outputFile == NULL) {
|
|
||||||
TK_ERROR("Can not open log file ...");
|
|
||||||
} else {
|
|
||||||
TK_INFO("Log file opened");
|
|
||||||
}
|
|
||||||
TK_INFO("plop");
|
|
||||||
}
|
|
||||||
|
|
||||||
etk::CCout::CCout(void) :
|
|
||||||
m_enableColor(true),
|
|
||||||
m_outputFile(NULL) {
|
|
||||||
#if (defined(__TARGET_OS__Windows))
|
|
||||||
m_enableColor = false;
|
|
||||||
#endif
|
|
||||||
#if defined(__TARGET_OS__Android)
|
|
||||||
m_levelAndroid = 0;
|
|
||||||
#endif
|
|
||||||
memset(m_tmpChar, 0, (MAX_LOG_SIZE+1)*sizeof(char));
|
|
||||||
};
|
|
||||||
|
|
||||||
etk::CCout& etk::CCout::operator << (char32_t _t) {
|
|
||||||
char output[5];
|
|
||||||
u32char::convertUtf8(_t, output);
|
|
||||||
snprintf(tmp, MAX_LOG_SIZE_TMP, "%s", output);
|
|
||||||
strncat(m_tmpChar, tmp, MAX_LOG_SIZE);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if ( defined(__TARGET_OS__MacOs) \
|
|
||||||
|| defined(__TARGET_OS__IOs))
|
|
||||||
etk::CCout& etk::CCout::operator << (size_t _t) {
|
|
||||||
snprintf(tmp, MAX_LOG_SIZE_TMP, "%lld", (uint64_t)_t);
|
|
||||||
strncat(m_tmpChar, tmp, MAX_LOG_SIZE);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
etk::CCout& etk::CCout::operator << (int8_t _t) {
|
|
||||||
snprintf(tmp, MAX_LOG_SIZE_TMP, "%d", _t);
|
|
||||||
strncat(m_tmpChar, tmp, MAX_LOG_SIZE);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
etk::CCout& etk::CCout::operator << (int16_t _t) {
|
|
||||||
snprintf(tmp, MAX_LOG_SIZE_TMP, "%d", _t);
|
|
||||||
strncat(m_tmpChar, tmp, MAX_LOG_SIZE);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
etk::CCout& etk::CCout::operator << (int32_t _t) {
|
|
||||||
snprintf(tmp, MAX_LOG_SIZE_TMP, "%d", _t);
|
|
||||||
strncat(m_tmpChar, tmp, MAX_LOG_SIZE);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
etk::CCout& etk::CCout::operator << (int64_t _t) {
|
|
||||||
#if __WORDSIZE == 64
|
|
||||||
snprintf(tmp, MAX_LOG_SIZE_TMP, "%ld", _t);
|
|
||||||
#else
|
|
||||||
snprintf(tmp, MAX_LOG_SIZE_TMP, "%lld", _t);
|
|
||||||
#endif
|
|
||||||
strncat(m_tmpChar, tmp, MAX_LOG_SIZE);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
etk::CCout& etk::CCout::operator << (uint8_t _t) {
|
|
||||||
snprintf(tmp, MAX_LOG_SIZE_TMP, "%u", _t);
|
|
||||||
strncat(m_tmpChar, tmp, MAX_LOG_SIZE);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
etk::CCout& etk::CCout::operator << (uint16_t _t) {
|
|
||||||
snprintf(tmp, MAX_LOG_SIZE_TMP, "%u", _t);
|
|
||||||
strncat(m_tmpChar, tmp, MAX_LOG_SIZE);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
etk::CCout& etk::CCout::operator << (uint32_t _t) {
|
|
||||||
snprintf(tmp, MAX_LOG_SIZE_TMP, "%u", _t);
|
|
||||||
strncat(m_tmpChar, tmp, MAX_LOG_SIZE);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
etk::CCout& etk::CCout::operator << (uint64_t _t) {
|
|
||||||
#if __WORDSIZE == 64
|
|
||||||
snprintf(tmp, MAX_LOG_SIZE_TMP, "%lu", _t);
|
|
||||||
#else
|
|
||||||
snprintf(tmp, MAX_LOG_SIZE_TMP, "%llu", _t);
|
|
||||||
#endif
|
|
||||||
strncat(m_tmpChar, tmp, MAX_LOG_SIZE);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
etk::CCout& etk::CCout::operator << (double _t) {
|
|
||||||
snprintf(tmp, MAX_LOG_SIZE_TMP, "%f", _t);
|
|
||||||
strncat(m_tmpChar, tmp, MAX_LOG_SIZE);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
etk::CCout& etk::CCout::operator << (float _t) {
|
|
||||||
snprintf(tmp, MAX_LOG_SIZE_TMP, "%f", _t);
|
|
||||||
strncat(m_tmpChar, tmp, MAX_LOG_SIZE);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
etk::CCout& etk::CCout::operator << (char * _t) {
|
|
||||||
snprintf(tmp, MAX_LOG_SIZE_TMP, "%s", _t);
|
|
||||||
strncat(m_tmpChar, tmp, MAX_LOG_SIZE);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
etk::CCout& etk::CCout::operator << (const char * _t) {
|
|
||||||
snprintf(tmp, MAX_LOG_SIZE_TMP, "%s", _t);
|
|
||||||
strncat(m_tmpChar, tmp, MAX_LOG_SIZE);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
etk::CCout& etk::CCout::operator << (char _t) {
|
|
||||||
snprintf(tmp, MAX_LOG_SIZE_TMP, "%c", _t);
|
|
||||||
strncat(m_tmpChar, tmp, MAX_LOG_SIZE);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
etk::CCout& etk::CCout::operator << (bool _t) {
|
|
||||||
if (_t) {
|
|
||||||
strncat(m_tmpChar, "true", MAX_LOG_SIZE);
|
|
||||||
} else {
|
|
||||||
strncat(m_tmpChar, "false", MAX_LOG_SIZE);
|
|
||||||
}
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
etk::CCout& etk::CCout::operator << (CStart _ccc) {
|
|
||||||
m_mutex.lock();
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
etk::CCout& etk::CCout::operator << (etk::CEndl _t) {
|
|
||||||
#if (!defined(__TARGET_OS__Windows) && !defined(__TARGET_OS__IOs))
|
|
||||||
if (m_enableColor == true) {
|
|
||||||
strncat(m_tmpChar, ETK_BASH_COLOR_NORMAL, MAX_LOG_SIZE);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
strncat(m_tmpChar, "\n", MAX_LOG_SIZE);
|
|
||||||
m_tmpChar[MAX_LOG_SIZE] = '\0';
|
|
||||||
#if defined(__TARGET_OS__Android)
|
|
||||||
__android_log_print(m_levelAndroid, "EWOL", "%s", m_tmpChar);
|
|
||||||
#elif defined(__TARGET_OS__IOs)
|
|
||||||
iosNSLog(m_tmpChar);
|
|
||||||
#else
|
|
||||||
printf("%s", m_tmpChar);
|
|
||||||
#endif
|
|
||||||
if (m_outputFile != NULL) {
|
|
||||||
fprintf(m_outputFile, "%s", m_tmpChar);
|
|
||||||
fflush(m_outputFile);
|
|
||||||
}
|
|
||||||
memset(m_tmpChar, 0, (MAX_LOG_SIZE+1)*sizeof(char));
|
|
||||||
m_mutex.unLock();
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
123
etk/Stream.h
123
etk/Stream.h
@ -1,123 +0,0 @@
|
|||||||
/**
|
|
||||||
* @author Edouard DUPIN
|
|
||||||
*
|
|
||||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
|
||||||
*
|
|
||||||
* @license BSD v3 (see license file)
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __ETK_STREAM_H__
|
|
||||||
#define __ETK_STREAM_H__
|
|
||||||
|
|
||||||
#include <etk/types.h>
|
|
||||||
#include <etk/os/Mutex.h>
|
|
||||||
|
|
||||||
namespace etk {
|
|
||||||
#define MAX_LOG_SIZE (16000)
|
|
||||||
#define MAX_LOG_SIZE_TMP (512)
|
|
||||||
//! @not-in-doc
|
|
||||||
class CEndl {};
|
|
||||||
//! @not-in-doc
|
|
||||||
class CStart {};
|
|
||||||
/**
|
|
||||||
* @brief Generic log output system. it change automaticly from generic console to Android console.
|
|
||||||
*/
|
|
||||||
class CCout {
|
|
||||||
public:
|
|
||||||
bool m_enableColor;
|
|
||||||
private:
|
|
||||||
FILE* m_outputFile;
|
|
||||||
char m_tmpChar[MAX_LOG_SIZE+1];
|
|
||||||
char tmp[MAX_LOG_SIZE_TMP];
|
|
||||||
etk::Mutex m_mutex;
|
|
||||||
#if defined(__TARGET_OS__Android)
|
|
||||||
public:
|
|
||||||
int8_t m_levelAndroid; //!< specific level for Android
|
|
||||||
#endif
|
|
||||||
public:
|
|
||||||
CCout(void);
|
|
||||||
CCout& operator << (char32_t _t);
|
|
||||||
#if (defined(__TARGET_OS__MacOs) || defined(__TARGET_OS__IOs))
|
|
||||||
CCout& operator << (size_t _t);
|
|
||||||
#endif
|
|
||||||
CCout& operator << (int8_t _t);
|
|
||||||
CCout& operator << (int16_t _t);
|
|
||||||
CCout& operator << (int32_t _t);
|
|
||||||
CCout& operator << (int64_t _t);
|
|
||||||
CCout& operator << (uint8_t _t);
|
|
||||||
CCout& operator << (uint16_t _t);
|
|
||||||
CCout& operator << (uint32_t _t);
|
|
||||||
CCout& operator << (uint64_t _t);
|
|
||||||
CCout& operator << (double _t);
|
|
||||||
CCout& operator << (float _t);
|
|
||||||
CCout& operator << (char * _t);
|
|
||||||
CCout& operator << (const char * _t);
|
|
||||||
CCout& operator << (char _t);
|
|
||||||
CCout& operator << (bool _t);
|
|
||||||
CCout& operator << (CStart _ccc);
|
|
||||||
CCout& operator << (etk::CEndl _t);
|
|
||||||
void setColor(bool _enable);
|
|
||||||
void setOutputFile(bool _enable);
|
|
||||||
};
|
|
||||||
extern etk::CCout cout;
|
|
||||||
extern etk::CEndl endl;
|
|
||||||
extern etk::CStart cstart;
|
|
||||||
/**
|
|
||||||
* @brief Log level is a simple list of all log availlable. This enum is used when setting a log and when user chose the level of log displayed.
|
|
||||||
*/
|
|
||||||
enum logLevel {
|
|
||||||
logLevelNone, //!< no display requested
|
|
||||||
logLevelCritical, //!< Display only critical logs (note that critical generally assert with a backtrace (when we can))
|
|
||||||
logLevelError, //!< Display Error and critical logs
|
|
||||||
logLevelWarning, //!< Display log critical to warning
|
|
||||||
logLevelInfo, //!< Display log critical to information (removed in release mode)
|
|
||||||
logLevelDebug, //!< Display log critical to debug (removed in release mode)
|
|
||||||
logLevelVerbose //!< Display all logs (removed in release and debug mode)
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Debug operator To display the curent element in a Human redeable information
|
|
||||||
*/
|
|
||||||
etk::CCout& operator <<(etk::CCout &_os, const enum etk::logLevel _obj);
|
|
||||||
/**
|
|
||||||
* @brief Display the current backtrace (only implemented in linux debug mode)
|
|
||||||
* @param[in] _breakAtEnd Request an assert after displaying the backtrace.
|
|
||||||
*/
|
|
||||||
void displayBacktrace(bool _breakAtEnd=true);
|
|
||||||
};
|
|
||||||
|
|
||||||
//regular colors
|
|
||||||
#define ETK_BASH_COLOR_BLACK "\e[0;30m"
|
|
||||||
#define ETK_BASH_COLOR_RED "\e[0;31m"
|
|
||||||
#define ETK_BASH_COLOR_GREEN "\e[0;32m"
|
|
||||||
#define ETK_BASH_COLOR_YELLOW "\e[0;33m"
|
|
||||||
#define ETK_BASH_COLOR_BLUE "\e[0;34m"
|
|
||||||
#define ETK_BASH_COLOR_MAGENTA "\e[0;35m"
|
|
||||||
#define ETK_BASH_COLOR_CYAN "\e[0;36m"
|
|
||||||
#define ETK_BASH_COLOR_WHITE "\e[0;37m"
|
|
||||||
//emphasized (bolded) colors
|
|
||||||
#define ETK_BASH_COLOR_BOLD_BLACK "\e[1;30m"
|
|
||||||
#define ETK_BASH_COLOR_BOLD_RED "\e[1;31m"
|
|
||||||
#define ETK_BASH_COLOR_BOLD_GREEN "\e[1;32m"
|
|
||||||
#define ETK_BASH_COLOR_BOLD_YELLOW "\e[1;33m"
|
|
||||||
#define ETK_BASH_COLOR_BOLD_BLUE "\e[1;34m"
|
|
||||||
#define ETK_BASH_COLOR_BOLD_MAGENTA "\e[1;35m"
|
|
||||||
#define ETK_BASH_COLOR_BOLD_CYAN "\e[1;36m"
|
|
||||||
#define ETK_BASH_COLOR_BOLD_WHITE "\e[1;37m"
|
|
||||||
//background colors
|
|
||||||
#define ETK_BASH_COLOR_BG_BLACK "\e[40m"
|
|
||||||
#define ETK_BASH_COLOR_BG_RED "\e[41m"
|
|
||||||
#define ETK_BASH_COLOR_BG_GREEN "\e[42m"
|
|
||||||
#define ETK_BASH_COLOR_BG_YELLOW "\e[43m"
|
|
||||||
#define ETK_BASH_COLOR_BG_BLUE "\e[44m"
|
|
||||||
#define ETK_BASH_COLOR_BG_MAGENTA "\e[45m"
|
|
||||||
#define ETK_BASH_COLOR_BG_CYAN "\e[46m"
|
|
||||||
#define ETK_BASH_COLOR_BG_WHITE "\e[47m"
|
|
||||||
// Return to the normal color setings
|
|
||||||
#define ETK_BASH_COLOR_NORMAL "\e[0m"
|
|
||||||
//go to the Top of bash
|
|
||||||
#define ETK_BASH_GO_TOP "\e[0;0f"
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -6,6 +6,10 @@
|
|||||||
* @license BSD v3 (see license file)
|
* @license BSD v3 (see license file)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <etk/types.h>
|
#include <etk/debug.h>
|
||||||
|
|
||||||
|
int32_t etk::getLogId(void) {
|
||||||
|
static int32_t g_val = etk::log::registerInstance("etk");
|
||||||
|
return g_val;
|
||||||
|
}
|
||||||
|
|
||||||
const char * etkLibName = "etk ";
|
|
||||||
|
47
etk/debug.h
47
etk/debug.h
@ -11,19 +11,44 @@
|
|||||||
#ifndef __ETK_DEBUG_H__
|
#ifndef __ETK_DEBUG_H__
|
||||||
#define __ETK_DEBUG_H__
|
#define __ETK_DEBUG_H__
|
||||||
|
|
||||||
#include <etk/debugGeneric.h>
|
#include <etk/log.h>
|
||||||
|
|
||||||
extern const char * etkLibName;
|
namespace etk {
|
||||||
|
int32_t getLogId(void);
|
||||||
|
};
|
||||||
|
// TODO : Review this problem of multiple intanciation of "std::stringbuf sb"
|
||||||
|
#define ETK_BASE(info,data) \
|
||||||
|
do { \
|
||||||
|
if (info <= etk::log::getLevel(etk::getLogId())) { \
|
||||||
|
std::stringbuf sb; \
|
||||||
|
std::ostream tmpStream(&sb); \
|
||||||
|
tmpStream << data; \
|
||||||
|
etk::log::logStream(etk::getLogId(), info, __LINE__, __class__, __func__, tmpStream); \
|
||||||
|
} \
|
||||||
|
} while(0)
|
||||||
|
|
||||||
#define TK_CRITICAL(data) ETK_CRITICAL(etkLibName, data)
|
#define TK_CRITICAL(data) ETK_BASE(1, data)
|
||||||
#define TK_WARNING(data) ETK_WARNING(etkLibName, data)
|
#define TK_ERROR(data) ETK_BASE(2, data)
|
||||||
#define TK_ERROR(data) ETK_ERROR(etkLibName, data)
|
#define TK_WARNING(data) ETK_BASE(3, data)
|
||||||
#define TK_INFO(data) ETK_INFO(etkLibName, data)
|
#ifdef DEBUG
|
||||||
#define TK_DEBUG(data) ETK_DEBUG(etkLibName, data)
|
#define TK_INFO(data) ETK_BASE(4, data)
|
||||||
#define TK_VERBOSE(data) ETK_VERBOSE(etkLibName, data)
|
#define TK_DEBUG(data) ETK_BASE(5, data)
|
||||||
#define TK_ASSERT(cond, data) ETK_ASSERT(etkLibName, cond, data)
|
#define TK_VERBOSE(data) ETK_BASE(6, data)
|
||||||
#define TK_CHECK_INOUT(cond) ETK_CHECK_INOUT(etkLibName, cond)
|
#define TK_TODO(data) ETK_BASE(4, "TODO : " << data)
|
||||||
#define TK_TODO(cond) ETK_TODO(etkLibName, cond)
|
#else
|
||||||
|
#define TK_INFO(data) do { } while(false)
|
||||||
|
#define TK_DEBUG(data) do { } while(false)
|
||||||
|
#define TK_VERBOSE(data) do { } while(false)
|
||||||
|
#define TK_TODO(data) do { } while(false)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define TK_ASSERT(cond,data) \
|
||||||
|
do { \
|
||||||
|
if (!(cond)) { \
|
||||||
|
TK_CRITICAL(data); \
|
||||||
|
assert(!#cond); \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1,66 +0,0 @@
|
|||||||
/**
|
|
||||||
* @author Edouard DUPIN
|
|
||||||
*
|
|
||||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
|
||||||
*
|
|
||||||
* @license BSD v3 (see license file)
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <etk/types.h>
|
|
||||||
#include <etk/debugGeneric.h>
|
|
||||||
#include <time.h>
|
|
||||||
|
|
||||||
// Max string size : (wide screan console nb caractere)
|
|
||||||
#define EDN_LOG_MAX_LENGTH 250
|
|
||||||
|
|
||||||
|
|
||||||
#define FUNCTION_NAME_SIZE (70)
|
|
||||||
|
|
||||||
void debug::displayFuncName(int32_t _ligne, const char* _className, const char* _funcName, const char* _libName)
|
|
||||||
{
|
|
||||||
char tmpName[FUNCTION_NAME_SIZE] = "";
|
|
||||||
if (NULL == _libName) {
|
|
||||||
_libName = "????????";
|
|
||||||
}
|
|
||||||
#if defined(__TARGET_OS__Android)
|
|
||||||
_className = NULL;
|
|
||||||
#endif
|
|
||||||
if (NULL == _className) {
|
|
||||||
snprintf(tmpName, FUNCTION_NAME_SIZE-1, "%s | (l=%5d) %s ",_libName, _ligne, _funcName);
|
|
||||||
} else {
|
|
||||||
snprintf(tmpName, FUNCTION_NAME_SIZE-1, "%s | (l=%5d) %s::%s ", _libName, _ligne, _className, _funcName);
|
|
||||||
}
|
|
||||||
tmpName[FUNCTION_NAME_SIZE-4] = ' ';
|
|
||||||
tmpName[FUNCTION_NAME_SIZE-3] = '|';
|
|
||||||
tmpName[FUNCTION_NAME_SIZE-2] = ' ';
|
|
||||||
tmpName[FUNCTION_NAME_SIZE-1] = '\0';
|
|
||||||
etk::cout << tmpName;
|
|
||||||
}
|
|
||||||
|
|
||||||
void debug::displayTime(void)
|
|
||||||
{
|
|
||||||
char tmpdata[50];
|
|
||||||
#ifdef __TARGET_OS__Android
|
|
||||||
struct timeval now;
|
|
||||||
gettimeofday(&now, NULL);
|
|
||||||
sprintf(tmpdata, " %2dh%2d'%2d | ", (int32_t)(now.tv_sec/3600)%24, (int32_t)(now.tv_sec/60)%60, (int32_t)(now.tv_sec%60));
|
|
||||||
#else
|
|
||||||
time_t rawtime;
|
|
||||||
struct tm * timeinfo;
|
|
||||||
time(&rawtime);
|
|
||||||
timeinfo = localtime(&rawtime);
|
|
||||||
sprintf(tmpdata, " %2dh%2d'%2d | ", (timeinfo->tm_hour)%24, timeinfo->tm_min, timeinfo->tm_sec);
|
|
||||||
#endif
|
|
||||||
etk::cout << tmpdata ;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#if (defined(__TARGET_OS__Android) || defined(__TARGET_OS__IOs))
|
|
||||||
enum etk::logLevel g_requestedLevel = etk::logLevelDebug;
|
|
||||||
#else
|
|
||||||
enum etk::logLevel g_requestedLevel = etk::logLevelWarning;
|
|
||||||
#endif
|
|
||||||
void debug::setGeneralLevel(enum etk::logLevel _ccc) {
|
|
||||||
g_requestedLevel = _ccc;
|
|
||||||
}
|
|
||||||
|
|
@ -1,91 +0,0 @@
|
|||||||
/**
|
|
||||||
* @author Edouard DUPIN
|
|
||||||
*
|
|
||||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
|
||||||
*
|
|
||||||
* @license BSD v3 (see license file)
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <etk/types.h>
|
|
||||||
|
|
||||||
#ifndef __ETK_DEBUG_GENERIC_H__
|
|
||||||
#define __ETK_DEBUG_GENERIC_H__
|
|
||||||
|
|
||||||
#include <etk/Stream.h>
|
|
||||||
|
|
||||||
namespace debug {
|
|
||||||
// Log Message System For EDN
|
|
||||||
void displayFuncName(int32_t _ligne, const char* _className, const char* _funcName, const char* _libName);
|
|
||||||
void displayTime(void);
|
|
||||||
void setGeneralLevel(enum etk::logLevel _ccc);
|
|
||||||
}
|
|
||||||
|
|
||||||
#undef __class__
|
|
||||||
#define __class__ (NULL)
|
|
||||||
|
|
||||||
extern enum etk::logLevel g_requestedLevel;
|
|
||||||
|
|
||||||
#define ETK_DBG_COMMON(libName,info,data) do { \
|
|
||||||
if (info <= g_requestedLevel) { \
|
|
||||||
etk::cout << etk::cstart << info; \
|
|
||||||
debug::displayTime(); \
|
|
||||||
debug::displayFuncName(__LINE__, __class__, __func__, libName); \
|
|
||||||
etk::cout << data; \
|
|
||||||
etk::cout <<etk::endl; \
|
|
||||||
} \
|
|
||||||
}while(0)
|
|
||||||
|
|
||||||
|
|
||||||
#define ETK_CRITICAL(libName,data) do { \
|
|
||||||
ETK_DBG_COMMON(libName, etk::logLevelCritical, data); \
|
|
||||||
etk::displayBacktrace(); \
|
|
||||||
}while(0)
|
|
||||||
|
|
||||||
#if DEBUG_LEVEL > 0
|
|
||||||
# define ETK_WARNING(libName,data) ETK_DBG_COMMON(libName, etk::logLevelWarning, data)
|
|
||||||
# define ETK_ERROR(libName,data) ETK_DBG_COMMON(libName, etk::logLevelError, data)
|
|
||||||
#else
|
|
||||||
# define ETK_WARNING(libName,data) do {}while(0)
|
|
||||||
# define ETK_ERROR(libName,data) do {}while(0)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if DEBUG_LEVEL > 1
|
|
||||||
# define ETK_INFO(libName,data) ETK_DBG_COMMON(libName, etk::logLevelInfo, data)
|
|
||||||
#else
|
|
||||||
# define ETK_INFO(libName,data) do {}while(0)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if DEBUG_LEVEL > 2
|
|
||||||
# define ETK_DEBUG(libName,data) ETK_DBG_COMMON(libName, etk::logLevelDebug, data)
|
|
||||||
#else
|
|
||||||
# define ETK_DEBUG(libName,data) do {}while(0)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if (DEBUG_LEVEL > 3 || defined(DEBUG_ENABLE_VERBOSE))
|
|
||||||
# define ETK_VERBOSE(libName,data) ETK_DBG_COMMON(libName, etk::logLevelVerbose, data)
|
|
||||||
#else
|
|
||||||
# define ETK_VERBOSE(libName,data) do {}while(0)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define ETK_ASSERT(libName,cond,data) do { \
|
|
||||||
if (!(cond)) { \
|
|
||||||
ETK_CRITICAL(libName, data); \
|
|
||||||
assert(!#cond); \
|
|
||||||
} \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#if DEBUG_LEVEL > 1
|
|
||||||
# define ETK_CHECK_INOUT(libName,cond) ETK_ASSERT(libName, (cond), "Internal input error : "#cond)
|
|
||||||
#elif DEBUG_LEVEL > 0
|
|
||||||
# define ETK_CHECK_INOUT(libName,cond) do { \
|
|
||||||
if (!(cond)) { \
|
|
||||||
ETK_CRITICAL(libName, "Internal input error : "#cond); \
|
|
||||||
} \
|
|
||||||
} while (0)
|
|
||||||
#else
|
|
||||||
# define ETK_CHECK_INOUT(libName,cond) do { } while (0)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define ETK_TODO(libName,data) ETK_INFO(libName, "TODO : " << data)
|
|
||||||
|
|
||||||
#endif
|
|
374
etk/log.cpp
Normal file
374
etk/log.cpp
Normal file
@ -0,0 +1,374 @@
|
|||||||
|
/**
|
||||||
|
* @author Edouard DUPIN
|
||||||
|
*
|
||||||
|
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||||
|
*
|
||||||
|
* @license BSD v3 (see license file)
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <etk/log.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <mutex>
|
||||||
|
|
||||||
|
#if defined(__TARGET_OS__Android)
|
||||||
|
# include <android/log.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <etk/logIOs.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
#if defined(__TARGET_OS__Linux) && DEBUG_LEVEL > 2
|
||||||
|
#include <execinfo.h>
|
||||||
|
#include <cxxabi.h>
|
||||||
|
#include <dlfcn.h>
|
||||||
|
#define MAX_DEPTH (256)
|
||||||
|
void etk::displayBacktrace(bool _breakAtEnd) {
|
||||||
|
// retrieve call-stack
|
||||||
|
void * trace[MAX_DEPTH];
|
||||||
|
int stack_depth = backtrace(trace, MAX_DEPTH);
|
||||||
|
|
||||||
|
TK_ERROR("Back-trace : ");
|
||||||
|
for (int32_t i = 1; i < stack_depth; i++) {
|
||||||
|
Dl_info dlinfo;
|
||||||
|
if(!dladdr(trace[i], &dlinfo)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
const char * symname = dlinfo.dli_sname;
|
||||||
|
int status;
|
||||||
|
char * demangled = abi::__cxa_demangle(symname, NULL, 0, &status);
|
||||||
|
if(status == 0 && demangled) {
|
||||||
|
symname = demangled;
|
||||||
|
}
|
||||||
|
TK_WARNING(" " << dlinfo.dli_fname << ": ");
|
||||||
|
TK_ERROR(" " << symname);
|
||||||
|
if(NULL != demangled) {
|
||||||
|
free(demangled);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (_breakAtEnd == true) {
|
||||||
|
assert(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
void etk::displayBacktrace(bool _breakAtEnd) {
|
||||||
|
#if DEBUG_LEVEL > 2
|
||||||
|
assert(false);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
enum etk::log::level& getDefaultLevel(void) {
|
||||||
|
static enum etk::log::level g_val = etk::log::logLevelNone;
|
||||||
|
return g_val;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::pair<std::string, enum etk::log::level>>& getList(void) {
|
||||||
|
static std::vector<std::pair<std::string, enum etk::log::level>> g_val;
|
||||||
|
return g_val;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t etk::log::registerInstance(const std::string& _name) {
|
||||||
|
for (size_t iii = 0; iii < getList().size(); ++iii) {
|
||||||
|
if (getList()[iii].first == _name) {
|
||||||
|
return iii;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
getList().push_back(std::make_pair(_name, getDefaultLevel()));
|
||||||
|
//std::cout << "register log : '" << _name << "'=" << getList().size()-1 << std::endl;
|
||||||
|
return getList().size()-1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void etk::log::setLevel(const std::string& _name, enum level _level) {
|
||||||
|
for (size_t iii = 0; iii < getList().size(); ++iii) {
|
||||||
|
if (getList()[iii].first == _name) {
|
||||||
|
getList()[iii].second = _level;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
getList().push_back(std::make_pair(_name, _level));
|
||||||
|
}
|
||||||
|
|
||||||
|
void etk::log::setLevel(enum level _level) {
|
||||||
|
getDefaultLevel() = _level;
|
||||||
|
for (size_t iii = 0; iii < getList().size(); ++iii) {
|
||||||
|
getList()[iii].second = _level;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void etk::log::setLevel(int32_t _id, enum level _level) {
|
||||||
|
if (_id < 0 || _id > (int32_t)getList().size()) {
|
||||||
|
// ERROR...
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
getList()[_id].second = _level;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int32_t etk::log::getLevel(int32_t _id) {
|
||||||
|
if (_id < 0 || _id > (int32_t)getList().size()) {
|
||||||
|
// ERROR...
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return (int32_t)getList()[_id].second;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> etk::log::getListInstance(void) {
|
||||||
|
std::vector<std::string> out;
|
||||||
|
for (size_t iii = 0; iii < getList().size(); ++iii) {
|
||||||
|
out.push_back(getList()[iii].first);
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
void etk::log::logStream(int32_t _id, int32_t _level, int32_t _ligne, const char* _className, const char* _funcName, const std::ostream& _log) {
|
||||||
|
std::ostringstream oss;
|
||||||
|
oss << _log.rdbuf();
|
||||||
|
std::string sss =oss.str();
|
||||||
|
etk::log::logChar(_id, _level, _ligne, _className, _funcName, sss.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
void etk::log::logChar1(int32_t _id, int32_t _level, const char* _log) {
|
||||||
|
etk::log::logChar(_id, _level, -1, NULL, NULL, _log);
|
||||||
|
}
|
||||||
|
|
||||||
|
void etk::log::logStream1(int32_t _id, int32_t _level, const std::ostream& _log) {
|
||||||
|
std::ostringstream oss;
|
||||||
|
oss << _log.rdbuf();
|
||||||
|
std::string sss =oss.str();
|
||||||
|
etk::log::logChar(_id, _level, -1, NULL, NULL, sss.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool& getColor(void) {
|
||||||
|
static bool g_val = true;
|
||||||
|
return g_val;
|
||||||
|
}
|
||||||
|
|
||||||
|
void etk::log::setColor(bool _status) {
|
||||||
|
getColor() = _status;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool& getTime(void) {
|
||||||
|
static bool g_val = true;
|
||||||
|
return g_val;
|
||||||
|
}
|
||||||
|
void etk::log::setTime(bool _status) {
|
||||||
|
getTime() = _status;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool& getLine(void) {
|
||||||
|
static bool g_val = true;
|
||||||
|
return g_val;
|
||||||
|
}
|
||||||
|
void etk::log::setLine(bool _status) {
|
||||||
|
getLine() = _status;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool& getFunction(void) {
|
||||||
|
static bool g_val = true;
|
||||||
|
return g_val;
|
||||||
|
}
|
||||||
|
void etk::log::setFunction(bool _status) {
|
||||||
|
getFunction() = _status;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void getDisplayTime(char* data) {
|
||||||
|
#ifdef __TARGET_OS__Android
|
||||||
|
struct timeval now;
|
||||||
|
gettimeofday(&now, NULL);
|
||||||
|
sprintf(data, " %2dh%2d'%2d | ", (int32_t)(now.tv_sec/3600)%24, (int32_t)(now.tv_sec/60)%60, (int32_t)(now.tv_sec%60));
|
||||||
|
#else
|
||||||
|
time_t rawtime;
|
||||||
|
struct tm * timeinfo;
|
||||||
|
time(&rawtime);
|
||||||
|
timeinfo = localtime(&rawtime);
|
||||||
|
sprintf(data, " %2dh%2d'%2d | ", (timeinfo->tm_hour)%24, timeinfo->tm_min, timeinfo->tm_sec);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
//regular colors
|
||||||
|
#define ETK_BASH_COLOR_BLACK "\e[0;30m"
|
||||||
|
#define ETK_BASH_COLOR_RED "\e[0;31m"
|
||||||
|
#define ETK_BASH_COLOR_GREEN "\e[0;32m"
|
||||||
|
#define ETK_BASH_COLOR_YELLOW "\e[0;33m"
|
||||||
|
#define ETK_BASH_COLOR_BLUE "\e[0;34m"
|
||||||
|
#define ETK_BASH_COLOR_MAGENTA "\e[0;35m"
|
||||||
|
#define ETK_BASH_COLOR_CYAN "\e[0;36m"
|
||||||
|
#define ETK_BASH_COLOR_WHITE "\e[0;37m"
|
||||||
|
//emphasized (bolded) colors
|
||||||
|
#define ETK_BASH_COLOR_BOLD_BLACK "\e[1;30m"
|
||||||
|
#define ETK_BASH_COLOR_BOLD_RED "\e[1;31m"
|
||||||
|
#define ETK_BASH_COLOR_BOLD_GREEN "\e[1;32m"
|
||||||
|
#define ETK_BASH_COLOR_BOLD_YELLOW "\e[1;33m"
|
||||||
|
#define ETK_BASH_COLOR_BOLD_BLUE "\e[1;34m"
|
||||||
|
#define ETK_BASH_COLOR_BOLD_MAGENTA "\e[1;35m"
|
||||||
|
#define ETK_BASH_COLOR_BOLD_CYAN "\e[1;36m"
|
||||||
|
#define ETK_BASH_COLOR_BOLD_WHITE "\e[1;37m"
|
||||||
|
//background colors
|
||||||
|
#define ETK_BASH_COLOR_BG_BLACK "\e[40m"
|
||||||
|
#define ETK_BASH_COLOR_BG_RED "\e[41m"
|
||||||
|
#define ETK_BASH_COLOR_BG_GREEN "\e[42m"
|
||||||
|
#define ETK_BASH_COLOR_BG_YELLOW "\e[43m"
|
||||||
|
#define ETK_BASH_COLOR_BG_BLUE "\e[44m"
|
||||||
|
#define ETK_BASH_COLOR_BG_MAGENTA "\e[45m"
|
||||||
|
#define ETK_BASH_COLOR_BG_CYAN "\e[46m"
|
||||||
|
#define ETK_BASH_COLOR_BG_WHITE "\e[47m"
|
||||||
|
// Return to the normal color setings
|
||||||
|
#define ETK_BASH_COLOR_NORMAL "\e[0m"
|
||||||
|
//go to the Top of bash
|
||||||
|
#define ETK_BASH_GO_TOP "\e[0;0f"
|
||||||
|
|
||||||
|
|
||||||
|
void etk::log::logChar(int32_t _id, int32_t _level, int32_t _ligne, const char* _className, const char* _funcName, const char* _log) {
|
||||||
|
static std::mutex g_lock;
|
||||||
|
char handle[1024] = "";
|
||||||
|
memset(handle, ' ', 1024);
|
||||||
|
handle[0] = '\0';
|
||||||
|
char* pointer = handle;
|
||||||
|
if(getColor() == true) {
|
||||||
|
switch(_level) {
|
||||||
|
default:
|
||||||
|
// nothing to do ...
|
||||||
|
break;
|
||||||
|
case logLevelCritical:
|
||||||
|
strcat(pointer, ETK_BASH_COLOR_BOLD_RED);
|
||||||
|
break;
|
||||||
|
case logLevelError:
|
||||||
|
strcat(pointer, ETK_BASH_COLOR_RED);
|
||||||
|
break;
|
||||||
|
case logLevelWarning:
|
||||||
|
strcat(pointer, ETK_BASH_COLOR_MAGENTA);
|
||||||
|
break;
|
||||||
|
case logLevelInfo:
|
||||||
|
strcat(pointer, ETK_BASH_COLOR_CYAN);
|
||||||
|
break;
|
||||||
|
case logLevelDebug:
|
||||||
|
strcat(pointer, ETK_BASH_COLOR_YELLOW);
|
||||||
|
break;
|
||||||
|
case logLevelVerbose:
|
||||||
|
strcat(pointer, ETK_BASH_COLOR_WHITE);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
pointer = handle+strlen(handle);
|
||||||
|
}
|
||||||
|
if(getTime() == true) {
|
||||||
|
getDisplayTime(pointer);
|
||||||
|
pointer = handle+strlen(handle);
|
||||||
|
}
|
||||||
|
#if !defined(__TARGET_OS__Android)
|
||||||
|
switch(_level) {
|
||||||
|
default:
|
||||||
|
strcat(pointer, "[?] ");
|
||||||
|
break;
|
||||||
|
case logLevelCritical:
|
||||||
|
strcat(pointer, "[C] ");
|
||||||
|
break;
|
||||||
|
case logLevelError:
|
||||||
|
strcat(pointer, "[E] ");
|
||||||
|
break;
|
||||||
|
case logLevelWarning:
|
||||||
|
strcat(pointer, "[W] ");
|
||||||
|
break;
|
||||||
|
case logLevelInfo:
|
||||||
|
strcat(pointer, "[I] ");
|
||||||
|
break;
|
||||||
|
case logLevelDebug:
|
||||||
|
strcat(pointer, "[D] ");
|
||||||
|
break;
|
||||||
|
case logLevelVerbose:
|
||||||
|
strcat(pointer, "[V] ");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
pointer = handle+strlen(handle);
|
||||||
|
#endif
|
||||||
|
if (_id >= 0) {
|
||||||
|
int32_t len = strlen(handle);
|
||||||
|
strcat(pointer, getList()[_id].first.c_str());
|
||||||
|
pointer = handle+strlen(handle);
|
||||||
|
while (strlen(handle) - len < 8) {
|
||||||
|
*pointer++ = ' ';
|
||||||
|
*pointer = '\0';
|
||||||
|
}
|
||||||
|
*pointer++ = '|';
|
||||||
|
*pointer++ = ' ';
|
||||||
|
*pointer = '\0';
|
||||||
|
}
|
||||||
|
if(getLine() == true) {
|
||||||
|
if (_ligne >= 0) {
|
||||||
|
sprintf(pointer, "(l=%5d)", _ligne);
|
||||||
|
pointer = handle+strlen(handle);
|
||||||
|
*pointer++ = ' ';
|
||||||
|
*pointer = '\0';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(getFunction() == true) {
|
||||||
|
int32_t len = strlen(handle);
|
||||||
|
if (_className != NULL) {
|
||||||
|
snprintf(pointer, 70, "%s::", _className);
|
||||||
|
pointer = handle+strlen(handle);
|
||||||
|
}
|
||||||
|
if (_funcName != NULL) {
|
||||||
|
snprintf(pointer, 70, "%s", _funcName);
|
||||||
|
pointer = handle+strlen(handle);
|
||||||
|
}
|
||||||
|
while (strlen(handle) - len < 60) {
|
||||||
|
*pointer++ = ' ';
|
||||||
|
*pointer = '\0';
|
||||||
|
}
|
||||||
|
*pointer++ = '|';
|
||||||
|
*pointer++ = ' ';
|
||||||
|
*pointer = '\0';
|
||||||
|
}
|
||||||
|
if (strlen(_log) > 1024-strlen(handle)-20) {
|
||||||
|
memcpy(pointer, _log, 1024-strlen(handle)-21);
|
||||||
|
handle[1024-25] = ' ';
|
||||||
|
handle[1024-24] = '.';
|
||||||
|
handle[1024-23] = '.';
|
||||||
|
handle[1024-22] = '.';
|
||||||
|
handle[1024-21] = '\0';
|
||||||
|
} else {
|
||||||
|
strcat(pointer, _log);
|
||||||
|
}
|
||||||
|
pointer = handle+strlen(handle);
|
||||||
|
if(getColor() == true) {
|
||||||
|
strcat(pointer, ETK_BASH_COLOR_NORMAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_lock.lock();
|
||||||
|
#if defined(__TARGET_OS__Android)
|
||||||
|
// TODO : Set package name instead of ewol ...
|
||||||
|
switch(_level) {
|
||||||
|
default:
|
||||||
|
__android_log_print(ANDROID_LOG_VERBOSE, "EWOL", "%s", handle);
|
||||||
|
break;
|
||||||
|
case logLevelCritical:
|
||||||
|
__android_log_print(ANDROID_LOG_FATAL, "EWOL", "%s", handle);
|
||||||
|
break;
|
||||||
|
case logLevelError:
|
||||||
|
__android_log_print(ANDROID_LOG_ERROR, "EWOL", "%s", handle);
|
||||||
|
break;
|
||||||
|
case logLevelWarning:
|
||||||
|
__android_log_print(ANDROID_LOG_WARN, "EWOL", "%s", handle);
|
||||||
|
break;
|
||||||
|
case logLevelInfo:
|
||||||
|
__android_log_print(ANDROID_LOG_INFO, "EWOL", "%s", handle);
|
||||||
|
break;
|
||||||
|
case logLevelDebug:
|
||||||
|
__android_log_print(ANDROID_LOG_DEBUG, "EWOL", "%s", handle);
|
||||||
|
break;
|
||||||
|
case logLevelVerbose:
|
||||||
|
__android_log_print(ANDROID_LOG_VERBOSE, "EWOL", "%s", handle);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
#elif defined(__TARGET_OS__IOs)
|
||||||
|
iosNSLog(handle);
|
||||||
|
#else
|
||||||
|
std::cout << handle << std::endl;
|
||||||
|
#endif
|
||||||
|
g_lock.unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
105
etk/log.h
Normal file
105
etk/log.h
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
/**
|
||||||
|
* @author Edouard DUPIN
|
||||||
|
*
|
||||||
|
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||||
|
*
|
||||||
|
* @license BSD v3 (see license file)
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __ETK_LOG_H__
|
||||||
|
#define __ETK_LOG_H__
|
||||||
|
|
||||||
|
#include <etk/types.h>
|
||||||
|
#include <sstream>
|
||||||
|
#include <ostream>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
namespace etk {
|
||||||
|
namespace log {
|
||||||
|
/**
|
||||||
|
* @brief Log level is a simple list of all log availlable. This enum is used when setting a log and when user chose the level of log displayed.
|
||||||
|
*/
|
||||||
|
enum level {
|
||||||
|
logLevelNone = 0, //!< no display requested
|
||||||
|
logLevelCritical = 1, //!< Display only critical logs (note that critical generally assert with a backtrace (when we can))
|
||||||
|
logLevelError = 2, //!< Display Error and critical logs
|
||||||
|
logLevelWarning = 3, //!< Display log critical to warning
|
||||||
|
logLevelInfo = 4, //!< Display log critical to information (removed in release mode)
|
||||||
|
logLevelDebug = 5, //!< Display log critical to debug (removed in release mode)
|
||||||
|
logLevelVerbose = 6 //!< Display all logs (removed in release and debug mode)
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* @brief Register an element in the log system
|
||||||
|
* @param[in] _name Name of the module
|
||||||
|
* @return reference Id of an instance name
|
||||||
|
*/
|
||||||
|
int32_t registerInstance(const std::string& _name);
|
||||||
|
/**
|
||||||
|
* @brief Set the log level of a specific instance
|
||||||
|
* @param[in] _name Name of the intance
|
||||||
|
* @param[in] _id Id of the intance
|
||||||
|
* @param[in] _level New level to set on the instance
|
||||||
|
*/
|
||||||
|
void setLevel(const std::string& _name, enum level _level);
|
||||||
|
//! @previous
|
||||||
|
void setLevel(int32_t _id, enum level _level);
|
||||||
|
/**
|
||||||
|
* @brief Set global debug level
|
||||||
|
* @param[in] _level New level to set on the instance
|
||||||
|
*/
|
||||||
|
void setLevel(enum level _level);
|
||||||
|
/**
|
||||||
|
* @brief Get the current level of debug for a specific intance
|
||||||
|
* @param[in] _id Id Of the intance
|
||||||
|
* @return the enum casted in an integer ==> generise the API (not dependent of etk)
|
||||||
|
*/
|
||||||
|
int32_t getLevel(int32_t _id);
|
||||||
|
/**
|
||||||
|
* @brief Get list of all intance
|
||||||
|
* @return the name list of all intance
|
||||||
|
*/
|
||||||
|
std::vector<std::string> getListInstance(void);
|
||||||
|
/**
|
||||||
|
* @brief Set Color enable or disable.
|
||||||
|
* @param[in] _status New value of color.
|
||||||
|
*/
|
||||||
|
void setColor(bool _status);
|
||||||
|
/**
|
||||||
|
* @brief Set Time display enable or disable.
|
||||||
|
* @param[in] _status New value.
|
||||||
|
*/
|
||||||
|
void setTime(bool _status);
|
||||||
|
/**
|
||||||
|
* @brief Set Line display enable or disable.
|
||||||
|
* @param[in] _status New value.
|
||||||
|
*/
|
||||||
|
void setLine(bool _status);
|
||||||
|
/**
|
||||||
|
* @brief Set Function display enable or disable.
|
||||||
|
* @param[in] _status New value.
|
||||||
|
*/
|
||||||
|
void setFunction(bool _status);
|
||||||
|
/**
|
||||||
|
* @brief Call log to display
|
||||||
|
* @param[in] _id Id of the instance type
|
||||||
|
* @param[in] _level Level debug
|
||||||
|
* @param[in] _ligne Line of the debug
|
||||||
|
* @param[in] _className Class name of the debug
|
||||||
|
* @param[in] _funcName Function name for debug
|
||||||
|
* @param[in] _log Stream to log
|
||||||
|
*/
|
||||||
|
void logChar(int32_t _id, int32_t _level, int32_t _ligne, const char* _className, const char* _funcName, const char* _log);
|
||||||
|
//! @previous
|
||||||
|
void logStream(int32_t _id, int32_t _level, int32_t _ligne, const char* _className, const char* _funcName, const std::ostream& _log);
|
||||||
|
//! @previous
|
||||||
|
void logChar1(int32_t _id, int32_t _level, const char* _log);
|
||||||
|
//! @previous
|
||||||
|
void logStream1(int32_t _id, int32_t _level, const std::ostream& _log);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
#ifdef __class__
|
||||||
|
#undef __class__
|
||||||
|
#endif
|
||||||
|
#define __class__ ("lkjlkj")
|
||||||
|
|
||||||
|
#endif
|
@ -6,8 +6,8 @@
|
|||||||
* @license BSD v3 (see license file)
|
* @license BSD v3 (see license file)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __ETK_STREAM_IOS_H__
|
#ifndef __ETK_LOG_IOS_H__
|
||||||
#define __ETK_STREAM_IOS_H__
|
#define __ETK_LOG_IOS_H__
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#import <UIKit/UIKit.h>
|
#import <UIKit/UIKit.h>
|
||||||
#include <etk/StreamIOs.h>
|
#include <etk/logIOs.h>
|
||||||
|
|
||||||
void iosNSLog(const char * _value) {
|
void iosNSLog(const char * _value) {
|
||||||
NSLog(@"\r%s", _value);
|
NSLog(@"\r%s", _value);
|
@ -217,12 +217,11 @@ etk::Matrix4 etk::Matrix4::invert()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
etk::CCout& etk::operator <<(etk::CCout &os, const etk::Matrix4 obj)
|
std::ostream& etk::operator <<(std::ostream& _os, const etk::Matrix4& _obj) {
|
||||||
{
|
_os << "matrix4 : (";
|
||||||
os << "matrix4 : (";
|
|
||||||
for (int32_t iii=0; iii<16; iii++) {
|
for (int32_t iii=0; iii<16; iii++) {
|
||||||
os << obj.m_mat[iii];
|
_os << _obj.m_mat[iii];
|
||||||
os << ",";
|
_os << ",";
|
||||||
}
|
}
|
||||||
return os;
|
return _os;
|
||||||
}
|
}
|
||||||
|
@ -264,7 +264,7 @@ namespace etk {
|
|||||||
/**
|
/**
|
||||||
* @brief Debug operator To display the curent element in a Human redeable information
|
* @brief Debug operator To display the curent element in a Human redeable information
|
||||||
*/
|
*/
|
||||||
etk::CCout& operator <<(etk::CCout &os, const etk::Matrix4 obj);
|
std::ostream& operator <<(std::ostream& _os, const etk::Matrix4& _obj);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
#include <etk/math/Vector2D.h>
|
#include <etk/math/Vector2D.h>
|
||||||
|
|
||||||
etk::CCout& etk::operator <<(etk::CCout& _os, const etk::Vector2D<int32_t>& _obj) {
|
std::ostream& etk::operator <<(std::ostream& _os, const etk::Vector2D<int32_t>& _obj) {
|
||||||
_os << "(";
|
_os << "(";
|
||||||
_os << _obj.x();
|
_os << _obj.x();
|
||||||
_os << ",";
|
_os << ",";
|
||||||
@ -17,7 +17,7 @@ etk::CCout& etk::operator <<(etk::CCout& _os, const etk::Vector2D<int32_t>& _obj
|
|||||||
return _os;
|
return _os;
|
||||||
}
|
}
|
||||||
|
|
||||||
etk::CCout& etk::operator <<(etk::CCout& _os, const etk::Vector2D<float>& _obj) {
|
std::ostream& etk::operator <<(std::ostream& _os, const etk::Vector2D<float>& _obj) {
|
||||||
_os << "(";
|
_os << "(";
|
||||||
_os << _obj.x();
|
_os << _obj.x();
|
||||||
_os << ",";
|
_os << ",";
|
||||||
@ -26,7 +26,7 @@ etk::CCout& etk::operator <<(etk::CCout& _os, const etk::Vector2D<float>& _obj)
|
|||||||
return _os;
|
return _os;
|
||||||
}
|
}
|
||||||
|
|
||||||
etk::CCout& etk::operator <<(etk::CCout& _os, const etk::Vector2D<uint32_t>& _obj) {
|
std::ostream& etk::operator <<(std::ostream& _os, const etk::Vector2D<uint32_t>& _obj) {
|
||||||
_os << "(";
|
_os << "(";
|
||||||
_os << _obj.x();
|
_os << _obj.x();
|
||||||
_os << ",";
|
_os << ",";
|
||||||
@ -35,7 +35,7 @@ etk::CCout& etk::operator <<(etk::CCout& _os, const etk::Vector2D<uint32_t>& _ob
|
|||||||
return _os;
|
return _os;
|
||||||
}
|
}
|
||||||
|
|
||||||
etk::CCout& etk::operator <<(etk::CCout& _os, const etk::Vector2D<bool>& _obj) {
|
std::ostream& etk::operator <<(std::ostream& _os, const etk::Vector2D<bool>& _obj) {
|
||||||
_os << "(";
|
_os << "(";
|
||||||
_os << _obj.x();
|
_os << _obj.x();
|
||||||
_os << ",";
|
_os << ",";
|
||||||
@ -44,7 +44,7 @@ etk::CCout& etk::operator <<(etk::CCout& _os, const etk::Vector2D<bool>& _obj) {
|
|||||||
return _os;
|
return _os;
|
||||||
}
|
}
|
||||||
|
|
||||||
etk::CCout& etk::operator <<(etk::CCout& _os, const std::vector<vec2 >& _obj) {
|
std::ostream& etk::operator <<(std::ostream& _os, const std::vector<vec2 >& _obj) {
|
||||||
for (size_t iii = 0; iii < _obj.size(); ++iii) {
|
for (size_t iii = 0; iii < _obj.size(); ++iii) {
|
||||||
if (iii != 0) {
|
if (iii != 0) {
|
||||||
_os << " ";
|
_os << " ";
|
||||||
@ -54,7 +54,7 @@ etk::CCout& etk::operator <<(etk::CCout& _os, const std::vector<vec2 >& _obj) {
|
|||||||
return _os;
|
return _os;
|
||||||
}
|
}
|
||||||
|
|
||||||
etk::CCout& etk::operator <<(etk::CCout& _os, const std::vector<ivec2 >& _obj) {
|
std::ostream& etk::operator <<(std::ostream& _os, const std::vector<ivec2 >& _obj) {
|
||||||
for (size_t iii = 0; iii < _obj.size(); ++iii) {
|
for (size_t iii = 0; iii < _obj.size(); ++iii) {
|
||||||
if (iii != 0) {
|
if (iii != 0) {
|
||||||
_os << " ";
|
_os << " ";
|
||||||
@ -64,7 +64,7 @@ etk::CCout& etk::operator <<(etk::CCout& _os, const std::vector<ivec2 >& _obj) {
|
|||||||
return _os;
|
return _os;
|
||||||
}
|
}
|
||||||
|
|
||||||
etk::CCout& etk::operator <<(etk::CCout& _os, const std::vector<uivec2 >& _obj) {
|
std::ostream& etk::operator <<(std::ostream& _os, const std::vector<uivec2 >& _obj) {
|
||||||
for (size_t iii = 0; iii < _obj.size(); ++iii) {
|
for (size_t iii = 0; iii < _obj.size(); ++iii) {
|
||||||
if (iii != 0) {
|
if (iii != 0) {
|
||||||
_os << " ";
|
_os << " ";
|
||||||
@ -74,7 +74,7 @@ etk::CCout& etk::operator <<(etk::CCout& _os, const std::vector<uivec2 >& _obj)
|
|||||||
return _os;
|
return _os;
|
||||||
}
|
}
|
||||||
|
|
||||||
etk::CCout& etk::operator <<(etk::CCout& _os, const std::vector<bvec2 >& _obj) {
|
std::ostream& etk::operator <<(std::ostream& _os, const std::vector<bvec2 >& _obj) {
|
||||||
for (size_t iii = 0; iii < _obj.size(); ++iii) {
|
for (size_t iii = 0; iii < _obj.size(); ++iii) {
|
||||||
if (iii != 0) {
|
if (iii != 0) {
|
||||||
_os << " ";
|
_os << " ";
|
||||||
@ -150,7 +150,7 @@ namespace etk {
|
|||||||
tmpStr.erase(0, posComa+1);
|
tmpStr.erase(0, posComa+1);
|
||||||
m_floats[1] = std::stob(tmpStr);
|
m_floats[1] = std::stob(tmpStr);
|
||||||
}
|
}
|
||||||
TK_VERBOSE("Parse : \"" << _str << "\" ==> " << *this);
|
TK_VERBOSE("Parse : '" << _str << "' ==> " << *this);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<> Vector2D<int32_t>::operator std::string(void) const {
|
template<> Vector2D<int32_t>::operator std::string(void) const {
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
#ifndef __ETK_MATH_VECTOR2D_H__
|
#ifndef __ETK_MATH_VECTOR2D_H__
|
||||||
#define __ETK_MATH_VECTOR2D_H__
|
#define __ETK_MATH_VECTOR2D_H__
|
||||||
|
|
||||||
#include <etk/Stream.h>
|
#include <etk/debug.h>
|
||||||
#include <etk/math/Vector3D.h>
|
#include <etk/math/Vector3D.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
@ -351,13 +351,13 @@ namespace etk {
|
|||||||
/**
|
/**
|
||||||
* @brief Debug operator To display the curent element in a Human redeable information
|
* @brief Debug operator To display the curent element in a Human redeable information
|
||||||
*/
|
*/
|
||||||
etk::CCout& operator <<(etk::CCout& _os, const etk::Vector2D<int32_t>& _obj);
|
std::ostream& operator <<(std::ostream& _os, const etk::Vector2D<int32_t>& _obj);
|
||||||
//! @previous
|
//! @previous
|
||||||
etk::CCout& operator <<(etk::CCout& _os, const etk::Vector2D<float>& _obj);
|
std::ostream& operator <<(std::ostream& _os, const etk::Vector2D<float>& _obj);
|
||||||
//! @previous
|
//! @previous
|
||||||
etk::CCout& operator <<(etk::CCout& _os, const etk::Vector2D<uint32_t>& _obj);
|
std::ostream& operator <<(std::ostream& _os, const etk::Vector2D<uint32_t>& _obj);
|
||||||
//! @previous
|
//! @previous
|
||||||
etk::CCout& operator <<(etk::CCout& _os, const etk::Vector2D<bool>& _obj);
|
std::ostream& operator <<(std::ostream& _os, const etk::Vector2D<bool>& _obj);
|
||||||
};
|
};
|
||||||
// To siplify the writing of the code ==> this permit to have the same name with the glsl language...
|
// To siplify the writing of the code ==> this permit to have the same name with the glsl language...
|
||||||
typedef etk::Vector2D<float> vec2;
|
typedef etk::Vector2D<float> vec2;
|
||||||
@ -376,12 +376,12 @@ inline vec2 vec2ClipInt64(const vec2& _val) {
|
|||||||
|
|
||||||
|
|
||||||
namespace etk {
|
namespace etk {
|
||||||
etk::CCout& operator <<(etk::CCout& _os, const std::vector<vec2 >& _obj);
|
std::ostream& operator <<(std::ostream& _os, const std::vector<vec2 >& _obj);
|
||||||
//! @previous
|
//! @previous
|
||||||
etk::CCout& operator <<(etk::CCout& _os, const std::vector<ivec2 >& _obj);
|
std::ostream& operator <<(std::ostream& _os, const std::vector<ivec2 >& _obj);
|
||||||
//! @previous
|
//! @previous
|
||||||
etk::CCout& operator <<(etk::CCout& _os, const std::vector<uivec2 >& _obj);
|
std::ostream& operator <<(std::ostream& _os, const std::vector<uivec2 >& _obj);
|
||||||
//! @previous
|
//! @previous
|
||||||
etk::CCout& operator <<(etk::CCout& _os, const std::vector<bvec2 >& _obj);
|
std::ostream& operator <<(std::ostream& _os, const std::vector<bvec2 >& _obj);
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
@ -8,56 +8,52 @@
|
|||||||
|
|
||||||
#include <etk/math/Vector3D.h>
|
#include <etk/math/Vector3D.h>
|
||||||
|
|
||||||
etk::CCout& etk::operator <<(etk::CCout &os, const etk::Vector3D<int32_t> obj)
|
std::ostream& etk::operator <<(std::ostream& _os, const etk::Vector3D<int32_t>& _obj) {
|
||||||
{
|
_os << "(";
|
||||||
os << "(";
|
_os << _obj.x();
|
||||||
os << obj.x();
|
_os << ",";
|
||||||
os << ",";
|
_os << _obj.y();
|
||||||
os << obj.y();
|
_os << ",";
|
||||||
os << ",";
|
_os << _obj.z();
|
||||||
os << obj.z();
|
_os << ")";
|
||||||
os << ")";
|
return _os;
|
||||||
return os;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
etk::CCout& etk::operator <<(etk::CCout &os, const btVector3 obj)
|
std::ostream& etk::operator <<(std::ostream& _os, const btVector3& _obj) {
|
||||||
{
|
_os << "(";
|
||||||
os << "(";
|
_os << _obj.x();
|
||||||
os << obj.x();
|
_os << ",";
|
||||||
os << ",";
|
_os << _obj.y();
|
||||||
os << obj.y();
|
_os << ",";
|
||||||
os << ",";
|
_os << _obj.z();
|
||||||
os << obj.z();
|
_os << ")";
|
||||||
os << ")";
|
return _os;
|
||||||
return os;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
etk::CCout& etk::operator <<(etk::CCout &os, const etk::Vector3D<uint32_t> obj)
|
std::ostream& etk::operator <<(std::ostream& _os, const etk::Vector3D<uint32_t>& _obj) {
|
||||||
{
|
_os << "(";
|
||||||
os << "(";
|
_os << _obj.x();
|
||||||
os << obj.x();
|
_os << ",";
|
||||||
os << ",";
|
_os << _obj.y();
|
||||||
os << obj.y();
|
_os << ",";
|
||||||
os << ",";
|
_os << _obj.z();
|
||||||
os << obj.z();
|
_os << ")";
|
||||||
os << ")";
|
return _os;
|
||||||
return os;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
etk::CCout& etk::operator <<(etk::CCout &os, const etk::Vector3D<bool> obj)
|
std::ostream& etk::operator <<(std::ostream& _os, const etk::Vector3D<bool>& _obj) {
|
||||||
{
|
_os << "(";
|
||||||
os << "(";
|
_os << _obj.x();
|
||||||
os << obj.x();
|
_os << ",";
|
||||||
os << ",";
|
_os << _obj.y();
|
||||||
os << obj.y();
|
_os << ",";
|
||||||
os << ",";
|
_os << _obj.z();
|
||||||
os << obj.z();
|
_os << ")";
|
||||||
os << ")";
|
return _os;
|
||||||
return os;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
etk::CCout& etk::operator <<(etk::CCout& _os, const std::vector<vec3 >& _obj) {
|
std::ostream& etk::operator <<(std::ostream& _os, const std::vector<vec3>& _obj) {
|
||||||
for (size_t iii = 0; iii < _obj.size(); ++iii) {
|
for (size_t iii = 0; iii < _obj.size(); ++iii) {
|
||||||
if (iii != 0) {
|
if (iii != 0) {
|
||||||
_os << " ";
|
_os << " ";
|
||||||
@ -67,7 +63,7 @@ etk::CCout& etk::operator <<(etk::CCout& _os, const std::vector<vec3 >& _obj) {
|
|||||||
return _os;
|
return _os;
|
||||||
}
|
}
|
||||||
|
|
||||||
etk::CCout& etk::operator <<(etk::CCout& _os, const std::vector<ivec3 >& _obj) {
|
std::ostream& etk::operator <<(std::ostream& _os, const std::vector<ivec3>& _obj) {
|
||||||
for (size_t iii = 0; iii < _obj.size(); ++iii) {
|
for (size_t iii = 0; iii < _obj.size(); ++iii) {
|
||||||
if (iii != 0) {
|
if (iii != 0) {
|
||||||
_os << " ";
|
_os << " ";
|
||||||
@ -77,7 +73,7 @@ etk::CCout& etk::operator <<(etk::CCout& _os, const std::vector<ivec3 >& _obj) {
|
|||||||
return _os;
|
return _os;
|
||||||
}
|
}
|
||||||
|
|
||||||
etk::CCout& etk::operator <<(etk::CCout& _os, const std::vector<uivec3 >& _obj) {
|
std::ostream& etk::operator <<(std::ostream& _os, const std::vector<uivec3>& _obj) {
|
||||||
for (size_t iii = 0; iii < _obj.size(); ++iii) {
|
for (size_t iii = 0; iii < _obj.size(); ++iii) {
|
||||||
if (iii != 0) {
|
if (iii != 0) {
|
||||||
_os << " ";
|
_os << " ";
|
||||||
@ -87,7 +83,7 @@ etk::CCout& etk::operator <<(etk::CCout& _os, const std::vector<uivec3 >& _obj)
|
|||||||
return _os;
|
return _os;
|
||||||
}
|
}
|
||||||
|
|
||||||
etk::CCout& etk::operator <<(etk::CCout& _os, const std::vector<bvec3 >& _obj) {
|
std::ostream& etk::operator <<(std::ostream& _os, const std::vector<bvec3>& _obj) {
|
||||||
for (size_t iii = 0; iii < _obj.size(); ++iii) {
|
for (size_t iii = 0; iii < _obj.size(); ++iii) {
|
||||||
if (iii != 0) {
|
if (iii != 0) {
|
||||||
_os << " ";
|
_os << " ";
|
||||||
@ -97,13 +93,12 @@ etk::CCout& etk::operator <<(etk::CCout& _os, const std::vector<bvec3 >& _obj) {
|
|||||||
return _os;
|
return _os;
|
||||||
}
|
}
|
||||||
|
|
||||||
vec3 quaternionToEulerXYZ(const btQuaternion& quat)
|
vec3 quaternionToEulerXYZ(const btQuaternion& _quat) {
|
||||||
{
|
|
||||||
// back to the euler angle :
|
// back to the euler angle :
|
||||||
float xxx = quat.x();
|
float xxx = _quat.x();
|
||||||
float yyy = quat.y();
|
float yyy = _quat.y();
|
||||||
float zzz = quat.z();
|
float zzz = _quat.z();
|
||||||
float www = quat.w();
|
float www = _quat.w();
|
||||||
double xxx2 = xxx*xxx;
|
double xxx2 = xxx*xxx;
|
||||||
double yyy2 = yyy*yyy;
|
double yyy2 = yyy*yyy;
|
||||||
double zzz2 = zzz*zzz;
|
double zzz2 = zzz*zzz;
|
||||||
|
@ -13,7 +13,6 @@
|
|||||||
|
|
||||||
#include <etk/debug.h>
|
#include <etk/debug.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <etk/Stream.h>
|
|
||||||
#include <LinearMath/btScalar.h>
|
#include <LinearMath/btScalar.h>
|
||||||
#include <LinearMath/btMinMax.h>
|
#include <LinearMath/btMinMax.h>
|
||||||
#include <LinearMath/btVector3.h>
|
#include <LinearMath/btVector3.h>
|
||||||
@ -443,13 +442,13 @@ namespace etk
|
|||||||
/**
|
/**
|
||||||
* @brief Debug operator To display the curent element in a Human redeable information
|
* @brief Debug operator To display the curent element in a Human redeable information
|
||||||
*/
|
*/
|
||||||
etk::CCout& operator <<(etk::CCout &_os, const etk::Vector3D<int32_t> _obj);
|
std::ostream& operator <<(std::ostream& _os, const etk::Vector3D<int32_t>& _obj);
|
||||||
//! @previous
|
//! @previous
|
||||||
etk::CCout& operator <<(etk::CCout &_os, const btVector3 _obj);
|
std::ostream& operator <<(std::ostream& _os, const btVector3& _obj);
|
||||||
//! @previous
|
//! @previous
|
||||||
etk::CCout& operator <<(etk::CCout &_os, const etk::Vector3D<uint32_t> _obj);
|
std::ostream& operator <<(std::ostream& _os, const etk::Vector3D<uint32_t>& _obj);
|
||||||
//! @previous
|
//! @previous
|
||||||
etk::CCout& operator <<(etk::CCout &_os, const etk::Vector3D<bool> _obj);
|
std::ostream& operator <<(std::ostream& _os, const etk::Vector3D<bool>& _obj);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -472,13 +471,13 @@ inline vec3 vec3ClipInt64(const vec3& val) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
namespace etk {
|
namespace etk {
|
||||||
etk::CCout& operator <<(etk::CCout& _os, const std::vector<vec3 >& _obj);
|
std::ostream& operator <<(std::ostream& _os, const std::vector<vec3>& _obj);
|
||||||
//! @previous
|
//! @previous
|
||||||
etk::CCout& operator <<(etk::CCout& _os, const std::vector<ivec3 >& _obj);
|
std::ostream& operator <<(std::ostream& _os, const std::vector<ivec3>& _obj);
|
||||||
//! @previous
|
//! @previous
|
||||||
etk::CCout& operator <<(etk::CCout& _os, const std::vector<uivec3 >& _obj);
|
std::ostream& operator <<(std::ostream& _os, const std::vector<uivec3>& _obj);
|
||||||
//! @previous
|
//! @previous
|
||||||
etk::CCout& operator <<(etk::CCout& _os, const std::vector<bvec3 >& _obj);
|
std::ostream& operator <<(std::ostream& _os, const std::vector<bvec3>& _obj);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -8,59 +8,55 @@
|
|||||||
|
|
||||||
#include <etk/math/Vector4D.h>
|
#include <etk/math/Vector4D.h>
|
||||||
|
|
||||||
etk::CCout& etk::operator <<(etk::CCout &os, const etk::Vector4D<int32_t> obj)
|
std::ostream& etk::operator <<(std::ostream &_os, const etk::Vector4D<int32_t>& _obj) {
|
||||||
{
|
_os << "(";
|
||||||
os << "(";
|
_os << _obj.x();
|
||||||
os << obj.x();
|
_os << ",";
|
||||||
os << ",";
|
_os << _obj.y();
|
||||||
os << obj.y();
|
_os << ",";
|
||||||
os << ",";
|
_os << _obj.z();
|
||||||
os << obj.z();
|
_os << ",";
|
||||||
os << ",";
|
_os << _obj.w();
|
||||||
os << obj.w();
|
_os << ")";
|
||||||
os << ")";
|
return _os;
|
||||||
return os;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
etk::CCout& etk::operator <<(etk::CCout &os, const etk::Vector4D<float> obj)
|
std::ostream& etk::operator <<(std::ostream &_os, const etk::Vector4D<float>& _obj) {
|
||||||
{
|
_os << "(";
|
||||||
os << "(";
|
_os << _obj.x();
|
||||||
os << obj.x();
|
_os << ",";
|
||||||
os << ",";
|
_os << _obj.y();
|
||||||
os << obj.y();
|
_os << ",";
|
||||||
os << ",";
|
_os << _obj.z();
|
||||||
os << obj.z();
|
_os << ",";
|
||||||
os << ",";
|
_os << _obj.w();
|
||||||
os << obj.w();
|
_os << ")";
|
||||||
os << ")";
|
return _os;
|
||||||
return os;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
etk::CCout& etk::operator <<(etk::CCout &os, const etk::Vector4D<uint32_t> obj)
|
std::ostream& etk::operator <<(std::ostream &_os, const etk::Vector4D<uint32_t>& _obj) {
|
||||||
{
|
_os << "(";
|
||||||
os << "(";
|
_os << _obj.x();
|
||||||
os << obj.x();
|
_os << ",";
|
||||||
os << ",";
|
_os << _obj.y();
|
||||||
os << obj.y();
|
_os << ",";
|
||||||
os << ",";
|
_os << _obj.z();
|
||||||
os << obj.z();
|
_os << ",";
|
||||||
os << ",";
|
_os << _obj.w();
|
||||||
os << obj.w();
|
_os << ")";
|
||||||
os << ")";
|
return _os;
|
||||||
return os;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
etk::CCout& etk::operator <<(etk::CCout &os, const etk::Vector4D<bool> obj)
|
std::ostream& etk::operator <<(std::ostream &_os, const etk::Vector4D<bool>& _obj) {
|
||||||
{
|
_os << "(";
|
||||||
os << "(";
|
_os << _obj.x();
|
||||||
os << obj.x();
|
_os << ",";
|
||||||
os << ",";
|
_os << _obj.y();
|
||||||
os << obj.y();
|
_os << ",";
|
||||||
os << ",";
|
_os << _obj.z();
|
||||||
os << obj.z();
|
_os << ",";
|
||||||
os << ",";
|
_os << _obj.w();
|
||||||
os << obj.w();
|
_os << ")";
|
||||||
os << ")";
|
return _os;
|
||||||
return os;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,7 +13,6 @@
|
|||||||
|
|
||||||
#include <etk/debug.h>
|
#include <etk/debug.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <etk/Stream.h>
|
|
||||||
#include <LinearMath/btScalar.h>
|
#include <LinearMath/btScalar.h>
|
||||||
#include <LinearMath/btMinMax.h>
|
#include <LinearMath/btMinMax.h>
|
||||||
#include <LinearMath/btVector3.h>
|
#include <LinearMath/btVector3.h>
|
||||||
@ -467,10 +466,10 @@ namespace etk
|
|||||||
/**
|
/**
|
||||||
* @brief Debug operator To display the curent element in a Human redeable information
|
* @brief Debug operator To display the curent element in a Human redeable information
|
||||||
*/
|
*/
|
||||||
etk::CCout& operator <<(etk::CCout &os, const etk::Vector4D<int32_t> obj);
|
std::ostream& operator <<(std::ostream& _os, const etk::Vector4D<int32_t>& _obj);
|
||||||
etk::CCout& operator <<(etk::CCout &os, const etk::Vector4D<float> obj);
|
std::ostream& operator <<(std::ostream& _os, const etk::Vector4D<float>& _obj);
|
||||||
etk::CCout& operator <<(etk::CCout &os, const etk::Vector4D<uint32_t> obj);
|
std::ostream& operator <<(std::ostream& _os, const etk::Vector4D<uint32_t>& _obj);
|
||||||
etk::CCout& operator <<(etk::CCout &os, const etk::Vector4D<bool> obj);
|
std::ostream& operator <<(std::ostream& _os, const etk::Vector4D<bool>& _obj);
|
||||||
};
|
};
|
||||||
|
|
||||||
// To siplify the writing of the code ==> this permit to have the same name with the glsl language...
|
// To siplify the writing of the code ==> this permit to have the same name with the glsl language...
|
||||||
|
@ -1116,12 +1116,12 @@ bool etk::FSNode::operator!= (const etk::FSNode& _obj ) const {
|
|||||||
return !(*this == _obj);
|
return !(*this == _obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
etk::CCout& etk::operator <<(etk::CCout &_os, const etk::FSNode &_obj) {
|
std::ostream& etk::operator <<(std::ostream &_os, const etk::FSNode &_obj) {
|
||||||
_os << "[" << _obj.m_type << "]->\"" << _obj.m_userFileName << "\"";
|
_os << "[" << _obj.m_type << "]->\"" << _obj.m_userFileName << "\"";
|
||||||
return _os;
|
return _os;
|
||||||
}
|
}
|
||||||
|
|
||||||
etk::CCout& etk::operator <<(etk::CCout &_os, const enum etk::FSNType &_obj) {
|
std::ostream& etk::operator <<(std::ostream &_os, const enum etk::FSNType &_obj) {
|
||||||
switch (_obj)
|
switch (_obj)
|
||||||
{
|
{
|
||||||
case etk::FSN_TYPE_UNKNOW:
|
case etk::FSN_TYPE_UNKNOW:
|
||||||
@ -1158,7 +1158,7 @@ etk::CCout& etk::operator <<(etk::CCout &_os, const enum etk::FSNType &_obj) {
|
|||||||
return _os;
|
return _os;
|
||||||
}
|
}
|
||||||
|
|
||||||
etk::CCout& etk::operator <<(etk::CCout &_os, const enum etk::typeNode &_obj) {
|
std::ostream& etk::operator <<(std::ostream &_os, const enum etk::typeNode &_obj) {
|
||||||
switch (_obj) {
|
switch (_obj) {
|
||||||
case etk::FSN_UNKNOW:
|
case etk::FSN_UNKNOW:
|
||||||
_os << "FSN_UNKNOW";
|
_os << "FSN_UNKNOW";
|
||||||
|
@ -38,7 +38,7 @@ namespace etk {
|
|||||||
FSN_SOCKET, //!< The node is a socket
|
FSN_SOCKET, //!< The node is a socket
|
||||||
};
|
};
|
||||||
|
|
||||||
etk::CCout& operator <<(etk::CCout &_os, const enum etk::typeNode &_obj);
|
std::ostream& operator <<(std::ostream &_os, const enum etk::typeNode &_obj);
|
||||||
|
|
||||||
enum seekNode{
|
enum seekNode{
|
||||||
FSN_SEEK_START,
|
FSN_SEEK_START,
|
||||||
@ -88,7 +88,7 @@ namespace etk {
|
|||||||
FSN_TYPE_THEME_DATA
|
FSN_TYPE_THEME_DATA
|
||||||
};
|
};
|
||||||
|
|
||||||
etk::CCout& operator <<(etk::CCout &_os, const enum etk::FSNType &_obj);
|
std::ostream& operator <<(std::ostream &_os, const enum etk::FSNType &_obj);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
note : The filename can be
|
note : The filename can be
|
||||||
@ -329,7 +329,7 @@ namespace etk {
|
|||||||
* @param[in] _obj Node to display
|
* @param[in] _obj Node to display
|
||||||
* @return std debug IO
|
* @return std debug IO
|
||||||
*/
|
*/
|
||||||
friend etk::CCout& operator <<( etk::CCout &_os,const etk::FSNode &_obj);
|
friend std::ostream& operator <<( std::ostream &_os,const etk::FSNode &_obj);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Count the number of subFolder in the curent Folder
|
* @brief Count the number of subFolder in the curent Folder
|
||||||
@ -478,7 +478,7 @@ namespace etk {
|
|||||||
void sortElementList(std::vector<etk::FSNode *>& _list);
|
void sortElementList(std::vector<etk::FSNode *>& _list);
|
||||||
};
|
};
|
||||||
|
|
||||||
etk::CCout& operator <<(etk::CCout &_os, const etk::FSNode &_obj);
|
std::ostream& operator <<(std::ostream &_os, const etk::FSNode &_obj);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Set manualy the folder of the Data.(like /usr/shared/applName/ for linux)
|
* @brief Set manualy the folder of the Data.(like /usr/shared/applName/ for linux)
|
||||||
|
@ -230,8 +230,7 @@ std::string etk::FSNodeRight::getRight(void) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
etk::CCout& etk::operator <<(etk::CCout &_os, const etk::FSNodeRight &_obj)
|
std::ostream& etk::operator <<(std::ostream &_os, const etk::FSNodeRight &_obj) {
|
||||||
{
|
|
||||||
_os << _obj.getRight();
|
_os << _obj.getRight();
|
||||||
return _os;
|
return _os;
|
||||||
};
|
};
|
||||||
|
@ -52,7 +52,7 @@ namespace etk {
|
|||||||
std::u32string getURight(void) const;
|
std::u32string getURight(void) const;
|
||||||
std::string getRight(void) const;
|
std::string getRight(void) const;
|
||||||
};
|
};
|
||||||
etk::CCout& operator <<(etk::CCout &_os, const etk::FSNodeRight &_obj);
|
std::ostream& operator <<(std::ostream &_os, const etk::FSNodeRight &_obj);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -12,12 +12,12 @@
|
|||||||
#undef __class__
|
#undef __class__
|
||||||
#define __class__ "u32char"
|
#define __class__ "u32char"
|
||||||
|
|
||||||
etk::CCout& etk::operator <<(etk::CCout& _os, const std::string& _obj) {
|
std::ostream& std::operator <<(std::ostream& _os, const std::string& _obj) {
|
||||||
_os << _obj.c_str();
|
_os << _obj.c_str();
|
||||||
return _os;
|
return _os;
|
||||||
}
|
}
|
||||||
|
|
||||||
etk::CCout& etk::operator <<(etk::CCout& _os, const std::vector<std::string>& _obj) {
|
std::ostream& std::operator <<(std::ostream& _os, const std::vector<std::string>& _obj) {
|
||||||
_os << "{";
|
_os << "{";
|
||||||
for (size_t iii=0; iii< _obj.size(); iii++) {
|
for (size_t iii=0; iii< _obj.size(); iii++) {
|
||||||
if (iii>0) {
|
if (iii>0) {
|
||||||
@ -29,12 +29,12 @@ etk::CCout& etk::operator <<(etk::CCout& _os, const std::vector<std::string>& _o
|
|||||||
return _os;
|
return _os;
|
||||||
}
|
}
|
||||||
|
|
||||||
etk::CCout& etk::operator <<(etk::CCout& _os, const std::u32string& _obj) {
|
std::ostream& std::operator <<(std::ostream& _os, const std::u32string& _obj) {
|
||||||
_os << std::to_string(_obj).c_str();
|
_os << std::to_string(_obj).c_str();
|
||||||
return _os;
|
return _os;
|
||||||
}
|
}
|
||||||
|
|
||||||
etk::CCout& etk::operator <<(etk::CCout& _os, const std::vector<std::u32string>& _obj) {
|
std::ostream& std::operator <<(std::ostream& _os, const std::vector<std::u32string>& _obj) {
|
||||||
_os << "{";
|
_os << "{";
|
||||||
for (size_t iii=0; iii< _obj.size(); iii++) {
|
for (size_t iii=0; iii< _obj.size(); iii++) {
|
||||||
if (iii>0) {
|
if (iii>0) {
|
||||||
|
@ -210,11 +210,12 @@ namespace std {
|
|||||||
//! @previous
|
//! @previous
|
||||||
void sort(std::vector<std::string *>& _list);
|
void sort(std::vector<std::string *>& _list);
|
||||||
};
|
};
|
||||||
namespace etk {
|
|
||||||
etk::CCout& operator <<(etk::CCout& _os, const std::string& _obj);
|
namespace std {
|
||||||
etk::CCout& operator <<(etk::CCout& _os, const std::vector<std::string>& _obj);
|
std::ostream& operator <<(std::ostream& _os, const std::string& _obj);
|
||||||
etk::CCout& operator <<(etk::CCout& _os, const std::u32string& _obj);
|
std::ostream& operator <<(std::ostream& _os, const std::vector<std::string>& _obj);
|
||||||
etk::CCout& operator <<(etk::CCout& _os, const std::vector<std::u32string>& _obj);
|
std::ostream& operator <<(std::ostream& _os, const std::u32string& _obj);
|
||||||
|
std::ostream& operator <<(std::ostream& _os, const std::vector<std::u32string>& _obj);
|
||||||
};
|
};
|
||||||
|
|
||||||
int32_t strlen(const char32_t * _data);
|
int32_t strlen(const char32_t * _data);
|
||||||
|
@ -13,10 +13,9 @@ def create(target):
|
|||||||
myModule.add_extra_compile_flags()
|
myModule.add_extra_compile_flags()
|
||||||
# add the file to compile:
|
# add the file to compile:
|
||||||
myModule.add_src_file([
|
myModule.add_src_file([
|
||||||
'etk/debugGeneric.cpp',
|
|
||||||
'etk/debug.cpp',
|
'etk/debug.cpp',
|
||||||
'etk/stdTools.cpp',
|
'etk/stdTools.cpp',
|
||||||
'etk/Stream.cpp',
|
'etk/log.cpp',
|
||||||
'etk/RegExp.cpp',
|
'etk/RegExp.cpp',
|
||||||
'etk/tool.cpp',
|
'etk/tool.cpp',
|
||||||
'etk/Noise.cpp',
|
'etk/Noise.cpp',
|
||||||
@ -38,7 +37,7 @@ def create(target):
|
|||||||
myModule.add_src_file('etk/os/Semaphore.Generic.cpp')
|
myModule.add_src_file('etk/os/Semaphore.Generic.cpp')
|
||||||
|
|
||||||
if target.name=="IOs":
|
if target.name=="IOs":
|
||||||
myModule.add_src_file('etk/StreamIOs.m')
|
myModule.add_src_file('etk/logIOs.m')
|
||||||
|
|
||||||
# name of the dependency
|
# name of the dependency
|
||||||
myModule.add_module_depend('linearmath')
|
myModule.add_module_depend('linearmath')
|
||||||
|
Loading…
Reference in New Issue
Block a user