My Project
Public Member Functions | Private Attributes
LinTree::LinTree Class Reference

#include <lintree.h>

Public Member Functions

 LinTree ()
 
 LinTree (const LinTree &other)
 
 ~LinTree ()
 
 LinTree (std::string &source)
 
LinTreeoperator= (const LinTree &other)
 
void rewind ()
 
void clear ()
 
void mark_error (const char *s)
 
int has_error ()
 
const char * error_msg ()
 
template<typename T >
T get ()
 
template<typename T >
T get_prev ()
 
template<typename T >
void put (T data)
 
template<typename T >
void skip ()
 
int get_int ()
 
size_t get_size ()
 
void put_int (int code)
 
void skip_int ()
 
const char * get_bytes (size_t n)
 
const char * get_addr ()
 
void put_bytes (char *p, size_t n)
 
char * reserve_bytes (size_t n)
 
void put_cstring (char *p)
 
const char * get_cstring ()
 
void skip_cstring ()
 
void skip_bytes (size_t n)
 
std::stringto_string ()
 
void set_last_ring (void *r)
 
int has_last_ring ()
 
void * get_last_ring ()
 

Private Attributes

std::stringmemory
 
size_t cursor
 
const char * error
 
void * last_ring
 

Detailed Description

Definition at line 24 of file lintree.h.

Constructor & Destructor Documentation

◆ LinTree() [1/3]

LinTree::LinTree::LinTree ( )

Definition at line 882 of file lintree.cc.

882 : cursor(0), memory(*new string()), error(NULL), last_ring(NULL) {
883}
void * last_ring
Definition: lintree.h:29
const char * error
Definition: lintree.h:28
std::string & memory
Definition: lintree.h:26
size_t cursor
Definition: lintree.h:27
#define NULL
Definition: omList.c:12

◆ LinTree() [2/3]

LinTree::LinTree::LinTree ( const LinTree other)

Definition at line 885 of file lintree.cc.

885 : cursor(0), memory(*new string(other.memory)), error(NULL), last_ring(NULL) {
886}

◆ ~LinTree()

LinTree::LinTree::~LinTree ( )

Definition at line 907 of file lintree.cc.

907 {
908 if (last_ring)
909 rKill((ring) last_ring);
910}
void rKill(ring r)
Definition: ipshell.cc:6180

◆ LinTree() [3/3]

LinTree::LinTree::LinTree ( std::string source)

Definition at line 896 of file lintree.cc.

896 :
897 cursor(0), memory(*new string(source)), error(NULL), last_ring(NULL) {
898}

Member Function Documentation

◆ clear()

void LinTree::LinTree::clear ( )
inline

Definition at line 37 of file lintree.h.

37{ memory.clear(); cursor = 0; error = NULL; last_ring = NULL; }

◆ error_msg()

const char * LinTree::LinTree::error_msg ( )
inline

Definition at line 44 of file lintree.h.

44 {
45 return error;
46 }

◆ get()

template<typename T >
T LinTree::LinTree::get ( )
inline

Definition at line 48 of file lintree.h.

48 {
49 T result;
50 memcpy(&result, memory.c_str() + cursor, sizeof(T));
51 cursor += sizeof(T);
52 return result;
53 }
return result
Definition: facAbsBiFact.cc:75
STATIC_VAR jList * T
Definition: janet.cc:30

◆ get_addr()

const char * LinTree::LinTree::get_addr ( )
inline

Definition at line 85 of file lintree.h.

85 {
86 return memory.c_str() + cursor;
87 }

◆ get_bytes()

const char * LinTree::LinTree::get_bytes ( size_t  n)
inline

Definition at line 80 of file lintree.h.

80 {
81 const char *result = memory.c_str() + cursor;
82 cursor += n;
83 return result;
84 }

◆ get_cstring()

const char * LinTree::LinTree::get_cstring ( )
inline

Definition at line 104 of file lintree.h.

104 {
105 size_t n = get_size();
106 const char *result = memory.c_str() + cursor;
107 cursor += n + 1;
108 return result;
109 }
size_t get_size()
Definition: lintree.h:71

◆ get_int()

int LinTree::LinTree::get_int ( )
inline

Definition at line 68 of file lintree.h.

68 {
69 return get<int>();
70 }

◆ get_last_ring()

void * LinTree::LinTree::get_last_ring ( )
inline

Definition at line 124 of file lintree.h.

124 {
125 return last_ring;
126 }

◆ get_prev()

template<typename T >
T LinTree::LinTree::get_prev ( )
inline

Definition at line 55 of file lintree.h.

55 {
56 T result;
57 memcpy(&result, memory.c_str() + cursor - sizeof(T), sizeof(T));
58 return result;
59 }

◆ get_size()

size_t LinTree::LinTree::get_size ( )
inline

Definition at line 71 of file lintree.h.

71 {
72 return get<size_t>();
73 }

◆ has_error()

int LinTree::LinTree::has_error ( )
inline

Definition at line 41 of file lintree.h.

41 {
42 return error != NULL;
43 }

◆ has_last_ring()

int LinTree::LinTree::has_last_ring ( )
inline

Definition at line 121 of file lintree.h.

121 {
122 return last_ring != NULL;
123 }

◆ mark_error()

void LinTree::LinTree::mark_error ( const char *  s)
inline

Definition at line 38 of file lintree.h.

38 {
39 error = s;
40 }
const CanonicalForm int s
Definition: facAbsFact.cc:51

◆ operator=()

LinTree & LinTree::LinTree::operator= ( const LinTree other)

Definition at line 888 of file lintree.cc.

888 {
889 cursor = other.cursor;
890 memory = *new string(other.memory);
891 error = NULL;
892 last_ring = NULL;
893 return *this;
894}
#define string
Definition: libparse.cc:1252

◆ put()

template<typename T >
void LinTree::LinTree::put ( T  data)
inline

Definition at line 61 of file lintree.h.

61 {
62 memory.append((const char *) &data, sizeof(T));
63 }

◆ put_bytes()

void LinTree::LinTree::put_bytes ( char *  p,
size_t  n 
)
inline

Definition at line 88 of file lintree.h.

88 {
89 memory.append(p, n);
90 }
int p
Definition: cfModGcd.cc:4078

◆ put_cstring()

void LinTree::LinTree::put_cstring ( char *  p)
inline

Definition at line 99 of file lintree.h.

99 {
100 size_t n = strlen(p);
101 put(n);
102 put_bytes(p, n+1);
103 }
void put_bytes(char *p, size_t n)
Definition: lintree.h:88
void put(T data)
Definition: lintree.h:61

◆ put_int()

void LinTree::LinTree::put_int ( int  code)
inline

Definition at line 74 of file lintree.h.

74 {
75 put(code);
76 }

◆ reserve_bytes()

char * LinTree::LinTree::reserve_bytes ( size_t  n)
inline

Definition at line 91 of file lintree.h.

91 {
92 size_t pos = memory.size();
93 memory.reserve(n);
94 for (size_t i = 0; i < n; i++) {
95 memory += '\0';
96 }
97 return (char *)(memory.c_str() + pos);
98 }
int i
Definition: cfEzgcd.cc:132

◆ rewind()

void LinTree::LinTree::rewind ( )
inline

Definition at line 36 of file lintree.h.

36{ cursor = 0; }

◆ set_last_ring()

void LinTree::LinTree::set_last_ring ( void *  r)

Definition at line 900 of file lintree.cc.

900 {
901 if (last_ring)
902 rKill((ring) last_ring);
903 last_ring = r;
904 if (r) rIncRefCnt((ring) r);
905}
static ring rIncRefCnt(ring r)
Definition: ring.h:837

◆ skip()

template<typename T >
void LinTree::LinTree::skip ( )
inline

Definition at line 65 of file lintree.h.

65 {
66 cursor += sizeof(T);
67 }

◆ skip_bytes()

void LinTree::LinTree::skip_bytes ( size_t  n)
inline

Definition at line 114 of file lintree.h.

114 {
115 cursor += n;
116 }

◆ skip_cstring()

void LinTree::LinTree::skip_cstring ( )
inline

Definition at line 110 of file lintree.h.

110 {
111 size_t n = get_size();
112 cursor += n + 1;
113 }

◆ skip_int()

void LinTree::LinTree::skip_int ( )
inline

Definition at line 77 of file lintree.h.

77 {
78 skip<int>();
79 }

◆ to_string()

std::string & LinTree::LinTree::to_string ( )
inline

Definition at line 117 of file lintree.h.

117 {
118 return memory;
119 }

Field Documentation

◆ cursor

size_t LinTree::LinTree::cursor
private

Definition at line 27 of file lintree.h.

◆ error

const char* LinTree::LinTree::error
private

Definition at line 28 of file lintree.h.

◆ last_ring

void* LinTree::LinTree::last_ring
private

Definition at line 29 of file lintree.h.

◆ memory

std::string& LinTree::LinTree::memory
private

Definition at line 26 of file lintree.h.


The documentation for this class was generated from the following files: