56 lines
1.0 KiB
C++
56 lines
1.0 KiB
C++
/*
|
||
* CompareParams.hh
|
||
*
|
||
* Created on: 23 янв. 2022 г.
|
||
* Author: sozonov
|
||
*/
|
||
|
||
#ifndef UMLIBRARY_SYSTEMIC_COMPAREPARAMS_HH_
|
||
#define UMLIBRARY_SYSTEMIC_COMPAREPARAMS_HH_
|
||
|
||
#include <utility>
|
||
#include <cstring>
|
||
|
||
namespace systemic {
|
||
|
||
class CompareParams {
|
||
public:
|
||
typedef std::pair< char *, std::size_t > params_t;
|
||
|
||
CompareParams( params_t _first, params_t _second ) :
|
||
first_param( _first ), second_param( _second ), is_equal(false) {}
|
||
|
||
void compare() {
|
||
|
||
bool equal_size = first_param.second == second_param.second;
|
||
bool equal_data;
|
||
|
||
if( equal_size ) {
|
||
|
||
bool data_not_equal = std::memcmp(first_param.first, second_param.first, first_param.second);
|
||
equal_data = not data_not_equal;
|
||
|
||
}
|
||
|
||
is_equal = equal_size and equal_data;
|
||
|
||
}
|
||
|
||
const bool & state() { return is_equal; }
|
||
|
||
private:
|
||
|
||
params_t first_param;
|
||
params_t second_param;
|
||
|
||
bool is_equal;
|
||
|
||
};
|
||
|
||
|
||
|
||
} // namespace systemic
|
||
|
||
|
||
#endif /* UMLIBRARY_SYSTEMIC_COMPAREPARAMS_HH_ */
|