File: string.hh

package info (click to toggle)
abacus 0.9.13-4
  • links: PTS
  • area: main
  • in suites: potato
  • size: 6,308 kB
  • ctags: 5,120
  • sloc: ansic: 27,540; cpp: 11,426; tcl: 7,564; makefile: 386; yacc: 327; lex: 265; sh: 221
file content (96 lines) | stat: -rw-r--r-- 2,330 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
// $Header: /usr/local/src/debian-packages/abacus-0.9.13/include/RCS/string.hh,v 1.2 1996/01/02 16:22:09 aml Exp fred $
/**************************************************************

Program: SMOG - Selection of Minimal Ordered Graphs

Author: Arlindo Oliveira (aml@ic.eecs.berkeley.edu)

Copyright 1994 University of California Berkeley / CAD Group

This software may not be distributed without 
permission of the copyright holder.


****************************************************************/

#ifndef _STRING_DOT_HH_
#define _STRING_DOT_HH_

#include "string.h"
#include "utils.hh"

class string {
  public:
    char *ptr;
    string(int n) {
        ptr = new char[n];
    }
    string() {
        ptr = NULL;
    }
    string(char *st) {
        int size = strlen(st)+1;
        ptr = new char[size];
        strcpy(ptr,st);
    }
    ~string(){
        delete [] ptr;
    }
    operator char*() {return(ptr);}
    void operator+=(const string &right) {
        char *ax;

        ax = ptr;

        int size = strlen(ptr)+strlen(right.ptr)+2;
        ptr = new char[size];

        strcpy(ptr,ax);
        strcat(ptr,right.ptr);    
        delete [] ax;
    }
    void operator=(const string &right) {
        delete [] ptr;
        if (right.ptr != NULL) {
            ptr = new char[strlen(right.ptr)+1];
            strcpy(ptr,right.ptr);
        }
        else ptr = right.ptr;
    }
    int operator==(const string &right) {
      return
        strcmp(ptr,right.ptr) != 0 ? 0 : 1;
    }
    int operator!=(const string &right) {
      return
        strcmp(ptr,right.ptr) != 0 ? 1 : 0;
    }
    string(const string &right) {
        ptr = new char[strlen(right.ptr)+1];
        strcpy(ptr,right.ptr);
    }
    int len() {
        return(strlen(ptr));
    }
    char &operator[](int i) {
        return(ptr[i]);
    }
friend ostream &operator<<(ostream &s, string &st) ;
};

#endif // _STRING_DOT_HH_

// $Log: string.hh,v $
// Revision 1.2  1996/01/02 16:22:09  aml
// Formula compilation, evaluation and decompilation now work.
// Cells can be of type label, numerical formula or numbers.
//
//Revision 1.1  1995/12/30  14:53:29  aml
//Initial revision
//
//Revision 1.2  1994/09/10  16:04:16  aml
//Made changes to compile on hp.
//
//Revision 1.1  94/09/08  00:01:34  00:01:34  aml
//Initial revision
//