// Copyright 1996
// College of Computer Science
// Northeastern University Boston MA 02115

// This software may be used for educational purposes as long as this copyright
// notice is retained at the top of all files

// Should this software be modified, the words "Modified from Original" must be
// included as a comment below this notice

// All publication rights are retained.  This software or its documentation may
// not be published in any media either in whole or in part.

///////////////////////////////////////////////////////////////////////////////

// IOHelp.h
// This file contains help routines to utilize stream input directly

///////////////////////////////////////////////////////////////////////////////

#ifndef IOHELP_H_
#define IOHELP_H_

#include "CHeaders.h"


// test if a character is the start of decimal number

inline bool BeginsNumber(int c) {
	if	(isdigit(c)		// decimal digit
	  || (c == '+')		// + sign
	  || (c == '-')		// - sign
	  || (c == '.'))	// decimal point
			return true;
	
	return false;
}


// skip across data in an input stream until a number is reached
// quit on EOF

inline void SkipToNumber(istream& is) {
	int c;
	
	while (true) {
		// peek ahead to next char in stream
		c = is.peek();
		
		// return if found start of number or hit EOF
		if (BeginsNumber(c) || (c == EOF))
			return;
		
		// read next char if it does not start number
		c = is.get();
	}
}


# endif // IOHELP_H_
