From aadaa8b5d7eda23e72dbded9d6437b40358353f3 Mon Sep 17 00:00:00 2001 From: Michael Krelin Date: Sun, 08 Mar 2009 20:09:21 +0000 Subject: Inital commit to public repository --- (limited to 'src/eyetil.cc') diff --git a/src/eyetil.cc b/src/eyetil.cc new file mode 100644 index 0000000..d00c2ee --- a/dev/null +++ b/src/eyetil.cc @@ -0,0 +1,103 @@ +#include +#include +#include +#include +#include +#include +#include "eyetil.h" + +binary_t& binary_t::from_hex(const std::string& h) { + /* TODO: algorithmize */ + std::string::size_type hs = h.length(); + if(hs&1) + throw std::runtime_error("odd number of characters in hexadecimal number"); + int rvs = hs>>1; + resize(rvs); + const unsigned char *hp = (const unsigned char*)h.data(); + iterator oi=begin(); + char t[3] = { 0,0,0 }; + for(int i=0;i