/*
 *
 *   bufcpy.h
 *
 *   Utility functions to quickly move date between std::queue's and raw byte arrays
 *
 */

#include "bufcpy.h"

void my::bufcpy (std::queue<unsigned char> &dst, const unsigned char *src, size_t len) {
	for (const unsigned char *cp = src; cp != (src + len); ++cp)
		dst.push(*cp);
}

void my::bufcpy (unsigned char *dst, std::queue<unsigned char> &src, size_t len) {
	for (unsigned char *cp = dst; cp != (dst + len); ++cp) {
		*cp = src.front();
		src.pop();
	}
}

void my::bufcpy (std::queue<unsigned char> &dst, const std::string &src) {
	for (std::string::const_iterator i = src.begin(); i != src.end(); ++i)
		dst.push(*i);
}

void my::bufcpy (std::string &dst, std::queue<unsigned char> &src) {
	dst.erase();
	while( ! src.empty()) {
		dst += src.front();
		src.pop();
	}
}

