File: oidseq.h

package info (click to toggle)
npadmin 0.8-2
  • links: PTS
  • area: main
  • in suites: potato
  • size: 524 kB
  • ctags: 792
  • sloc: cpp: 3,514; ansic: 1,176; sh: 327; makefile: 52
file content (64 lines) | stat: -rw-r--r-- 1,667 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
#ifndef __OIDSEQ_H__
#define __OIDSEQ_H__

#include <string.h>

#include "ber.h"

struct TableEntry;

class Assoc{
 public:
  char *str;
  BerOid *oid;
  
  Assoc *next;
  
  Assoc(const char *oidstr,Assoc *nxt);
  Assoc(const char *oidstr,BerOid *oid,Assoc *nxt);
  inline ~Assoc(){ delete str;}

  inline int operator==(const char *oidstr){ return !strcmp(oidstr,str);}
};


class OidSeq {
  BerSequence *seq;
  Assoc *index;

public:
  // converts a list of strings with the ascii representation of oids into
  // an OidSeq. The strings that are passed in are duplicated so that 
  // there is no confusion as to who should delete them.
  inline OidSeq():seq(NULL),index(NULL){}
  OidSeq(unsigned int num...); 
  OidSeq(BerSequence *valseq); // takes ownership of valseq
  //just grabs the oidstrs out of the table doesn't modify the table
  OidSeq(TableEntry *table); 
  ~OidSeq();

  //for gets
  void append(const char *oidstr);

  //for sets of ints and counters.
  void append(const char *oidstr,Tags type, long data);

  //for sets of strings oid's and ipaddrs
  void append(CONST char *oidstr,Tags type, void *data, unsigned int len);

  void remove(const char *oidstr);

  // returns the pointer to the value (keeps ownership)
  BerBase *value(const char* oid); 
  BerBase *value(BerOid &oid);
  // returns the pointer to the value of the child whose oid this is
  BerBase *child(const char *oid);
  // returns the pointer to the beroid who was created with this ascii 
  //version of the oid
  BerOid *key(const char *oid);

  inline int print(char* str,unsigned int len){ return seq->print(str,len);}
  inline BerSequence *Seq(){ return seq;}
};

#endif