~vcs-imports/openbabel/trunk

« back to all changes in this revision

Viewing changes to oeifstream.h

  • Committer: ghutchis
  • Date: 2001-11-27 18:50:36 UTC
  • Revision ID: svn-v4:86f38270-e075-4da6-bf68-7dcd545c500b:openbabel/trunk:46
Initial revision

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**********************************************************************
 
2
Copyright (C) 1998-2001 by OpenEye Scientific Software, Inc.
 
3
 
 
4
This program is free software; you can redistribute it and/or modify
 
5
it under the terms of the GNU General Public License as published by
 
6
the Free Software Foundation version 2 of the License.
 
7
 
 
8
This program is distributed in the hope that it will be useful,
 
9
but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
GNU General Public License for more details.
 
12
***********************************************************************/
 
13
 
 
14
#ifndef OEIFSTREAM_H
 
15
#define OEIFSTREAM_H
 
16
 
 
17
#ifdef __sgi
 
18
#include <iostream.h>
 
19
#include <fstream.h>
 
20
#else
 
21
#include <iostream>
 
22
#include <fstream>
 
23
#endif
 
24
 
 
25
class oeifstream : public ifstream
 
26
{
 
27
public:
 
28
  bool SafeGetline(char *buffer,int size)
 
29
  {
 
30
    if (!getline(buffer,size)) return(false);
 
31
 
 
32
      char badchar1 = '\015';
 
33
      char badchar2 = '\032';
 
34
 
 
35
      char *p1,*p2;
 
36
 
 
37
      for (p1 = p2 = buffer;*p2 != '\0';)
 
38
        {
 
39
          if (*p2 == badchar1 || *p2 == badchar2)
 
40
            {
 
41
              *p1 = '\0';
 
42
              p2++; continue;
 
43
            }
 
44
          *p1++ = *p2++;
 
45
        }
 
46
 
 
47
      return(true);
 
48
    }
 
49
};
 
50
 
 
51
#endif //OEIFSTREAM_H