#include "extract.h"
#include <cstring>

namespace proctools
{

	using namespace std;

	extract::extract(const string& value)
	{
		m_parser << value;
	}
	
	extract& extract::operator>>(const char* literal)
	{
		if (m_parser.good()) {
			int len = strlen(literal);
			char buffer[len];
#ifdef STONEAGE_GCC
			m_parser.read(buffer, len);
			std::string text(buffer, len);
#else
			int count = m_parser.readsome(buffer, len);
			std::string text(buffer, count);
#endif
			if (text != literal)
				m_parser.setstate(std::ios::failbit);
		}
		return *this;
	}

}
