-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtext.cpp
59 lines (51 loc) · 2.14 KB
/
text.cpp
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
/*************************
* text.cpp
*
*
* editor: amo
*************************/
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <text.h>
/* -------------------------------------------------------------------- */
/* my define macro */
/* -------------------------------------------------------------------- */
/* -------------------------------------------------------------------- */
/* global variables */
/* -------------------------------------------------------------------- */
/* -------------------------------------------------------------------- */
/* implements */
/* -------------------------------------------------------------------- */
MyText::MyText(char *src){
if(strlen(src) > 127){
std::cout << "[MyText]: !!! limit of text is 127" << std::endl;
}
memset(text, 0, 128);
strncpy(text, src, strlen(src)+1);
length = strlen(text);
std::cout << "[MyText::MyText(char*)]: >>> " << this << ", text:" << text << ", length:" << length << std::endl;
}
MyText::MyText(){
std::cout << "[MyText::MyText()]: >>> " << this << ", text:" << text << ", length:" << length << std::endl;
}
MyText::~MyText(){
std::cout << "[MyText::~MyText()]: >>> " << this << ", release text:" << text << ", release length:" << length << std::endl;
}
void MyText::showText(){
std::cout << "[MyText::showText()]: >>> showText()" << std::endl;
std::cout << "[MyText::showText()]: now text:" << text << " and arg:" << arg << std::endl;
}
void MyText::setText(char *src){
std::cout << "[MyText::setText()]: >>> setText()" << std::endl;
strncpy(text, src, strlen(src)+1);
length = strlen(text);
std::cout << "[MyText::setText()]: text:" << text << std::endl;
std::cout << "[MyText::setText()]: length:" << length << std::endl;
}
void MyText::getText(char *dest){
strncpy(dest, text, strlen(text)+1);
std::cout << "[MyText::getText()]: text" << text << " to dest:" << dest << std::endl;
}