Skip to content

Instantly share code, notes, and snippets.

@mntone
Last active December 29, 2015 17:39
Show Gist options
  • Save mntone/7705926 to your computer and use it in GitHub Desktop.
Save mntone/7705926 to your computer and use it in GitHub Desktop.
niconico_context 管理用クラス。実装段階。 (Nov 2013 CTP)
#pragma once
namespace mntone { namespace niconico {
/// <summary>
/// niconico の API 用コンテクストを管理します
/// </summary>
class niconico_context
{
public:
niconico_context() = default;
niconico_context( const niconico_context& ) = default;
niconico_context( niconico_context&& ) = default;
explicit niconico_context( ::utility::string_t mail, ::utility::string_t password ):
mail_( ::std::move( mail ) ), password_( ::std::move( password ) )
{ }
explicit niconico_context( ::utility::string_t mail, ::utility::string_t password, ::utility::string_t session ) :
mail_( std::move( mail ) ), password_( std::move( password ) ), session_( std::move( session ) )
{ }
::pplx::task<::utility::string_t> login();
const ::utility::string_t& mail() const noexcept { return mail_; }
void set_mail( ::utility::string_t value ) noexcept { mail_ = ::std::move( value ); }
const ::utility::string_t& password() const noexcept { return password_; }
void set_password( ::utility::string_t value ) noexcept { password_ = ::std::move( value ); }
const ::utility::string_t& session() const noexcept { return session_; }
void set_session( ::utility::string_t value ) noexcept { session_ = ::std::move( value ); }
niconico_context& operator=( const niconico_context& rhs ) noexcept
{
niconico_context( rhs ).swap( *this );
return *this;
}
niconico_context& operator=( niconico_context&& ) = default;
void swap( niconico_context& other ) noexcept
{
::std::swap( mail_, other.mail_ );
::std::swap( password_, other.password_ );
::std::swap( session_, other.session_ );
}
friend void swap( niconico_context& left, niconico_context& right ) noexcept
{
left.swap( right );
}
private:
::utility::string_t mail_, password_, session_;
};
} }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment