87 if (!filenm || filenm[0] ==
'\0') {
92 std::ifstream* ifs =
new std::ifstream;
108 if (!filenm || filenm[0] ==
'\0') {
113 std::ofstream* ofs =
new std::ofstream;
129 if (s != &std::cin) {
138 if (s != &std::cout) {
147 if (s != &std::cin && s != &std::cout) {
158 fs.open(filenm, ios::in);
159 if (!fs.is_open() || fs.fail()) {
160 DIAG_Throw(
"Cannot open file '" << filenm <<
"'");
170 fs.open(filenm, ios::out | ios::trunc);
171 if (!fs.is_open() || fs.fail()) {
172 DIAG_Throw(
"Cannot open file '" << filenm <<
"'");
185 Get(std::istream& is,
char end)
187 static const int bufSz = 256;
188 static char buf[bufSz];
191 while ( (!is.eof() && !is.fail()) && is.peek() != end) {
192 is.get(buf, bufSz, end);
203 std::string str =
Get(is, end);
210 Skip(std::istream& is,
const char* s)
214 for (
int i = 0; s[i] !=
'\0'; i++) {
216 if (c != s[i]) {
return false; }
void CloseStream(std::istream *s)
std::istream * OpenIStream(const char *filenm)
std::ostream * OpenOStream(const char *filenm)
void OpenOFile(std::ofstream &fs, const char *filenm)
bool Skip(std::istream &is, const char *s)
std::string GetLine(std::istream &is, char end)
std::string Get(std::istream &is, char end)
void CloseFile(std::fstream &fs)
const char * DIAG_UnexpectedInput
void OpenIFile(std::ifstream &fs, const char *filenm)