OpenCores
URL https://opencores.org/ocsvn/thor/thor/trunk

Subversion Repositories thor

[/] [thor/] [trunk/] [FT64v5/] [software/] [AS64/] [source/] [NameTable.h] - Blame information for rev 48

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 48 robfinch
#ifndef NAMETABLE_H
2
#define NAMETABLE_H
3
 
4
public class NameTable {
5
    char text[100000];
6
    int length;
7
 
8
    NameTable() {
9
        text[0] = 0;
10
        length = 1;
11
    };
12
 
13
    char *GetName(int ndx) {
14
         return &text[ndx];
15
    };
16
 
17
    int FindName(char *nm) {
18
        int nn, mm;
19
 
20
        for (nn = 0; nn < length; nn++) {
21
            if (text[nn] == nm[0]) {
22
                for(mm = 1; nm[mm] == text[nn+mm] && nm[mm]; mm++);
23
                if (nm[mm]=='\0')
24
                   return nn;
25
            }
26
        }
27
        return -1;
28
    };
29
 
30
    int AddName(char *nm) {
31
        int reg;
32
        int olen;
33
 
34
        if ((ret = FindName(nm)) > 0)
35
           return ret;
36
        olen = length;
37
        strcpy(&text[length], nm);
38
        length += strlen(nm) + 1;
39
        return olen;
40
    };
41
 
42
    void write(FILE *fp) {
43
         fwrite((void *)text, 1, length, fp);
44
    };
45
};
46
 
47
#endif

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.