コード例 #1
0
ファイル: User.cpp プロジェクト: pabloalbanese/taller2
string User::GetJsonByUserContentList(std::list<UserContent*> list, bool full)
{
	string json;
	for (std::list<UserContent*>::iterator it=list.begin(); it != list.end(); ++it)
	{
		json += "{";
		json += "\"identifier\" : " + std::to_string((*it)->identifier)  + ",";
		json += "\"type\" : " + std::to_string((*it)->type) + ",";

		if(full)
		{
			File* file = new File();
			file->Load((*it)->identifier);

			json += "\"name\" : \"" + file->GetName() + "\",";
			json += "\"extension\" : \"" + file->GetExtension() + "\",";
			json += "\"sizeMB\" : " + std::to_string(file->GetSize()) + ",";
			json += "\"owner\" : " + file->GetOwner() + ",";
			json += "\"tags\" : " + file->GetTagsStr() + ",";
			if(file->IsDeleted())
				json += "\"delete\" : true,";
			else
				json += "\"delete\" : false,";
			json += "\"lastModifiedBy\" : \"" + file->GetLastModifiedBy() + "\", ";
			json += "\"lastModifiedOn\" : \"" + to_string(file->GetLastModifiedOn())+ "\",";
			json += "\"lastVersion\" : " + std::to_string(file->GetLastVersion()) + ",";
			json += "\"versions\" :" + file->GetVersionsStr() + ",";

			delete file;
		}

		json += "\"content\" : [";
		if((*it)->type == 2)
			json += GetJsonByUserContentList((*it)->content, full);
		json += "]";
		json += "},";
	}
	return json.substr(0, json.length() - 1);
}
コード例 #2
0
ファイル: User.cpp プロジェクト: pabloalbanese/taller2
string User::GetJsonBySharedFilesList(bool full)
{
	string json;
	for (std::list<int>::iterator it=sharedFiles.begin(); it != sharedFiles.end(); ++it)
	{
		if(full)
		{
			File* file = new File();
			file->Load(*it);

			json += "{";
			json += "\"identifier\" : " + std::to_string(file->GetIdentifier())  + ",";
			json += "\"type\" : " + std::to_string(file->GetType()) + ",";
			json += "\"name\" : \"" + file->GetName() + "\",";
			json += "\"extension\" : \"" + file->GetExtension() + "\",";
			json += "\"sizeMB\" : " + std::to_string(file->GetSize()) + ",";
			json += "\"owner\" : " + file->GetOwner() + ",";
			json += "\"tags\" : " + file->GetTagsStr() + ",";
			if(file->IsDeleted())
				json += "\"delete\" : true,";
			else
				json += "\"delete\" : false,";
			json += "\"lastModifiedOn\" : \"" + to_string(file->GetLastModifiedOn()) + "\",";
			json += "\"lastModifiedBy\" : \"" + file->GetLastModifiedBy() + "\",";
			json += "\"lastVersion\" : " + std::to_string(file->GetLastVersion()) + ",";
			json += "\"versions\" : " + file->GetVersionsStr();

			delete file;

			json += "},";

		}
		else
			json += std::to_string(*it) + ",";
	}
	return json.substr(0, json.length() - 1);
}