<commit_before>/*
 * Copyright (C) 2010 
 * Written by:
 * <NAME> <<EMAIL>>
 * <NAME> <<EMAIL>>
 *
 * All Rights Reserved
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 */

#ifndef FACEBOOK_AUTHORIZED_OBJECT_H_
#define FACEBOOK_AUTHORIZED_OBJECT_H_

#include "HttpRequest.h"

namespace Facebook
{

class ResponseBlob;
class HttpRequest;
struct PagingInfo;
struct Uri;

// XXX: Move this elsewhere
enum FACEBOOK_API FACEBOOK_PICTURE_SIZE
{
	FPS_SQUARE,
	FPS_SMALL,
	FPS_LARGE,

	FPS_COUNT
};


class AuthorizedObject
{
protected:
	void Init(const AuthorizedObject &obj);
	void Init(const shared_ptr<HttpRequest>& request);

private:
	void Deserialize(const AuthorizedObject &parent_obj, const Json::Value &json);

protected: // interface
	AuthorizedObject() { }

	virtual void _Deserialize(const AuthorizedObject &parent_obj, const Json::Value &json) = 0;

	template<class TType>
	void _GetConnection(const std::string &id, const std::string &page, TType *t) const
	{
		FACEBOOK_ASSERT(t);

		Uri uri;
		request_->GetUri(&uri);

		std::ostringstream base_uri;
		base_uri << "https://graph.facebook.com/" << curlpp::escape(id) << "/" << curlpp::escape(page);
		uri.base_uri = base_uri.str();

		Json::Value value;
		request_->GetResponse(uri, &value);

		t->Deserialize(*this, value);
	}

	void _GetPictureConnection(const std::string &id, FACEBOOK_PICTURE_SIZE size, ResponseBlob *blob) const;

	template<class TType>
	void _GetConnection(const std::string &id, const std::string &page, std::list<TType> *list, const PagingInfo *paging) const
	{
		FACEBOOK_ASSERT(list);

		Uri uri;
		request_->GetUri(&uri);
<commit_msg>Modifying helper function signatures to accept const char* where the input is known to be a const static string<commit_after>/*
 * Copyright (C) 2010 
 * Written by:
 * <NAME> <<EMAIL>>
 * <NAME> <<EMAIL>>
 *
 * All Rights Reserved
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 */

#ifndef FACEBOOK_AUTHORIZED_OBJECT_H_
#define FACEBOOK_AUTHORIZED_OBJECT_H_

#include "HttpRequest.h"

namespace Facebook
{

class ResponseBlob;
class HttpRequest;
struct PagingInfo;
struct Uri;

// XXX: Move this elsewhere
enum FACEBOOK_API FACEBOOK_PICTURE_SIZE
{
	FPS_SQUARE,
	FPS_SMALL,
	FPS_LARGE,

	FPS_COUNT
};


class AuthorizedObject
{
protected:
	void Init(const AuthorizedObject &obj);
	void Init(const shared_ptr<HttpRequest>& request);

private:
	void Deserialize(const AuthorizedObject &parent_obj, const Json::Value &json);

protected: // interface
	AuthorizedObject() { }

	virtual void _Deserialize(const AuthorizedObject &parent_obj, const Json::Value &json) = 0;

	template<class TType>
	void _GetConnection(const std::string &id, const char *page, TType *t) const
	{
		FACEBOOK_ASSERT(page);
		FACEBOOK_ASSERT(t);

		Uri uri;
		request_->GetUri(&uri);

		std::ostringstream base_uri;
		base_uri << "https://graph.facebook.com/" << curlpp::escape(id) << "/" << curlpp::escape(page);
		uri.base_uri = base_uri.str();

		Json::Value value;
		request_->GetResponse(uri, &value);

		t->Deserialize(*this, value);
	}

	void _GetPictureConnection(const std::string &id, FACEBOOK_PICTURE_SIZE size, ResponseBlob *blob) const;

	template<class TType>
	void _GetConnection(const std::string &id, const char *page, std::list<TType> *list, const PagingInfo *paging) const
	{
		FACEBOOK_ASSERT(page);
		FACEBOOK_ASSERT(list);

		Uri uri;
		request_->GetUri(&uri);

{'fraction_non_alphanumeric': 0.10512939001848429, 'fraction_numerical': 0.003234750462107209, 'mean_word_length': 4.971034482758621, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 31, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4702255', 'n_tokens_mistral': 1444, 'n_tokens_neox': 1374, 'n_words': 440}