ffead.server.doc
BinaryData.cpp
1 /*
2  Copyright 2009-2012, Sumeet Chhetri
3 
4  Licensed under the Apache License, Version 2.0 (the "License");
5  you may not use this file except in compliance with the License.
6  You may obtain a copy of the License at
7 
8  http://www.apache.org/licenses/LICENSE-2.0
9 
10  Unless required by applicable law or agreed to in writing, software
11  distributed under the License is distributed on an "AS IS" BASIS,
12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  See the License for the specific language governing permissions and
14  limitations under the License.
15 */
16 /*
17  * BinaryData.cpp
18  *
19  * Created on: Jun 14, 2010
20  * Author: sumeet
21  */
22 
23 #include "BinaryData.h"
24 
25 BinaryData::BinaryData() {
26  // TODO Auto-generated constructor stub
27 
28 }
29 
30 BinaryData::~BinaryData() {
31  // TODO Auto-generated destructor stub
32 }
33 
34 void BinaryData::append(unsigned char dat)
35 {
36  this->data.push_back(dat);
37 }
38 void BinaryData::append(unsigned char *dat)
39 {
40  //for(int i=0;i<(signed int)strlen(dat);i++)
41  // this->data.push_back(dat[i]);
42 }
43 void BinaryData::append(unsigned char *dat,int length)
44 {
45  for(int i=0;i<length;i++)
46  this->data.push_back(dat[i]);
47 }
48 void BinaryData::append(string dat)
49 {
50  for(int i=0;i<(signed int)dat.length();i++)
51  this->data.push_back(dat[i]);
52 }
53 void BinaryData::append(binaryData data)
54 {
55  for(int i=0;i<(signed int)data.size();i++)
56  this->data.push_back(data.at(i));
57 }
58 binaryData BinaryData::getData()
59 {
60  return this->data;
61 }
62 
63 string BinaryData::serilaize(BinaryData data)
64 {
65  string temp;
66  for(int i=0;i<(signed int)data.data.size();i++)
67  temp += data.data.at(i);
68  return temp;
69 }
70 
71 BinaryData* BinaryData::unSerilaize(string temp)
72 {
73  BinaryData *binr = new BinaryData;
74  binr->data.clear();
75  binr->append(temp);
76  return binr;
77 }