[DEV] add missing const

This commit is contained in:
Edouard DUPIN 2013-05-08 12:19:19 +02:00
parent 2c649d3741
commit 249870fc13
5 changed files with 86 additions and 90 deletions

View File

@ -168,7 +168,7 @@ namespace etk
* @param[in] pos Position in the buffer.
* @return Element at the request pos.
*/
int8_t operator[] (int32_t pos)
int8_t operator[] (int32_t pos) const
{
TK_ASSERT(0 <= pos || pos < Size(), "try to read an element non existing");
if (pos < m_gapStart) {
@ -182,7 +182,7 @@ namespace etk
* @param[in] pos Desired position read
* @return Reference on the Element
*/
int8_t& Get(int32_t pos)
int8_t& Get(int32_t pos) const
{
TK_ASSERT(0 <= pos || pos < Size(), "try to read an element non existing");
if (pos < m_gapStart) {
@ -385,7 +385,7 @@ namespace etk
* @brief Get the number of element in the vector
* @return The number requested
*/
int32_t Size(void)
int32_t Size(void) const
{
return m_allocated - GapSize();
};
@ -496,7 +496,7 @@ namespace etk
* @brief Get the current gap size.
* @return The number of element in the gap
*/
int32_t GapSize(void)
int32_t GapSize(void) const
{
return m_gapEnd - m_gapStart;
}

View File

@ -133,7 +133,7 @@ template<class CLASS_TYPE> class RegExpNode{
* @param[in,out]
* @return
*/
virtual bool Parse(CLASS_TYPE &data, int32_t currentPos, int32_t lenMax, int32_t &findLen)
virtual bool Parse(const CLASS_TYPE &data, int32_t currentPos, int32_t lenMax, int32_t &findLen)
{
findLen = 0;
return false;
@ -233,7 +233,7 @@ template<class CLASS_TYPE> class RegExpNodeValue : public RegExpNode<CLASS_TYPE>
* @param[in,out]
* @return
*/
bool Parse(CLASS_TYPE &data, int32_t currentPos, int32_t lenMax, int32_t &findLen)
bool Parse(const CLASS_TYPE &data, int32_t currentPos, int32_t lenMax, int32_t &findLen)
{
findLen = 0;
//TK_INFO("Parse node : Value{" << RegExpNode<CLASS_TYPE>::m_multipleMin << "," << RegExpNode<CLASS_TYPE>::m_multipleMax << "}");
@ -359,7 +359,7 @@ template<class CLASS_TYPE> class RegExpNodeBracket : public RegExpNode<CLASS_TYP
* @param[in,out]
* @return
*/
bool Parse(CLASS_TYPE &data, int32_t currentPos, int32_t lenMax, int32_t &findLen)
bool Parse(const CLASS_TYPE &data, int32_t currentPos, int32_t lenMax, int32_t &findLen)
{
findLen = 0;
//TK_INFO("Parse node : [...]{" << RegExpNode<CLASS_TYPE>::m_multipleMin << "," << RegExpNode<CLASS_TYPE>::m_multipleMax << "}");
@ -437,7 +437,7 @@ template<class CLASS_TYPE> class RegExpNodeDigit : public RegExpNode<CLASS_TYPE>
* @param[in,out]
* @return
*/
bool Parse(CLASS_TYPE &data, int32_t currentPos, int32_t lenMax, int32_t &findLen)
bool Parse(const CLASS_TYPE &data, int32_t currentPos, int32_t lenMax, int32_t &findLen)
{
findLen = 0;
//TK_INFO("Parse node : Digit{" << RegExpNode<CLASS_TYPE>::m_multipleMin << "," << RegExpNode<CLASS_TYPE>::m_multipleMax << "} : "<< data[currentPos] << " lenMax=" << lenMax);
@ -503,7 +503,7 @@ template<class CLASS_TYPE> class RegExpNodeDigitNot : public RegExpNode<CLASS_TY
* @param[in,out]
* @return
*/
bool Parse(CLASS_TYPE &data, int32_t currentPos, int32_t lenMax, int32_t &findLen)
bool Parse(const CLASS_TYPE &data, int32_t currentPos, int32_t lenMax, int32_t &findLen)
{
findLen = 0;
//TK_INFO("Parse node : DigitNot{" << RegExpNode<CLASS_TYPE>::m_multipleMin << "," << RegExpNode<CLASS_TYPE>::m_multipleMax << "}");
@ -573,7 +573,7 @@ template<class CLASS_TYPE> class RegExpNodeLetter : public RegExpNode<CLASS_TYPE
* @param[in,out]
* @return
*/
bool Parse(CLASS_TYPE &data, int32_t currentPos, int32_t lenMax, int32_t &findLen)
bool Parse(const CLASS_TYPE &data, int32_t currentPos, int32_t lenMax, int32_t &findLen)
{
findLen = 0;
//TK_INFO("Parse node : Letter{" << RegExpNode<CLASS_TYPE>::m_multipleMin << "," << RegExpNode<CLASS_TYPE>::m_multipleMax << "}");
@ -645,7 +645,7 @@ template<class CLASS_TYPE> class RegExpNodeLetterNot : public RegExpNode<CLASS_T
* @param[in,out]
* @return
*/
bool Parse(CLASS_TYPE &data, int32_t currentPos, int32_t lenMax, int32_t &findLen)
bool Parse(const CLASS_TYPE &data, int32_t currentPos, int32_t lenMax, int32_t &findLen)
{
findLen = 0;
//TK_INFO("Parse node : LetterNot{" << RegExpNode<CLASS_TYPE>::m_multipleMin << "," << RegExpNode<CLASS_TYPE>::m_multipleMax << "}");
@ -717,7 +717,7 @@ template<class CLASS_TYPE> class RegExpNodeWhiteSpace : public RegExpNode<CLASS_
* @param[in,out]
* @return
*/
bool Parse(CLASS_TYPE &data, int32_t currentPos, int32_t lenMax, int32_t &findLen)
bool Parse(const CLASS_TYPE &data, int32_t currentPos, int32_t lenMax, int32_t &findLen)
{
findLen = 0;
//TK_INFO("Parse node : Space{" << m_multipleMin << "," << m_multipleMax << "}");
@ -791,7 +791,7 @@ template<class CLASS_TYPE> class RegExpNodeWhiteSpaceNot : public RegExpNode<CLA
* @param[in,out]
* @return
*/
bool Parse(CLASS_TYPE &data, int32_t currentPos, int32_t lenMax, int32_t &findLen)
bool Parse(const CLASS_TYPE &data, int32_t currentPos, int32_t lenMax, int32_t &findLen)
{
findLen = 0;
//TK_INFO("Parse node : SpaceNot{" << RegExpNode<CLASS_TYPE>::m_multipleMin << "," << RegExpNode<CLASS_TYPE>::m_multipleMax << "}");
@ -865,7 +865,7 @@ template<class CLASS_TYPE> class RegExpNodeWordChar : public RegExpNode<CLASS_TY
* @param[in,out]
* @return
*/
bool Parse(CLASS_TYPE &data, int32_t currentPos, int32_t lenMax, int32_t &findLen)
bool Parse(const CLASS_TYPE &data, int32_t currentPos, int32_t lenMax, int32_t &findLen)
{
findLen = 0;
//TK_INFO("Parse node : Word{" << RegExpNode<CLASS_TYPE>::m_multipleMin << "," << RegExpNode<CLASS_TYPE>::m_multipleMax << "}");
@ -939,7 +939,7 @@ template<class CLASS_TYPE> class RegExpNodeWordCharNot : public RegExpNode<CLASS
* @param[in,out]
* @return
*/
bool Parse(CLASS_TYPE &data, int32_t currentPos, int32_t lenMax, int32_t &findLen)
bool Parse(const CLASS_TYPE &data, int32_t currentPos, int32_t lenMax, int32_t &findLen)
{
findLen = 0;
//TK_INFO("Parse node : WordNot{" << RegExpNode<CLASS_TYPE>::m_multipleMin << "," << RegExpNode<CLASS_TYPE>::m_multipleMax << "}");
@ -1013,7 +1013,7 @@ template<class CLASS_TYPE> class RegExpNodeDot : public RegExpNode<CLASS_TYPE> {
* @param[in,out]
* @return
*/
bool Parse(CLASS_TYPE &data, int32_t currentPos, int32_t lenMax, int32_t &findLen)
bool Parse(const CLASS_TYPE &data, int32_t currentPos, int32_t lenMax, int32_t &findLen)
{
findLen = 0;
//TK_INFO("Parse node : '.'{" << RegExpNode<CLASS_TYPE>::m_multipleMin << "," << RegExpNode<CLASS_TYPE>::m_multipleMax << "}");
@ -1089,7 +1089,7 @@ template<class CLASS_TYPE> class RegExpNodeSOL : public RegExpNode<CLASS_TYPE> {
* @param[in,out]
* @return
*/
bool Parse(CLASS_TYPE &data, int32_t currentPos, int32_t lenMax, int32_t &findLen)
bool Parse(const CLASS_TYPE &data, int32_t currentPos, int32_t lenMax, int32_t &findLen)
{
findLen = 0;
TK_INFO("Parse node : SOL{" << RegExpNode<CLASS_TYPE>::m_multipleMin << "," << RegExpNode<CLASS_TYPE>::m_multipleMax << "}");
@ -1138,7 +1138,7 @@ template<class CLASS_TYPE> class RegExpNodeEOL : public RegExpNode<CLASS_TYPE> {
* @param[in,out]
* @return
*/
bool Parse(CLASS_TYPE &data, int32_t currentPos, int32_t lenMax, int32_t &findLen)
bool Parse(const CLASS_TYPE &data, int32_t currentPos, int32_t lenMax, int32_t &findLen)
{
findLen = 0;
TK_INFO("Parse node : EOL{" << RegExpNode<CLASS_TYPE>::m_multipleMin << "," << RegExpNode<CLASS_TYPE>::m_multipleMax << "}");
@ -1351,7 +1351,7 @@ template<class CLASS_TYPE> class RegExpNodePTheseElem : public RegExpNode<CLASS_
* @param[in,out]
* @return
*/
bool Parse(CLASS_TYPE &data, int32_t currentPos, int32_t lenMax, int32_t &findLen)
bool Parse(const CLASS_TYPE &data, int32_t currentPos, int32_t lenMax, int32_t &findLen)
{
findLen = 0;
//TK_INFO("Parse node : (Elem){" << RegExpNode<CLASS_TYPE>::m_multipleMin << "," << RegExpNode<CLASS_TYPE>::m_multipleMax << "}");
@ -1480,7 +1480,7 @@ template<class CLASS_TYPE> class RegExpNodePThese : public RegExpNode<CLASS_TYPE
* @param[in,out]
* @return
*/
bool Parse(CLASS_TYPE &data, int32_t currentPos, int32_t lenMax, int32_t &findLen)
bool Parse(const CLASS_TYPE &data, int32_t currentPos, int32_t lenMax, int32_t &findLen)
{
findLen = 0;
//TK_INFO("Parse node : (...){" << RegExpNode<CLASS_TYPE>::m_multipleMin << "," << RegExpNode<CLASS_TYPE>::m_multipleMax << "}");
@ -1611,11 +1611,10 @@ template<class CLASS_TYPE> class RegExp {
};
/**
* @brief
* @param[in,out]
* @return
* @brief Set a new regular expression matching
* @param[in] expressionRequested the new expression to search
*/
void SetRegExp(etk::UString &expressionRequested)
void SetRegExp(const etk::UString &expressionRequested)
{
m_expressionRequested = expressionRequested; // TODO : Must be deprecated ...
etk::Vector<int16_t> tmpExp;
@ -1745,19 +1744,18 @@ template<class CLASS_TYPE> class RegExp {
};
/**
* @brief
* @param[in,out]
* @return
* @brief Get the regular expression string
* @return the string representing the RegExp
*/
etk::UString GetRegExp(void)
etk::UString GetRegExp(void)
{
return m_expressionRequested;
};
/**
* @brief
* @param[in,out]
* @return
* @brief Get the status if the regular expression parsing
* @return true : the regExp is correctly parsed
* @return false : an error occcured (check log ...)
*/
bool GetStatus(void)
{
@ -1766,14 +1764,17 @@ template<class CLASS_TYPE> class RegExp {
// process the regular expression
/**
* @brief
* @param[in,out]
* @return
* @brief process the seach of the regular expression in a defined class type
* @param[in] SearchIn table of element to seach in
* @param[in] startPos start position to search
* @param[in] endPos end position to search
* @param[in] escapeChar special char that remove other char real type
* @return true : find something, false otherwise
*/
bool Process( CLASS_TYPE &SearchIn,
int32_t startPos,
int32_t endPos,
char escapeChar=0)
bool Process( const CLASS_TYPE& SearchIn,
int32_t startPos,
int32_t endPos,
char escapeChar=0)
{
if (false == m_isOk) {
return false;
@ -1851,10 +1852,10 @@ template<class CLASS_TYPE> class RegExp {
return false;
};
bool ProcessOneElement( CLASS_TYPE &SearchIn,
int32_t startPos,
int32_t endPos,
char escapeChar=0)
bool ProcessOneElement( const CLASS_TYPE& SearchIn,
int32_t startPos,
int32_t endPos,
char escapeChar=0)
{
if (false == m_isOk) {
return false;

View File

@ -18,6 +18,8 @@ namespace etk
{
class UString
{
private :
etk::Vector<uniChar_t> m_data; //!< internal data is stored in the Unicode properties ...
public:
// Constructeurs
UString(void);
@ -55,10 +57,10 @@ namespace etk
/*****************************************************
* > < >= <= operator
*****************************************************/
bool operator> (const etk::UString& etkS) const;
bool operator>= (const etk::UString& etkS) const;
bool operator< (const etk::UString& etkS) const;
bool operator<= (const etk::UString& etkS) const;
bool operator> (const etk::UString& etkS) const;
bool operator>= (const etk::UString& etkS) const;
bool operator< (const etk::UString& etkS) const;
bool operator<= (const etk::UString& etkS) const;
/*****************************************************
* += operator
*****************************************************/
@ -97,37 +99,34 @@ namespace etk
* toolbox
*****************************************************/
// Start With ...
bool StartWith(const etk::UString& data, bool caseSensitive=true) const ;
bool StartWith(const etk::UString& data, bool caseSensitive=true) const ;
// End With ...
bool EndWith(const etk::UString& data, bool caseSensitive=true) const ;
bool EndWith(const etk::UString& data, bool caseSensitive=true) const ;
// Find element
int32_t FindForward(const char data, int32_t startPos=0) const;
int32_t FindForward(const uniChar_t data, int32_t startPos=0) const;
int32_t FindBack(const char data, int32_t startPos=0x7FFFFFFF) const;
int32_t FindBack(const uniChar_t data, int32_t startPos=0x7FFFFFFF) const;
int32_t FindForward(const char data, int32_t startPos=0) const;
int32_t FindForward(const uniChar_t data, int32_t startPos=0) const;
int32_t FindBack(const char data, int32_t startPos=0x7FFFFFFF) const;
int32_t FindBack(const uniChar_t data, int32_t startPos=0x7FFFFFFF) const;
bool IsEmpty(void) const;
int32_t Size(void) const;
bool IsEmpty(void) const;
int32_t Size(void) const;
/*****************************************************
* Generic modification function
*****************************************************/
void Add(int32_t currentID, const char* inputData);
void Add(int32_t currentID, const uniChar_t* inputData);
void Add(int32_t currentID, const uniChar_t inputData);
void Remove(int32_t currentID, int32_t len);
void Clear(void);
void Add(int32_t currentID, const char* inputData);
void Add(int32_t currentID, const uniChar_t* inputData);
void Add(int32_t currentID, const uniChar_t inputData);
void Remove(int32_t currentID, int32_t len);
void Clear(void);
etk::Vector<uniChar_t> GetVector(void);
uniChar_t * pointer(void) { return &m_data[0]; };
uniChar_t* pointer(void) { return &m_data[0]; };
etk::Char c_str(void) const;
// Sting operation :
etk::UString Extract(int32_t posStart=0, int32_t posEnd=0x7FFFFFFF) const;
private :
etk::Vector<uniChar_t> m_data; //!< internal data is stored in the Unicode properties ...
};
etk::CCout& operator <<(etk::CCout &os, const etk::UString &obj);

View File

@ -58,8 +58,8 @@ namespace etk
{
// Private data :
private:
int32_t m_current; //!< curent Id on the vector
Vector<MY_TYPE> * m_vector; //!< Pointer on the curent element of the vectorBin
int32_t m_current; //!< curent Id on the vector
Vector<MY_TYPE>* m_vector; //!< Pointer on the curent element of the vectorBin
public:
/**
* @brief Basic itarator constructor with no link with an etkVector
@ -72,7 +72,7 @@ namespace etk
}
/**
* @brief Recopy constructor on a specific etkVector.
* @param[in] otherIterator The Iterator that might be copy
* @param[in] otherIterator The Iterator that might be copy
*/
Iterator(const Iterator & otherIterator):
m_current(otherIterator.m_current),
@ -82,7 +82,7 @@ namespace etk
}
/**
* @brief Asignation operator.
* @param[in] otherIterator The Iterator that might be copy
* @param[in] otherIterator The Iterator that might be copy
* @return reference on the curent Iterator
*/
Iterator& operator=(const Iterator & otherIterator)
@ -105,8 +105,8 @@ namespace etk
*/
operator bool ()
{
if( 0 <= m_current
&& m_current < m_vector->Size() )
if( 0 <= m_current
&& m_current < m_vector->Size() )
{
return true;
} else {
@ -119,8 +119,8 @@ namespace etk
*/
Iterator& operator++ ()
{
if( NULL != m_vector
&& m_current < m_vector->Size() )
if( NULL != m_vector
&& m_current < m_vector->Size() )
{
m_current++;
}
@ -176,14 +176,6 @@ namespace etk
return m_vector->Get(m_current);
}
private:
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
*/
Iterator(Vector<MY_TYPE> * obj, int32_t pos):
m_current(pos),
m_vector(obj)
@ -194,13 +186,13 @@ namespace etk
};
private:
MY_TYPE * m_data; //!< pointer on the curetn table of Data
int32_t m_size; //!< nb Element in the buffer
int32_t m_allocated; //!< Current allocated size
MY_TYPE* m_data; //!< pointer on the curetn table of Data
int32_t m_size; //!< nb Element in the buffer
int32_t m_allocated; //!< Current allocated size
public:
/**
* @brief Create an empty vector
* @param[in] count Minimum request size of the Buffer
* @param[in] count Minimum request size of the Buffer
*/
Vector(int32_t count = 0):
m_data(NULL),
@ -211,9 +203,9 @@ namespace etk
}
/**
* @brief Re-copy constructor (copy all needed data)
* @param[in] Evb Vector that might be copy
* @param[in] obj Vector that might be copy
*/
Vector(const etk::Vector<MY_TYPE> & obj)
Vector(const etk::Vector<MY_TYPE>& obj)
{
m_allocated = obj.m_allocated;
m_size = obj.m_size;
@ -260,12 +252,11 @@ namespace etk
obj.m_data = tmpData;
obj.m_allocated = tmpAllocated;
obj.m_size = tmpSize;
}
}
/**
* @brief Re-copy operator
* @param[in] Evb Vector that might be copy
* @param[in] obj Vector that might be copy
* @return reference on the curent re-copy vector
*/
Vector& operator=(const etk::Vector<MY_TYPE> & obj)
@ -297,9 +288,9 @@ namespace etk
/**
* @brief Add at the Last position of the Vector
* @param[in] item Element to add at the end of vector
* @param[in] obj Element to add at the end of vector
*/
Vector& operator+= (const etk::Vector<MY_TYPE> & obj) // += operator
Vector& operator+= (const etk::Vector<MY_TYPE> & obj)
{
int32_t nbElememt = obj.Size();
int32_t idx = m_size;
@ -319,7 +310,7 @@ namespace etk
* @brief Get the number of element in the vector
* @return The number requested
*/
int32_t Size() const
int32_t Size(void) const
{
return m_size;
}

View File

@ -56,6 +56,11 @@ def Create(target):
myModule.AddExportFlag_CC("-DDEBUG_LEVEL=3")
myModule.AddExportFlag_CC("-DDEBUG=1")
if target.name=="Windows":
None
else:
myModule.AddExportflag_LD("-lpthread")
myModule.AddExportPath(lutinTools.GetCurrentPath(__file__))