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


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

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


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

示例1: getString

string SceneLoader::getString(istream &str)
{
    string ret;
    char temp;
    str >> temp; // get rid of white space, get to first char
    str.putback(temp);
    while (str.get(temp))
    {
        if (temp >= 'a' && temp <= 'z'
                || temp >= 'A' && temp <= 'Z'
                || temp >= '0' && temp <= '9'
                || temp == '_' )
        {
            ret += temp;
        }
        else if (temp == '#')
        {
            string no;
            getline(str, no);
            if (ret.empty())
                return getString(str);
            else
                return ret;
        }
        else {
            str.putback(temp);
            break;
        }
    }

    return ret;
}
开发者ID:therichardnguyen,项目名称:-CS184-AS5,代码行数:32,代码来源:SceneLoader.cpp

示例2: ReadNumber

XFileToken XFileToken::ReadNumber(istream& s)
{
	XFileToken result;
	result.m_type = Integer;
	char c;
	s.get(c);
	result.m_content.push_back(c);
	while (s.get(c))
	{
		if (c == '.')
		{
			if (result.m_type == Integer)
				result.m_type = Float;
			else
			{
				s.putback(c);
				return result;
			}
		}
		else if (!isdigit(c))
		{
			s.putback(c);
			return result;
		}
		result.m_content.push_back(c);
	}
	return result;
}
开发者ID:kamillys,项目名称:IN_SDL_Demo,代码行数:28,代码来源:mini_xfileToken.cpp

示例3: input

//-----------------------------------------------------------------------------
//    Class:			CTime
//	  Method:			void CTime::input(istream& sin)
//	  Description:		input method for CTime objects
//	  Input:			sin
//    Called By:		constructor from DateTime/CTime, mutators, saferead
//    Parameters:		istream& sin - input istream
//    Returns:          n/a
//    History Log:
//                      4/29/15  KG  completed version 1.0
// ----------------------------------------------------------------------------
	void CTime::input(istream& sin)
	{
		int hour = 0;
		int minute = 0;
		int second = 0;
		m_hour = hour;
		m_second = second;
		m_minute = minute;
		char c = ' ';
		sin.get(c);
		if(c == '\n') //checks for no input if datetime
		{
			sin.putback(c);
			return;
		}
		sin.putback(c); //puts back character if normal input
		if(sin >> hour)
		{
			if(hour > MINTIME && hour <= MAXHOUR)
				m_hour = hour;
			sin.get(c);
			if(c == '\n')
			{
				sin.putback(c);
				return;
			}
			if(c == ':')
			{
				if(sin >> minute)
				{
					if(minute > MINTIME && minute < MAXMINSEC)
					{
						m_minute = minute;
					}
					sin.get(c);
					if(c == '\n')
					{
						sin.putback(c);
						return;
					}
					if(c == ':')
					{
						if(sin >> second)
						{
							if(second > MINTIME && second < MAXMINSEC)
							{
								m_second = second;
							}
						}
					}
					else
						sin.setstate(std::ios::failbit);
				}
			}
			else
开发者ID:KyleGraham,项目名称:CS133,代码行数:66,代码来源:CTime.cpp

示例4: _check_idlabel_title

bool _check_idlabel_title(istream &s, string &title)
{
    title.clear();
    if (!s.good())
        return false;
    bool hv = false;
    while (1)
    {
        string line0;
        getline(s, line0);
        if (!allSpace(line0))
        {
            string line = removeLeadSpace2(line0);
            if (line.length() <= 1 || !(
                        (line.front() == '"' && line.back() == '"')
                        || (line.front() == '\'' && line.back() == '\'')
                        || (line.front() == '(' && line.back() == ')')
                    ))
            {
                if (!s.eof())
                    s.putback('\n');
                s.clear();
                strputback(s, line0);
                return hv;
            }
            title = line.substr(1, line.length() - 2);
            return true;
        }
        if (s.eof() || hv)
            break;
        hv = true;
    }
    return true;
}
开发者ID:liangjs,项目名称:marktex,代码行数:34,代码来源:idlabel.cpp

示例5: while

bool
// 
// Extracts the next word from the input stream. This function has the same
// functionality as "cin >> word", excepts it additionally makes sure that
// the word buffer is not over-run!
//
getWord(istream& in, string& word)
{
    int  i = 0;
    char ch;
    word = "";

    while(in.get(ch))
    {
        if(!isspace(ch)) {
            if(i > MAX_WORDLEN) {
                in.putback(ch);
                break;
            } else {
                word += ch;
                i++;
            }
        }
        else {
            break;
        }
    }
        
    if (i > 0) 
        return true;
    else
        return false;
}
开发者ID:cyrus,项目名称:high-dimensional-explorer,代码行数:33,代码来源:utilities.cpp

示例6: predicate_scan_token

string predicate_scan_token ( istream & is, scan_token_predicate & prd )
{
	char ch = '\0';
	string res = "";
	
	do {  // eat whitespaces ...
		ch = is.get();
	} while ( isspace( ch ) );
	
	for( bool longString = false;; ch = is.get() )
	{
		if( ch == DOUBLE_L )
		{
			if( longString )
				break;
			else
				longString = true;
		}
		else if( longString )
			res += ch;
		else if( prd.check( ch ) )
		{
			if( res.size() )
				is.putback( ch );
			else
				res += ch;
			break;
		}
		else
			res += ch;
	}
	
	return res;
}
开发者ID:o-peregudov,项目名称:libcrs,代码行数:34,代码来源:parsing.cpp

示例7: SkipComments

bool XFileToken::SkipComments(istream& s)
{
	char c;
	SkipWS(s);
	while (s.get(c))
	{
		if (c == '/')
		{
            if (!s.get(c))
                THROW_EXCEPTION_T("Parsing error", ParsingException);
            if (c != '/')
                THROW_EXCEPTION_T("Parsing error", ParsingException);
		}
		else if (c != '#')
		{
			s.putback(c);
			return true;
		}
		while (s.get(c))
		{
			if (c == '\n')
				break;
		}
		SkipWS(s);
	}
	return false;
}
开发者ID:kamillys,项目名称:IN_SDL_Demo,代码行数:27,代码来源:mini_xfileToken.cpp

示例8: scan_pgn

int ChessIO::scan_pgn(istream &game_file, vector<string> &contents)
{
    Board board;
    int c;

    while (game_file.good() && !game_file.eof())
    {
        // Collect the header:
        long first;
        vector<Header> hdrs;
        string eventStr;
        collect_headers(game_file, hdrs, first);
        if (get_header(hdrs,"Event",eventStr))
        {
           // We have the headers, munge them into a single-line game
           // description. Append the index to the game so the GUI
           // can navigate to the game when the user clicks on the
           // description.
           string descr;
           get_game_description(hdrs, descr, first);
           contents.push_back(descr);
        }
        hdrs.clear();

        while (game_file.good() && !game_file.eof())
        {
           if ((c = game_file.get()) == '[')
           {
               game_file.putback(c);
               break;
           }
        }
    }
    return 1;
}
开发者ID:jdart1,项目名称:arasan-chess,代码行数:35,代码来源:chessio.cpp

示例9: eof

bool eof(istream& in)
{
   char ch;
   in >> ch;
   in.putback(ch);
   return !in;
}
开发者ID:garura,项目名称:myString,代码行数:7,代码来源:client.cpp

示例10: read_header

void read_header(istream& fin, ostream& fout, int& width, int& height, int& max)
{
    char header[100];
    char ch;
    
    //  Getmage=ic number
    fin.getline(header,100);
    
    //  write magic number
    fout << header <<endl;
    cout << header << endl;
    
    //  get all comment lines and write to new file
    fin >> ch;
    while (ch == '#')
    {
        fin.getline(header, 100);
        fout <<ch << header << endl;
        cout <<ch << header << endl;
        fin >> ch;
    }
    fin.putback(ch);
    
    //  Input width and height of image
    fin >> width >> height;
    cout << width <<" " << height << endl;
    fout << width <<" " << height << endl;
    
    //  Input maximum color value
    fin >> max;
    cout << max << endl;
    fout << max << endl;
    return;
}
开发者ID:TheHimanshu,项目名称:Image-Smoothing,代码行数:34,代码来源:smooth_pixel.cpp

示例11: FromStream

void CL_TimeOfDay::FromStream (istream& s)
{
    CL_String rep;
    char c;
    long count = 0;
    char fill_char = s.fill ();
    
    while (s.get (c) && c == fill_char);
    if (!s.good() || s.eof()) {
        _numSecs = 0;
        return;
    }
    do {
        if (isalnum (c) || c == ':') {
            rep.Append (c);
            count++;
        }
        else
            break;
    } while (s.get (c));

    long n = ParseAndConvert (rep);
    if (n > 0) {
        if (!s.eof())
            s.putback (c);
        _numSecs = n;
    }
    else {
        s.seekg (s.tellg() - count, istream::cur);
        _numSecs = 0;
    }
}
开发者ID:ABratovic,项目名称:open-watcom-v2,代码行数:32,代码来源:timeofda.cpp

示例12: skipspace

/******************************************************************************************
		
			void skipspace(istream& in)

Description:
	This function reads past all whitespace (ie. ' ' and '/t').

Parameters:
	istream& in			-input stream being read

******************************************************************************************/
void skipspace(istream& in)
{
  char ch;
  in.get(ch);
  while ((ch ==' ') ||(ch =='\t'))
    in.get(ch);
  in.putback(ch);
}
开发者ID:guenhae,项目名称:Orbit,代码行数:19,代码来源:functios.cpp

示例13: seek_eoln

int seek_eoln(istream &i)
  {
   char ch=' ';
   int ret=0;
   while ( (i) && (ch==' ') ) i.get(ch);
   if (ch=='\n') ret=1;
   else if (i) i.putback(ch);
   if (!i) ret=1;
   return ret;
  };
开发者ID:pyal,项目名称:eos_cpp,代码行数:10,代码来源:ORD_TYP.CPP

示例14: seek_eof

int seek_eof(istream &i)
  {
   char ch=' ';
   int ret=0;
   while ( (i) && ((ch==' ') || (ch=='\n')) ) i.get(ch);
//   if (ch==0) return 1;
   if (i) { i.putback(ch);}
   if (!i) ret=1;
   return ret;
  };
开发者ID:pyal,项目名称:eos_cpp,代码行数:10,代码来源:ORD_TYP.CPP

示例15: putback

// Put a string back into an istream
void a::putback(istream &in, const string &s) {
  if (s.length()==0)
    return;
  unsigned i=unsigned(s.length())-1;
  while (true) {
    in.putback(s[i]);
    if (i==0)
      return;
    i--;
  }
}
开发者ID:behollis,项目名称:muViewBranch,代码行数:12,代码来源:misc.cpp


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