|
Boost : |
Subject: [boost] gsoc project(checks) plain
From: Àëåêñàíäð (daywalker_at_[hidden])
Date: 2011-03-31 08:28:42
In case there is a problem with sending zipped files i just list my
code here(with no tests or docs,just hpp):
#ifndef BOOST_CHECKSUM_HPP
#define BOOST_CHECKSUM_HPP
#include <boost/cstdint.hpp>
#include <vector>
namespace boost {
typedef boost::uint8_t byte;
class checksum {
public:
checksum();
checksum(const checksum&);
checksum(const std::vector<byte>&);
void process();
void put_data(const std::vector<byte>&);
byte get_sum() const;
bool proceeded() const;
private:
byte sum;
std::vector<byte> in_data;
bool done;
};//boost::checksum
inline checksum::checksum() : sum(0), done(false)
{
}
inline checksum::checksum(const boost::checksum &cs)
{
sum=cs.sum;
done=cs.done;
in_data=cs.in_data;
}
inline checksum::checksum(const std::vector<byte> &_in_data) : sum(0), done(false), in_data(_in_data)
{
}
inline void checksum::process()
{
if (!done) {
uint8_t temp_sum=0;
for (std::vector<byte>::const_iterator it=in_data.begin();it<in_data.end();it++)
temp_sum+=*it;
sum=temp_sum;
done=true;
}
}
inline void checksum::put_data(const std::vector<byte> &_in_data) {
if (in_data!=_in_data) {
in_data=_in_data;
done=false;
}
}
inline byte checksum::get_sum() const
{
return sum;
}
inline bool checksum::proceeded() const
{
return done;
}
} //namespace boost
#endif // BOOST_CHECKSUM_HPP
-- Alexandr mailto:daywalker_at_[hidden]
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk