_END
}

bool get_company_account_req::pack(std::string& json)
{
	PACK_JSON_BEGIN
	pt_protocol.add(protocol_strings::COMMAND, protocol_commands::GET_COMACCOUNT);
	pt_protocol.add(protocol_strings::USERNAME,username);
	pt_root.add_child(protocol_strings::REQUEST, pt_protocol);
	PACK_JSON_END
}

bool get_company_account_req::unpack(const std::string& json)
{
	UNPACK_JSON_BEGIN
	pt_protocol = pt_root.get_child(protocol_strings::REQUEST);
	username = pt_protocol.get<std::string>(protocol_strings::USERNAME);
	UNPACK_JSON_END
}

bool get_company_account_resp::pack(std::string& json)
{
	PACK_JSON_BEGIN
	pt_protocol.add(protocol_strings::STATUS, (int)status);
	account.pack(pt_protocol);
	pt_root.add_child(protocol_strings::RESPONSE, pt_protocol);
	PACK_JSON_END
}

bool get_company_account_resp::unpack(const std::string& json)
{
	UNPACK_JSON_BEGIN
	pt_protocol = pt_root.get_child(protocol_strings::RESPONSE);
	status = (PROTOCOL_RESP_STATUS)pt_protocol.get<int>(protocol_strings::STATUS);
	account.unpack(pt_protocol);
	UNPACK_JSON_END
}

bool edit_company_account_req::pack(std::string& json)
{
	PACK_JSON_BEGIN
	pt_protocol.add(protocol_strings::COMMAND, protocol_commands::EDIT_COMACCOUNT);
	account.pack(pt_protocol);
	pt_root.add_child(protocol_strings::REQUEST, pt_protocol);
	PACK_JSON_END
}

bool edit_company_account_req::unpack(const std::string& json)
{
	UNPACK_JSON_BEGIN
	pt_protocol = pt_root.get_child(protocol_strings::REQUEST);
	account.unpack(pt_protocol);
	UNPACK_JSON_END
}

bool edit_company_account_resp::pack(std::string& json)
{
	PACK_JSON_BEGIN
	pt_protocol.add(protocol_strings::STATUS, (int)status);
	account.pack(pt_protocol);
	pt_root.add_child(protocol_strings::RESPONSE, pt_protocol);
	PACK_JSON_END
}

bool edit_company_account_resp::unpack(const std::string& json)
{
	UNPACK_JSON_BEGIN
	pt_protocol = pt_root.get_child(protocol_strings::RESPONSE);
	status = (PROTOCOL_RESP_STATUS)pt_protocol.get<int>(protocol_strings::STATUS);
	account.unpack(pt_protocol);
	UNPACK_JSON_END
}

bool get_company_account_list_req::pack(std::string& json)
{
	PACK_JSON_BEGIN
	pt_protocol.add(protocol_strings::COMMAND, protocol_commands::GET_COMACCOUNT_LIST);
	pt_root.add_child(protocol_strings::REQUEST, pt_protocol);
	PACK_JSON_END
}

bool get_company_account_list_req::unpack(const std::string& json)
{
	UNPACK_JSON_BEGIN
	pt_protocol = pt_root.get_child(protocol_strings::REQUEST);
	UNPACK_JSON_END
}

bool get_company_account_list_resp::pack(std::string& json)
{
	PACK_JSON_BEGIN
	pt_protocol.add(protocol_strings::STATUS, (int)status);
	boost::property_tree::ptree childen;
	for (size_t i = 0;i < accounts.size();i++)
	{
		boost::property_tree::ptree child;
		accounts.at(i).pack(child);
		childen.push_back(std::make_pair("",child));
	}
	pt_protocol.add_child(protocol_strings::COMPANY_ACCOUNT_LIST, childen);
	pt_root.add_child(protocol_strings::RESPONSE, pt_protocol);
	PACK_JSON_END	
}

bool get_company_account_list_resp::unpack(const std::string& json)
{
	UNPACK_JSON_BEGIN
	pt_protocol = pt_root.get_child(protocol_strings::RESPONSE);
	status = (PROTOCOL_RESP_STATUS)pt_protocol.get<int>(protocol_strings::STATUS);
	boost::property_tree::ptree children = pt_protocol.get_child(protocol_strings::COMPANY_ACCOUNT_LIST);		
	BOOST_FOREACH(boost::property_tree::ptree::value_type &v, children)
	{
		boost::property_tree::ptree p = v.second;
		company_account account;
		account.unpack(p);
		accounts.push_back(account);
	}
	UNPACK_JSON_END
}

void signature::pack(boost::property_tree::ptree& pt)
{
	pt.add(protocol_strings::ID,id);
	pt.add(protocol_strings::INDEX,index);
	pt.add(protocol_strings::SIGNATURE_TYPE, type);
	pt.add(protocol_strings::SIGNATURE_POSITION, position);
	std::string content_base64 = base64_encode((const unsigned char *)content.c_str(),(unsigned int)content.length());
	pt.add(protocol_strings::CONTENT, content_base64);
}

void signature::unpack(boost::property_tree::ptree& pt)
{
	id = pt.get<std::string>(protocol_strings::ID);
	index = pt.get<std::string>(protocol_strings::INDEX);
	type = (SIGNATURE_TYPE)pt.get<int>(protocol_strings::SIGNATURE_TYPE);
	position = (SIGNATURE_POSITION)pt.get<int>(protocol_strings::SIGNATURE_POSITION);
	std::string content_base64 = pt.get<std::string>(protocol_strings::CONTENT);
	std::vector<unsigned char> v_name = base64_decode(content_base64);
	content = std::string(v_name.begin(), v_name.end());
}

bool add_signature_req::pack(std::string& json)
{
	PACK_JSON_BEGIN
	pt_protocol.add(protocol_strings::COMMAND,protocol_commands::ADD_SIGNATURE);
	pt_protocol.add(protocol_strings::BELONGINGNESS,belongingness);
	signature_.pack(pt_protocol);
	pt_root.add_child(protocol_strings::REQUEST,pt_protocol);
	PACK_JSON_END
}

bool add_signature_req::unpack(const std::string& json)
{
	UNPACK_JSON_BEGIN
	pt_protocol = pt_root.get_child(protocol_strings::REQUEST);
	belongingness = (SIGNATURE_BELONGINGNESS)pt_protocol.get<int>(protocol_strings::BELONGINGNESS);
	signature_.unpack(pt_protocol);
	UNPACK_JSON_END
}

bool add_signature_resp::pack(std::string& json)
{
	PACK_JSON_BEGIN
	pt_protocol.add(protocol_strings::STATUS,status);
	pt_root.add_child(protocol_strings::RESPONSE,pt_protocol);
	PACK_JSON_END
}

bool add_signature_resp::unpack(const std::string& json)
{
	UNPACK_JSON_BEGIN
	pt_protocol = pt_root.get_child(protocol_strings::RESPONSE);
	status = (PROTOCOL_RESP_STATUS)pt_protocol.get<int>(protocol_strings::STATUS);
	UNPACK_JSON_END
}

bool get_signature_list_req::pack(std::string& json)
{
	PACK_JSON_BEGIN
	pt_protocol.add(protocol