-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathblog.cpp
More file actions
103 lines (70 loc) · 1.41 KB
/
blog.cpp
File metadata and controls
103 lines (70 loc) · 1.41 KB
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
97
98
99
100
101
#include <cstring>
#include "config.h"
#include "blog.h"
blog_post_t::blog_post_t(){
contents = new char[BLOG_CONTENT_SIZE];
}
blog_post_t::~blog_post_t(){
delete contents;
}
//deep copy constrcutor
blog_post_t::blog_post_t(const blog_post_t &to_copy){
contents = new char[BLOG_CONTENT_SIZE];
strncpy(contents, to_copy.contents, BLOG_CONTENT_SIZE);
}
/* the setters */
void blog_post_t::setTitle(const char *t){
strncpy(title, t, 64);
}
void blog_post_t::setAuthor(const char *a){
strncpy(author, a, 64);
}
void blog_post_t::setSummary(const char *s){
strncpy(summary, s, 128);
}
void blog_post_t::setDate(int m, int d, int y){
month = m;
day = d;
year = y;
}
void blog_post_t::setHTML(const char *h){
strncpy(html, h, 64);
}
void blog_post_t::setSB(const char *s){
strncpy(sb, s, 64);
}
void blog_post_t::addChar(char c, int i){
//for feeding individual characters to content buffer
contents[i] = c;
}
/* the getters*/
char* blog_post_t::getTitle(){
return title;
}
int blog_post_t::getM(){
return month;
}
int blog_post_t::getD(){
return day;
}
int blog_post_t::getY(){
return year;
}
char* blog_post_t::getSummary(){
return summary;
}
char* blog_post_t::getAuthor(){
return author;
}
char* blog_post_t::getSB(){
return sb;
}
char *blog_post_t::getHTML(){
return html;
}
char blog_post_t::getChar(int i){
return contents[i];
}
char* blog_post_t::getContents(){
return contents;
}