当前位置: 首页>>代码示例>>C++>>正文


C++ istream::get方法代码示例

本文整理汇总了C++中std::istream::get方法的典型用法代码示例。如果您正苦于以下问题:C++ istream::get方法的具体用法?C++ istream::get怎么用?C++ istream::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在std::istream的用法示例。


在下文中一共展示了istream::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1:

void Polynomial<T>::input(std::istream &in)
{
	T coef;
	int data;
	in.clear();
	in>>coef>>data;
	while(in.good())
	{
		operator+=(Polynomial(coef,data));
		in>>coef>>data;
	}
	in.clear();
	in.get();
}
开发者ID:AoEiuV020,项目名称:datastructure,代码行数:14,代码来源:list.cpp

示例2: isGzippedStream

/// Determine whether the given stream is gzipped.
bool RibInputBuffer::isGzippedStream(std::istream& in)
{
	bool isZipped = false;
	std::istream::int_type c = in.get();
	// Check whether the magic number matches that for a gzip stream
	const std::istream::int_type gzipMagic[] = {0x1f, 0x8b};
	if(c == gzipMagic[0])
	{
		if(in.peek() == gzipMagic[1])
			isZipped = true;
	}
	in.unget();
	return isZipped;
}
开发者ID:guiann,项目名称:GERendering,代码行数:15,代码来源:ribinputbuffer.cpp

示例3: isGzip

			static bool isGzip(std::istream & in)
			{
				int const b0 = in.get();
				
				if ( b0 < 0 )
					return false;
				
				int const b1 = in.get();
				
				if ( b1 < 0 )
				{
					in.clear();
					in.putback(b0);
					return false;
				}
				
				in.clear();
				in.putback(b1);
				in.putback(b0);
				
				return b0 == libmaus2::lz::GzipHeaderConstantsBase::ID1 &&
				       b1 == libmaus2::lz::GzipHeaderConstantsBase::ID2;
			}
开发者ID:dkj,项目名称:libmaus2,代码行数:23,代码来源:IsGzip.hpp

示例4: readUrl

void HTMLForm::readUrl(std::istream& istr)
{
	static const int eof = std::char_traits<char>::eof();

	int fields = 0;
	int ch = istr.get();
	while (ch != eof)
	{
		if (_fieldLimit > 0 && fields == _fieldLimit)
			throw HTMLFormException("Too many form fields");
		std::string name;
		std::string value;
		while (ch != eof && ch != '=' && ch != '&')
		{
			if (ch == '+') ch = ' ';
			name += (char) ch;
			ch = istr.get();
		}
		if (ch == '=')
		{
			ch = istr.get();
			while (ch != eof && ch != '&')
			{
				if (ch == '+') ch = ' ';
				value += (char) ch;
				ch = istr.get();
			}
		}
		std::string decodedName;
		std::string decodedValue;
		URI::decode(name, decodedName);
		URI::decode(value, decodedValue);
		add(decodedName, decodedValue);
		++fields;
		if (ch == '&') ch = istr.get();
	}
}
开发者ID:Chingliu,项目名称:poco,代码行数:37,代码来源:HTMLForm.cpp

示例5: readMultipart

void HTMLForm::readMultipart(std::istream& istr, PartHandler& handler)
{
	static const int eof = std::char_traits<char>::eof();

	MultipartReader reader(istr, _boundary);
	while (reader.hasNextPart())
	{
		MessageHeader header;
		reader.nextPart(header);
		std::string disp;
		NameValueCollection params;
		if (header.has("Content-Disposition"))
		{
			std::string cd = header.get("Content-Disposition");
			MessageHeader::splitParameters(cd, disp, params);
		}
		if (params.has("filename"))
		{
			handler.handlePart(header, reader.stream());
			// Ensure that the complete part has been read.
			while (reader.stream().good()) reader.stream().get();
		}
		else
		{
			std::string name = params["name"];
			std::string value;
			std::istream& istr = reader.stream();
			int ch = istr.get();
			while (ch != eof)
			{
				value += (char) ch;
				ch = istr.get();
			}
			add(name, value);
		}
	}
}
开发者ID:,项目名称:,代码行数:37,代码来源:

示例6: nextToken

void JSSPageReader::nextToken(std::istream& istr, std::string& token)
{
	token.clear();
	int ch = istr.get();
	if (ch != -1)
	{
		if (ch == '<' && istr.peek() == '%')
		{
			token += "<%";
			ch = istr.get();
			ch = istr.peek();
			switch (ch)
			{
			case '%':
			case '@':
			case '=':
				ch = istr.get();
				token += (char) ch;
				break;
			case '!':
				ch = istr.get();
				token += (char) ch;
				if (istr.peek() == '!')
				{
					ch = istr.get();
					token += (char) ch;
				}
				break;
			case '-':
				ch = istr.get();
				token += (char) ch;
				if (istr.peek() == '-')
				{
					ch = istr.get();
					token += (char) ch;
				}
				break;
			}
		}
		else if (ch == '%' && istr.peek() == '>')
		{
			token += "%>";
			ch = istr.get();
		}
		else token += (char) ch;
	}
}
开发者ID:curiousTauseef,项目名称:macchina.io,代码行数:47,代码来源:JSSPageReader.cpp

示例7: style

// style prompts for and accepts the style from input stream is
//
bool style(std::istream& is, char& s) {
	bool rc = false, ok = false;
	char c;
	do {
		std::cout << " EAN Style ('-', ' ', '\\n' or '0' to quit) : ";
		c = ' ';
		is.get(c);
		if (is.fail()) {
			is.clear();
			is.ignore(2000, '\n');
			std::cerr << " Invalid input. Try again.\n";
        } else if (c != '-' && c != ' ' && c != '\n' && c != '0') {
            is.ignore(2000, '\n');
            std::cerr << " Invalid Character.  Try again.\n";
		} else if (c == '0') {
			if (is.get() != '\n') {
				is.ignore(2000, '\n');
				std::cerr << " Trailing Characters.  Try Again.\n";
			} else {
				ok = true;
			}
		} else if (c == '\n') {
			ok = true;
			s = '\0';
			rc = true;
        } else if (is.get() != '\n') {
            is.ignore(2000, '\n');
            std::cerr << " Trailing Characters.  Try Again.\n";
        } else if (c == '-' || c == ' ') {
            ok = true;
			s = c;
			rc = true;
		}
	} while (!ok);

	return rc;
}
开发者ID:soonilhong,项目名称:CPP_EAN_Book_Order_CLI,代码行数:39,代码来源:main.cpp

示例8: configParExceptionParseError

/** returns inner content of a quoted string
 *  Matches pattern "[^"]*"\s* and returns matching part without quotes
 *
 */
std::string 
configparBase::parse_quoted_string(std::istream &in) {

	if ( in.get() != '"' )
		throw configParExceptionParseError("string doesn't start with a quotation mark");

	bool escape = false;
	std::string tmp;
	char c;

	while ( in.get(c) ) {
		if ( escape ) {
			if ( c == '\\' || c == '"' )
				tmp += c;
			else
				throw configParExceptionParseError("invalid escape sequence");

			escape = false;
		}
		else {
			if ( c == '"' )
				break;
			else if ( c == '\\' )
				escape = true;
			else
				tmp += c;
		}
	}

	// we should be on the closing quotation mark
	if ( c != '"' )
		throw configParExceptionParseError("unterminated string");

	skip_rest_of_line(in);

	return tmp;
}
开发者ID:allanborgespontes,项目名称:ReVir-UFPe,代码行数:41,代码来源:configpar.cpp

示例9: GetField

bool GetField(std::istream &is, std::string &name, std::string &value)
{
	name.resize(0);		// GCC workaround: 2.95.3 doesn't have clear()
	is >> name;
	if (name.empty())
		return false;

	if (name[name.size()-1] != ':')
		SignalTestError();
	name.erase(name.size()-1);

	while (is.peek() == ' ')
		is.ignore(1);

	// VC60 workaround: getline bug
	char buffer[128];
	value.resize(0);	// GCC workaround: 2.95.3 doesn't have clear()
	bool continueLine;

	do
	{
		do
		{
			is.get(buffer, sizeof(buffer));
			value += buffer;
		}
		while (buffer[0] != 0);
		is.clear();
		is.ignore();

		if (!value.empty() && value[value.size()-1] == '\r')
			value.resize(value.size()-1);

		if (!value.empty() && value[value.size()-1] == '\\')
		{
			value.resize(value.size()-1);
			continueLine = true;
		}
		else
			continueLine = false;

		std::string::size_type i = value.find('#');
		if (i != std::string::npos)
			value.erase(i);
	}
	while (continueLine);

	return true;
}
开发者ID:hon1nbo,项目名称:BCTt,代码行数:49,代码来源:datatest.cpp

示例10: if

// Parses a string serialized by serializeJsonStringIfNeeded.
static std::string deSerializeJsonStringIfNeeded(std::istream &is)
{
	std::ostringstream tmp_os;
	bool expect_initial_quote = true;
	bool is_json = false;
	bool was_backslash = false;
	for(;;)
	{
		char c = is.get();
		if(is.eof())
			break;
		if(expect_initial_quote && c == '"')
		{
			tmp_os << c;
			is_json = true;
		}
		else if(is_json)
		{
			tmp_os << c;
			if(was_backslash)
				was_backslash = false;
			else if(c == '\\')
				was_backslash = true;
			else if(c == '"')
				break; // Found end of string
		}
		else
		{
			if(c == ' ')
			{
				// Found end of word
				is.unget();
				break;
			}
			else
			{
				tmp_os << c;
			}
		}
		expect_initial_quote = false;
	}
	if(is_json)
	{
		std::istringstream tmp_is(tmp_os.str(), std::ios::binary);
		return deSerializeJsonString(tmp_is);
	}
	else
		return tmp_os.str();
}
开发者ID:JakubVanek,项目名称:minetest,代码行数:50,代码来源:inventory.cpp

示例11:

static std::string goto_first_of(std::istream& s, const std::string& str)
{
	std::string result;
	char c;
	while (s.get(c))
	{
		if (str.find(c) != std::string::npos)
		{
			break;
		}
		result += c;
	}
	
	return result;
}
开发者ID:ChristianFrisson,项目名称:gephex,代码行数:15,代码来源:streamtokenizer.cpp

示例12: read_with_limit

        void read_with_limit(
            std::istream& in, 
            std::string& buffer, 
            int delim = '\n'
        ) 
        {
            using namespace std;
            const size_t max = 16*1024;
            buffer.clear();
            buffer.reserve(300);

            while (in.peek() != delim && in.peek() != EOF && buffer.size() < max)
            {
                buffer += (char)in.get();
            }

            // if we quit the loop because the data is longer than expected or we hit EOF
            if (in.peek() == EOF || buffer.size() == max)
                throw http_parse_error("HTTP field from client is too long", 414);

            // Make sure the last char is the delim.
            if (in.get() != delim) 
            {
                in.setstate(ios::badbit);
                buffer.clear();
            } 
            else 
            {
                // Read the remaining delimiters
                if (delim == ' ') 
                {
                    while (in.peek() == ' ')
                        in.get();
                }
            }
        }
开发者ID:Andy0898,项目名称:Project_Isagoge,代码行数:36,代码来源:server_http.cpp

示例13: readHuffmanHeader

std::map<char, long long> readHuffmanHeader(std::istream &inFile, int *validBitsLastByte) {
	long long length, frequency;
	char space, character, space2, algorithm;
	map<char, long long> char_freq;
	inFile >> skipws;
	inFile >> (*validBitsLastByte);
	if (DEBUG) cout << " + validBitsLastByte: " << *validBitsLastByte <<endl;
	inFile >> length;
	if (DEBUG) cout << " + length: " << length << endl;

	inFile.get(space);
	if (DEBUG) cout << " - It was suppose to be a space: [" << space << "]\n";

	for (int i = 0; i < length; i++) {
		inFile.get(character);
		inFile.get(space);
		inFile >> frequency;
		inFile.get(space2);
		if (DEBUG) cout << "character: " << character << ", space: "<< space << ", frequency: "<< frequency << ", space2: " << space2 <<endl;
		if (DEBUG) cout << "char_freq["<<character<<"] : " << frequency << endl;
		char_freq[character] = frequency;
	}
	return char_freq;
}
开发者ID:CarH,项目名称:Compression,代码行数:24,代码来源:huffman.cpp

示例14:

void
PinConfigInfoPacket::read(
        std::istream& inputStream
        )
{
    int pin;
    int direction;

    pin = inputStream.get();
    if (inputStream.good() != true)
    {
        return;
    }
    myPin = (unsigned int)pin;

    direction = inputStream.get();
    if (inputStream.good() != true)
    {
        return;
    }
    myDirection = ((direction == 1) ? DIR_OUTPUT : DIR_INPUT);

    inputStream.get();
}
开发者ID:barracuda1994,项目名称:wpirb,代码行数:24,代码来源:ConfigurableInterface.cpp

示例15: putback_test_one

bool putback_test_one(std::istream& is)
{
    try {
        do {
            char buf[chunk_size];
            is.read(buf, chunk_size);
            if (is.gcount() < static_cast<std::streamsize>(chunk_size))
                break;
            is.putback('a');
            if (is.get() != 'a')
                return false;
        } while (!is.eof());
        return true;
    } catch (std::exception&) { return false; }
}
开发者ID:LancelotGHX,项目名称:Simula,代码行数:15,代码来源:putback_test.hpp


注:本文中的std::istream::get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。