Skip to content

Commit

Permalink
update code style
Browse files Browse the repository at this point in the history
  • Loading branch information
Jhuster committed Jan 7, 2016
1 parent cc93c1b commit 34b18b5
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 55 deletions.
2 changes: 1 addition & 1 deletion cpp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ It can help you construct & parse one or several TLV objects.
Building
----------

g++ -o test Test.cpp TlvBox.cpp Tlv.cpp
g++ -o test test.cpp tlv_box.cpp tlv.cpp
./test

Usage
Expand Down
32 changes: 16 additions & 16 deletions cpp/Test.cpp → cpp/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

#include <iostream>
#include <string>
#include "TlvBox.h"
#include "tlv_box.h"

using namespace tlv;

Expand Down Expand Up @@ -44,7 +44,7 @@ int main(int argc, char const *argv[])
unsigned char array[6] = {1,2,3,4,5,6};
box.PutBytesValue(TEST_TYPE_9,array,6);

if(!box.Serialize()) {
if (!box.Serialize()) {
std::cout << "box Serialize Failed !\n";
return -1;
}
Expand All @@ -54,23 +54,23 @@ int main(int argc, char const *argv[])
TlvBox boxes;
boxes.PutObjectValue(TEST_TYPE_a, box);

if(!boxes.Serialize()) {
if (!boxes.Serialize()) {
std::cout << "boxes Serialize Failed !\n";
return -1;
}

std::cout << "boxes Serialize Success, " << boxes.GetSerializedBytes() << " bytes \n";

TlvBox parsedBoxes;
if(!parsedBoxes.Parse(boxes.GetSerializedBuffer(),boxes.GetSerializedBytes())) {
if (!parsedBoxes.Parse(boxes.GetSerializedBuffer(),boxes.GetSerializedBytes())) {
std::cout << "boxes Parse Failed !\n";
return -1;
}

std::cout << "boxes Parse Success, " << parsedBoxes.GetSerializedBytes() << " bytes \n";

TlvBox parsedBox;
if(!parsedBoxes.GetObjectValue(TEST_TYPE_a,parsedBox)) {
if (!parsedBoxes.GetObjectValue(TEST_TYPE_a,parsedBox)) {
std::cout << "GetObjectValue Failed !\n";
return -1;
}
Expand All @@ -79,7 +79,7 @@ int main(int argc, char const *argv[])

{
bool value;
if(!parsedBox.GetBoolValue(TEST_TYPE_0,value)) {
if (!parsedBox.GetBoolValue(TEST_TYPE_0,value)) {
std::cout << "GetBoolValue Failed !\n";
return -1;
}
Expand All @@ -88,7 +88,7 @@ int main(int argc, char const *argv[])

{
char value;
if(!parsedBox.GetCharValue(TEST_TYPE_1,value)) {
if (!parsedBox.GetCharValue(TEST_TYPE_1,value)) {
std::cout << "GetCharValue Failed !\n";
return -1;
}
Expand All @@ -97,7 +97,7 @@ int main(int argc, char const *argv[])

{
short value;
if(!parsedBox.GetShortValue(TEST_TYPE_2,value)) {
if (!parsedBox.GetShortValue(TEST_TYPE_2,value)) {
std::cout << "GetShortValue Failed !\n";
return -1;
}
Expand All @@ -106,7 +106,7 @@ int main(int argc, char const *argv[])

{
int value;
if(!parsedBox.GetIntValue(TEST_TYPE_3,value)) {
if (!parsedBox.GetIntValue(TEST_TYPE_3,value)) {
std::cout << "GetIntValue Failed !\n";
return -1;
}
Expand All @@ -115,7 +115,7 @@ int main(int argc, char const *argv[])

{
long value;
if(!parsedBox.GetLongValue(TEST_TYPE_4,value)) {
if (!parsedBox.GetLongValue(TEST_TYPE_4,value)) {
std::cout << "GetLongValue Failed !\n";
return -1;
}
Expand All @@ -124,7 +124,7 @@ int main(int argc, char const *argv[])

{
float value;
if(!parsedBox.GetFloatValue(TEST_TYPE_5,value)) {
if (!parsedBox.GetFloatValue(TEST_TYPE_5,value)) {
std::cout << "PutFloatValue Failed !\n";
return -1;
}
Expand All @@ -133,7 +133,7 @@ int main(int argc, char const *argv[])

{
double value;
if(!parsedBox.GetDoubleValue(TEST_TYPE_6,value)) {
if (!parsedBox.GetDoubleValue(TEST_TYPE_6,value)) {
std::cout << "GetDoubleValue Failed !\n";
return -1;
}
Expand All @@ -142,7 +142,7 @@ int main(int argc, char const *argv[])

{
char value[128]; int length = 128;
if(!parsedBox.GetStringValue(TEST_TYPE_7,value,length)) {
if (!parsedBox.GetStringValue(TEST_TYPE_7,value,length)) {
std::cout << "GetStringValue Failed !\n";
return -1;
}
Expand All @@ -151,7 +151,7 @@ int main(int argc, char const *argv[])

{
std::string value;
if(!parsedBox.GetStringValue(TEST_TYPE_8,value)) {
if (!parsedBox.GetStringValue(TEST_TYPE_8,value)) {
std::cout << "GetStringValue Failed !\n";
return -1;
}
Expand All @@ -160,13 +160,13 @@ int main(int argc, char const *argv[])

{
unsigned char value[128]; int length = 128;
if(!parsedBox.GetBytesValue(TEST_TYPE_9,value,length)) {
if (!parsedBox.GetBytesValue(TEST_TYPE_9,value,length)) {
std::cout << "GetBytesValue Failed !\n";
return -1;
}

std::cout << "GetBytesValue Success ";
for(int i=0; i<length; i++) {
for (int i=0; i<length; i++) {
std::cout << (int)value[i] << "--";
}
std::cout << std::endl;
Expand Down
6 changes: 3 additions & 3 deletions cpp/Tlv.cpp → cpp/tlv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
* the Free Software Foundation; version 2 of the License.
*/

#include "Tlv.h"
#include <string.h>

#include "tlv.h"

namespace tlv
{

Expand Down Expand Up @@ -78,7 +78,7 @@ Tlv::Tlv(int type,const Tlv& value) : mType(type)

Tlv::~Tlv()
{
delete mValue;
delete[] mValue;
}

void Tlv::Initialize(const void *value,int length)
Expand Down
File renamed without changes.
Loading

0 comments on commit 34b18b5

Please sign in to comment.