File: CmdFile.hh

package info (click to toggle)
gri 2.4.2-1
  • links: PTS
  • area: main
  • in suites: potato
  • size: 4,540 kB
  • ctags: 1,966
  • sloc: cpp: 32,542; lisp: 3,243; perl: 806; makefile: 548; sh: 253
file content (55 lines) | stat: -rw-r--r-- 1,333 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// Object for command files
#if !defined(_CmdFile_hh_)
#define _CmdFile_hh_
#include <string.h>
#include <stdio.h>
#include "types.hh"
#include "macro.hh"

class CmdFile
{
public:
    CmdFile() {
	name = new char[1];
	if (!name) OUT_OF_MEMORY;
	strcpy(name, "");
	fp = NULL;		// for now anyway
	interactive = true;
	line = 0;
    }
    CmdFile(const CmdFile& c) {
	name = new char[1 + strlen(c.get_name())];
	if (!name) OUT_OF_MEMORY;
	strcpy(name, c.get_name());
	fp = c.get_fp();
	interactive = c.get_interactive();
	line = c.get_line();
    }
    ~CmdFile() {delete [] name;}
    CmdFile& operator=(const CmdFile& c) {
	COPY_STRING(name, c.get_name());
	fp = c.get_fp();
	interactive = c.get_interactive();
	line = c.get_line();
	return *this;
    }
    void set(const char *n, FILE *f, bool i, int l) {
	COPY_STRING(name, n);
	fp = f;
	interactive = i;
	line = l;
    }
    void increment_line()               {line++;}

    const char *get_name() const        {return name;}
    char *get_name()                    {return name;}
    FILE *get_fp()         const        {return fp;}
    bool get_interactive() const        {return interactive;}
    int  get_line()        const        {return line;}
private:
    char           *name;
    FILE           *fp;
    bool            interactive;
    int             line;
};
#endif