mirror of
https://gitee.com/acl-dev/acl.git
synced 2024-12-02 20:08:21 +08:00
commit
80213fb28e
5
app/gson/test/Makefile
Normal file
5
app/gson/test/Makefile
Normal file
@ -0,0 +1,5 @@
|
||||
|
||||
clean:
|
||||
@(cd benchmark; make clean)
|
||||
@(cd test1; make clean)
|
||||
@(cd test2; make clean)
|
@ -81,10 +81,14 @@ ifneq ($(SYSPATH),)
|
||||
endif
|
||||
###########################################################
|
||||
|
||||
CFLAGS += -I../../../lib_acl/include -I../../../lib_protocol/include -I../../../lib_acl_cpp/include
|
||||
CFLAGS += -I../../../../lib_acl/include \
|
||||
-I../../../../lib_protocol/include \
|
||||
-I../../../../lib_acl_cpp/include
|
||||
EXTLIBS =
|
||||
LDFLAGS = -L../../../lib_acl_cpp/lib -l_acl_cpp -L../../../lib_protocol/lib -l_protocol -L../../../lib_acl/lib -l_acl \
|
||||
$(EXTLIBS) $(SYSLIB)
|
||||
LDFLAGS = -L../../../../lib_acl_cpp/lib -l_acl_cpp \
|
||||
-L../../../../lib_protocol/lib -l_protocol \
|
||||
-L../../../../lib_acl/lib -l_acl \
|
||||
$(EXTLIBS) $(SYSLIB)
|
||||
|
||||
COMPILE = $(CC) $(CFLAGS)
|
||||
LINK = $(CC) $(OBJ) $(LDFLAGS)
|
||||
@ -109,6 +113,9 @@ RM:
|
||||
clean:
|
||||
rm -f $(PROG)
|
||||
rm -f $(OBJ)
|
||||
rm -f gson.cpp
|
||||
rm -f gson.h
|
||||
rm -f struct.h
|
||||
install:
|
||||
cp $(PROG) ../../../dist/master/libexec/$(RPATH)/
|
||||
cp $(PROG).cf ../../../dist/master/conf/service/
|
5
app/gson/test/benchmark/Makefile
Normal file
5
app/gson/test/benchmark/Makefile
Normal file
@ -0,0 +1,5 @@
|
||||
include ../Makefile.in
|
||||
ifeq ($(findstring FreeBSD, $(UNIXNAME)), FreeBSD)
|
||||
EXTLIBS += -L/usr/local/lib -liconv
|
||||
endif
|
||||
PROG = test1
|
3
app/gson/test/benchmark/valgrind.sh
Executable file
3
app/gson/test/benchmark/valgrind.sh
Executable file
@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
|
||||
valgrind --tool=memcheck --leak-check=yes -v ./test1 -n 10000
|
@ -1,5 +1,5 @@
|
||||
include ./Makefile.in
|
||||
include ../Makefile.in
|
||||
ifeq ($(findstring FreeBSD, $(UNIXNAME)), FreeBSD)
|
||||
EXTLIBS += -L/usr/local/lib -liconv
|
||||
endif
|
||||
PROG = json
|
||||
PROG = test
|
172
app/gson/test/test1/main.cpp
Normal file
172
app/gson/test/test1/main.cpp
Normal file
@ -0,0 +1,172 @@
|
||||
#include "stdafx.h"
|
||||
#include <list>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <stdio.h>
|
||||
#include <iostream>
|
||||
#include <time.h>
|
||||
#include "struct.h"
|
||||
#include "gson.h"
|
||||
|
||||
static void print_msg(message& msg)
|
||||
{
|
||||
printf("=======================================================\r\n");
|
||||
printf("type: %d\r\n", msg.type);
|
||||
printf("cmd: %s\r\n", msg.cmd.c_str());
|
||||
|
||||
printf("-------------------- user list ------------------------\r\n");
|
||||
size_t i = 0;
|
||||
for (auto cit : msg.user_list)
|
||||
{
|
||||
printf(">>username: %s, domain: %s, age: %d, male: %s\r\n",
|
||||
cit.username.c_str(), cit.domain.c_str(),
|
||||
cit.age, cit.male ? "true" : "false");
|
||||
if (++i >= 10)
|
||||
break;
|
||||
}
|
||||
|
||||
printf("-------------------- user vector ----------------------\r\n");
|
||||
i = 0;
|
||||
for (auto cit : msg.user_vector)
|
||||
{
|
||||
printf(">>username: %s, domain: %s, age: %d, male: %s\r\n",
|
||||
cit.username.c_str(), cit.domain.c_str(),
|
||||
cit.age, cit.male ? "true" : "false");
|
||||
if (++i >= 10)
|
||||
break;
|
||||
}
|
||||
|
||||
printf("------------------- user map --------------------------\r\n");
|
||||
i = 0;
|
||||
for (auto cit : msg.user_map)
|
||||
{
|
||||
printf(">>key: %s, username: %s, domain: %s, age: %d, male: %s\r\n",
|
||||
cit.first.c_str(),
|
||||
cit.second.username.c_str(),
|
||||
cit.second.domain.c_str(),
|
||||
cit.second.age,
|
||||
cit.second.male ? "true" : "false");
|
||||
if (++i >= 10)
|
||||
break;
|
||||
}
|
||||
printf("-------------------- user list ptr --------------------\r\n");
|
||||
i = 0;
|
||||
for (auto cit : *msg.user_list_ptr)
|
||||
{
|
||||
printf(">>username: %s, domain: %s, age: %d, male: %s\r\n",
|
||||
cit->username.c_str(), cit->domain.c_str(),
|
||||
cit->age, cit->male ? "true" : "false");
|
||||
if (++i >= 10)
|
||||
break;
|
||||
}
|
||||
|
||||
printf("-------------------- user vector ptr ------------------\r\n");
|
||||
i = 0;
|
||||
for (auto cit : *msg.user_vector_ptr)
|
||||
{
|
||||
printf(">>username: %s, domain: %s, age: %d, male: %s\r\n",
|
||||
cit->username.c_str(), cit->domain.c_str(),
|
||||
cit->age, cit->male ? "true" : "false");
|
||||
if (++i >= 10)
|
||||
break;
|
||||
}
|
||||
|
||||
printf("------------------- user map ptr ----------------------\r\n");
|
||||
i = 0;
|
||||
for (auto cit : *msg.user_map_ptr)
|
||||
{
|
||||
printf(">>key: %s, username: %s, domain: %s, age: %d, male: %s\r\n",
|
||||
cit.first.c_str(),
|
||||
cit.second->username.c_str(),
|
||||
cit.second->domain.c_str(),
|
||||
cit.second->age,
|
||||
cit.second->male ? "true" : "false");
|
||||
if (++i >= 10)
|
||||
break;
|
||||
}
|
||||
|
||||
printf("-------------------------------------------------------\r\n");
|
||||
}
|
||||
|
||||
static void test1(void)
|
||||
{
|
||||
message msg;
|
||||
msg.user_list_ptr = new std::list<user*>;
|
||||
msg.user_vector_ptr = new std::vector<user*>;
|
||||
msg.user_map_ptr = new std::map<acl::string, user*>;
|
||||
|
||||
msg.type = 1;
|
||||
msg.cmd = "add";
|
||||
|
||||
user u = {"zsx1", "263.net", 11, true};
|
||||
msg.user_list.push_back(u);
|
||||
msg.user_list.emplace_back(u);
|
||||
msg.user_list.emplace_back("zsx1", "263.net", 13, false);
|
||||
|
||||
u = {"zsx2", "263.net", 11, true};
|
||||
msg.user_vector.push_back(u);
|
||||
msg.user_vector.emplace_back(u);
|
||||
msg.user_vector.emplace_back("zsx2", "263.net4", 14, true);
|
||||
|
||||
u = {"zsx31", "263.net", 11, true};
|
||||
msg.user_map[u.username] = u;
|
||||
msg.user_map["zsx32"] = {"zsx32", "263.net", 11, true };
|
||||
|
||||
msg.user_list_ptr->push_back(new user("zsx4", "263.net1", 11, true));
|
||||
msg.user_list_ptr->push_back(new user("zsx4", "263.net2", 12, true));
|
||||
|
||||
msg.user_vector_ptr->push_back(new user("zsx5", "263.net1", 11, true));
|
||||
msg.user_vector_ptr->push_back(new user("zsx5", "263.net2", 12, true));
|
||||
|
||||
(*msg.user_map_ptr)["zsx61"] = new user("zsx61:", "263.net1", 11, true);
|
||||
(*msg.user_map_ptr)["zsx62"] = new user("zsx62", "263.net2", 12, true);
|
||||
|
||||
acl::json json;
|
||||
acl::json_node& node = acl::gson(json, msg);
|
||||
|
||||
message msg1;
|
||||
acl::json json1;
|
||||
json1.update(node.to_string());
|
||||
|
||||
printf("------------------------------------------------------\r\n");
|
||||
printf("json to_string: %s\r\n", json.to_string().c_str());
|
||||
printf("------------------------------------------------------\r\n");
|
||||
printf("node to_string: %s\r\n", node.to_string().c_str());
|
||||
printf("------------------------------------------------------\r\n");
|
||||
printf("json1 to_string: %s\r\n", json1.to_string().c_str());
|
||||
printf("------------------------------------------------------\r\n");
|
||||
|
||||
std::pair<bool, std::string> ret = acl::gson(json1.get_root(), msg1);
|
||||
if (ret.first == false)
|
||||
printf("error: %s\r\n", ret.second.c_str());
|
||||
else
|
||||
{
|
||||
printf("==================== All OK ===================\r\n");
|
||||
print_msg(msg);
|
||||
}
|
||||
}
|
||||
|
||||
static void usage(const char* procname)
|
||||
{
|
||||
printf("usage: %s -h [help]\r\n", procname);
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
int ch;
|
||||
|
||||
while ((ch = getopt(argc, argv, "h")) > 0)
|
||||
{
|
||||
switch (ch)
|
||||
{
|
||||
case 'h':
|
||||
usage(argv[0]);
|
||||
return 0;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
test1();
|
||||
return 0;
|
||||
}
|
8
app/gson/test/test1/stdafx.cpp
Normal file
8
app/gson/test/test1/stdafx.cpp
Normal file
@ -0,0 +1,8 @@
|
||||
// stdafx.cpp : 只包括标准包含文件的源文件
|
||||
// wizard.pch 将成为预编译头
|
||||
// stdafx.obj 将包含预编译类型信息
|
||||
|
||||
#include "stdafx.h"
|
||||
|
||||
// TODO: 在 STDAFX.H 中
|
||||
//引用任何所需的附加头文件,而不是在此文件中引用
|
15
app/gson/test/test1/stdafx.h
Normal file
15
app/gson/test/test1/stdafx.h
Normal file
@ -0,0 +1,15 @@
|
||||
// stdafx.h : 标准系统包含文件的包含文件,
|
||||
// 或是常用但不常更改的项目特定的包含文件
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
//#include <iostream>
|
||||
//#include <tchar.h>
|
||||
|
||||
// TODO: 在此处引用程序要求的附加头文件
|
||||
|
||||
#include "lib_acl.h"
|
||||
#include "acl_cpp/lib_acl.hpp"
|
||||
#include "lib_protocol.h"
|
61
app/gson/test/test1/struct.stub
Normal file
61
app/gson/test/test1/struct.stub
Normal file
@ -0,0 +1,61 @@
|
||||
#pragma once
|
||||
|
||||
struct user
|
||||
{
|
||||
user(const char* user_name, const char* user_domain,
|
||||
int user_age, bool user_male)
|
||||
: username(user_name)
|
||||
, domain(user_domain)
|
||||
, age(user_age)
|
||||
, male(user_male)
|
||||
{}
|
||||
|
||||
user() {}
|
||||
~user() {}
|
||||
|
||||
acl::string username;
|
||||
acl::string domain;
|
||||
int age;
|
||||
bool male;
|
||||
};
|
||||
|
||||
struct message
|
||||
{
|
||||
int type;
|
||||
acl::string cmd;
|
||||
std::list<user> user_list;
|
||||
std::list<user> user_vector;
|
||||
std::map<acl::string, user> user_map;
|
||||
|
||||
std::list<user*> *user_list_ptr;
|
||||
std::vector<user*> *user_vector_ptr;
|
||||
std::map<acl::string, user*> *user_map_ptr;
|
||||
|
||||
message()
|
||||
: user_list_ptr(NULL)
|
||||
, user_vector_ptr(NULL)
|
||||
, user_map_ptr(NULL)
|
||||
{}
|
||||
|
||||
~message()
|
||||
{
|
||||
if (user_list_ptr)
|
||||
{
|
||||
for (auto it : *user_list_ptr)
|
||||
delete it;
|
||||
delete user_list_ptr;
|
||||
}
|
||||
if (user_vector_ptr)
|
||||
{
|
||||
for (auto it : *user_vector_ptr)
|
||||
delete it;
|
||||
delete user_vector_ptr;
|
||||
}
|
||||
if (user_map_ptr)
|
||||
{
|
||||
for (auto it : *user_map_ptr)
|
||||
delete it.second;
|
||||
delete user_map_ptr;
|
||||
}
|
||||
}
|
||||
};
|
3
app/gson/test/test1/valgrind.sh
Executable file
3
app/gson/test/test1/valgrind.sh
Executable file
@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
|
||||
valgrind --tool=memcheck --leak-check=yes -v ./test
|
5
app/gson/test/test2/Makefile
Normal file
5
app/gson/test/test2/Makefile
Normal file
@ -0,0 +1,5 @@
|
||||
include ../Makefile.in
|
||||
ifeq ($(findstring FreeBSD, $(UNIXNAME)), FreeBSD)
|
||||
EXTLIBS += -L/usr/local/lib -liconv
|
||||
endif
|
||||
PROG = test
|
111
app/gson/test/test2/main.cpp
Normal file
111
app/gson/test/test2/main.cpp
Normal file
@ -0,0 +1,111 @@
|
||||
#include "stdafx.h"
|
||||
#include <list>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <stdio.h>
|
||||
#include <iostream>
|
||||
#include <time.h>
|
||||
#include "struct.h"
|
||||
#include "gson.h"
|
||||
|
||||
static void print_user(const user& u)
|
||||
{
|
||||
printf("\t\tuser ---> name: %s, male: %s, age: %d\r\n",
|
||||
u.name.c_str(), u.male ? "yes" : "no", u.age);
|
||||
}
|
||||
|
||||
static void print_group(const group& g)
|
||||
{
|
||||
printf("\tgroup --> name: %s\r\n", g.name.c_str());
|
||||
for (auto cit : g.users)
|
||||
print_user(cit);
|
||||
}
|
||||
|
||||
static void print_company(const company& com)
|
||||
{
|
||||
printf("\r\ncompany ---> name: %s, addr: %s\r\n",
|
||||
com.name.c_str(), com.addr.c_str());
|
||||
|
||||
for (auto cit : com.groups)
|
||||
print_group(cit);
|
||||
}
|
||||
|
||||
static void test(void)
|
||||
{
|
||||
company com;
|
||||
com.name = "263";
|
||||
com.addr = "beijing";
|
||||
|
||||
group g;
|
||||
|
||||
g.name = "dev1";
|
||||
g.users.emplace_back("zsx11", 11, true);
|
||||
g.users.emplace_back("zsx12", 12, false);
|
||||
g.users.emplace_back("zsx13", 13, true);
|
||||
com.groups.emplace_back(g);
|
||||
|
||||
g.name = "dev2";
|
||||
g.users.clear();
|
||||
g.users.emplace_back("zsx21", 11, true);
|
||||
g.users.emplace_back("zsx22", 12, false);
|
||||
g.users.emplace_back("zsx23", 13, true);
|
||||
com.groups.emplace_back(g);
|
||||
|
||||
g.name = "dev3";
|
||||
g.users.clear();
|
||||
g.users.emplace_back("zsx31", 11, true);
|
||||
g.users.emplace_back("zsx32", 12, false);
|
||||
g.users.emplace_back("zsx33", 13, true);
|
||||
com.groups.emplace_back(g);
|
||||
|
||||
g = {"dev4", {{"zsx41", 11, true}, {"zsx42", 11, true}}};
|
||||
com.groups.emplace_back(g);
|
||||
|
||||
acl::json json;
|
||||
acl::json_node& node = acl::gson(json, com);
|
||||
|
||||
printf("------------------------------------------------------\r\n");
|
||||
printf("node to_string: %s\r\n", node.to_string().c_str());
|
||||
printf("------------------------------------------------------\r\n");
|
||||
|
||||
company com1;
|
||||
acl::json json1;
|
||||
json1.update(node.to_string());
|
||||
|
||||
printf("json1 to_string: %s\r\n", json1.to_string().c_str());
|
||||
printf("------------------------------------------------------\r\n");
|
||||
|
||||
std::pair<bool, std::string> ret = acl::gson(json1.get_root(), com1);
|
||||
if (ret.first == false)
|
||||
printf("error: %s\r\n", ret.second.c_str());
|
||||
else
|
||||
{
|
||||
printf("==================== All OK ===================\r\n");
|
||||
print_company(com1);
|
||||
}
|
||||
}
|
||||
|
||||
static void usage(const char* procname)
|
||||
{
|
||||
printf("usage: %s -h [help]\r\n", procname);
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
int ch;
|
||||
|
||||
while ((ch = getopt(argc, argv, "h")) > 0)
|
||||
{
|
||||
switch (ch)
|
||||
{
|
||||
case 'h':
|
||||
usage(argv[0]);
|
||||
return 0;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
test();
|
||||
return 0;
|
||||
}
|
8
app/gson/test/test2/stdafx.cpp
Normal file
8
app/gson/test/test2/stdafx.cpp
Normal file
@ -0,0 +1,8 @@
|
||||
// stdafx.cpp : 只包括标准包含文件的源文件
|
||||
// wizard.pch 将成为预编译头
|
||||
// stdafx.obj 将包含预编译类型信息
|
||||
|
||||
#include "stdafx.h"
|
||||
|
||||
// TODO: 在 STDAFX.H 中
|
||||
//引用任何所需的附加头文件,而不是在此文件中引用
|
15
app/gson/test/test2/stdafx.h
Normal file
15
app/gson/test/test2/stdafx.h
Normal file
@ -0,0 +1,15 @@
|
||||
// stdafx.h : 标准系统包含文件的包含文件,
|
||||
// 或是常用但不常更改的项目特定的包含文件
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
//#include <iostream>
|
||||
//#include <tchar.h>
|
||||
|
||||
// TODO: 在此处引用程序要求的附加头文件
|
||||
|
||||
#include "lib_acl.h"
|
||||
#include "acl_cpp/lib_acl.hpp"
|
||||
#include "lib_protocol.h"
|
33
app/gson/test/test2/struct.stub
Normal file
33
app/gson/test/test2/struct.stub
Normal file
@ -0,0 +1,33 @@
|
||||
#pragma once
|
||||
|
||||
struct user
|
||||
{
|
||||
user(const char* user_name, int user_age, bool user_male)
|
||||
: name(user_name)
|
||||
, age(user_age)
|
||||
, male(user_male)
|
||||
{}
|
||||
|
||||
user() {}
|
||||
~user() {}
|
||||
|
||||
std::string name;
|
||||
int age;
|
||||
bool male;
|
||||
|
||||
//Gson@optional
|
||||
std::string addr;
|
||||
};
|
||||
|
||||
struct group
|
||||
{
|
||||
std::string name;
|
||||
std::vector<user> users;
|
||||
};
|
||||
|
||||
struct company
|
||||
{
|
||||
std::string name;
|
||||
std::string addr;
|
||||
std::vector<group> groups;
|
||||
};
|
3
app/gson/test/test2/valgrind.sh
Executable file
3
app/gson/test/test2/valgrind.sh
Executable file
@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
|
||||
valgrind --tool=memcheck --leak-check=yes -v ./test
|
@ -1,78 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
struct user
|
||||
{
|
||||
user(const char* username, const char* domain, int age, bool male)
|
||||
: username_(username)
|
||||
, domain_(domain)
|
||||
, age_(age)
|
||||
, male_(male)
|
||||
{}
|
||||
|
||||
user() {}
|
||||
~user() {}
|
||||
|
||||
acl::string username_;
|
||||
acl::string domain_;
|
||||
int age_;
|
||||
bool male_;
|
||||
};
|
||||
|
||||
struct message
|
||||
{
|
||||
int type_;
|
||||
acl::string cmd_;
|
||||
std::list<user> data_;
|
||||
};
|
||||
|
||||
struct user1
|
||||
{
|
||||
user1(const char* username, const char* domain, int age, bool male)
|
||||
{
|
||||
size_t n = strlen(username);
|
||||
username_ = new char[n + 1];
|
||||
memcpy(username_, username, n);
|
||||
username_[n] = 0;
|
||||
|
||||
n = strlen(domain);
|
||||
domain_ = new char[n + 1];
|
||||
memcpy(domain_, domain, n);
|
||||
domain_[n] = 0;
|
||||
age_ = age;
|
||||
male_ = male;
|
||||
}
|
||||
|
||||
user1()
|
||||
{
|
||||
username_ = NULL;
|
||||
domain_ = NULL;
|
||||
}
|
||||
|
||||
~user1()
|
||||
{
|
||||
delete []username_;
|
||||
delete []domain_;
|
||||
}
|
||||
|
||||
char* username_;
|
||||
char* domain_;
|
||||
int age_;
|
||||
bool male_;
|
||||
};
|
||||
|
||||
struct message1
|
||||
{
|
||||
message1()
|
||||
{
|
||||
}
|
||||
|
||||
~message1()
|
||||
{
|
||||
for (auto it = data_.begin(); it != data_.end(); ++it)
|
||||
delete *it;
|
||||
}
|
||||
|
||||
int type_;
|
||||
acl::string cmd_;
|
||||
std::list<user1*> data_;
|
||||
};
|
@ -1,3 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
valgrind --tool=memcheck --leak-check=yes -v ./json -n 10000
|
@ -94,6 +94,7 @@ gsoner::gsoner()
|
||||
gen_header_ = NULL;
|
||||
gen_source_ = NULL;
|
||||
default_ = true;
|
||||
required_ = default_;
|
||||
gen_header_filename_ = "gson.h";
|
||||
gen_source_filename_ = "gson.cpp";
|
||||
default_delimiters_ = "\\\r\n\t ";
|
||||
@ -272,13 +273,13 @@ std::string gsoner::get_unpack_code(const std::string &obj_name,
|
||||
|
||||
return tab_ +
|
||||
"if(" + field.name_ + ")\n" + tab_ + tab_ +
|
||||
"gson(*" + field.name_ + ",&obj." + field.name_ + ");\n";
|
||||
"gson(*" + field.name_ + ",&obj." + field.name_ + ");";
|
||||
|
||||
else if(field.required_ == false)
|
||||
return tab_
|
||||
+ "if(" + field.name_ + "&& " + field.name_
|
||||
+ "->get_obj())\n" + tab_ + tab_ + " gson(*" + field.name_
|
||||
+ "->get_obj(), &obj." + field.name_ + ");\n";
|
||||
+ "->get_obj(), &obj." + field.name_ + ");";
|
||||
|
||||
return "unknown_type";
|
||||
}
|
||||
@ -874,17 +875,41 @@ bool gsoner::check_member()
|
||||
{
|
||||
e--;
|
||||
}
|
||||
|
||||
get_name:
|
||||
while(lines[e] != ' ' &&
|
||||
lines[e] != '\r' &&
|
||||
lines[e] != '\n' &&
|
||||
lines[e] != '\t' &&
|
||||
lines[e] != '*' &&
|
||||
lines[e] != '&')
|
||||
lines[e] != '&' &&
|
||||
lines[e] != '=')
|
||||
{
|
||||
name.push_back(lines[e]);
|
||||
e--;
|
||||
}
|
||||
//clear space;
|
||||
while (lines[e] == ' ' ||
|
||||
lines[e] == '\r' ||
|
||||
lines[e] == '\n' ||
|
||||
lines[e] == '\t')
|
||||
{
|
||||
e--;
|
||||
}
|
||||
|
||||
if (lines[e] == '=')
|
||||
{
|
||||
//eg: int a = 0;
|
||||
name.clear();
|
||||
e--;
|
||||
while (lines[e] == ' ' ||
|
||||
lines[e] == '\r' ||
|
||||
lines[e] == '\n' ||
|
||||
lines[e] == '\t')
|
||||
{
|
||||
e--;
|
||||
}
|
||||
goto get_name;
|
||||
}
|
||||
|
||||
//get name
|
||||
std::reverse(name.begin(), name.end());
|
||||
|
Loading…
Reference in New Issue
Block a user