| LicenseSpring C++ SDK 7.27.0 Easily add Software Licensing to your application

Public Member Functions | Static Public Member Functions | List of all members
LicenseSpring::LicenseID Class Reference

Class that represents License identifier. More...

`#include <LicenseSpring/LicenseID.h>`

## Public Member Functions
| LicenseID ()=default
| Default constructor, constructs invalid (empty) LicenseID. More...
| LicenseID (const LicenseID &)=default
| Default copy constructor. More...
bool | isEmpty () const
| Checks if LicenseID is empty. More...
bool | isValid () const
| Checks if LicenseID is valid. More...
const std::string & | id () const
| Returns license key or user identifier, depending of what is present. More...
const std::string & | key () const
| Returns license key or empty string, if key is not set (for example in case of user-based product). More...
const std::string & | user () const
| Returns user identifier or empty string, if user is not set (for example in case of key-based product). More...
const std::string & | password () const
| Returns user password or empty string, if password is not set. More...
void | setPassword (const std::string &password)
| Sets user password accordingly to provided string. More...
void | trim ()
| Remove trailing whitespaces from the end and beginning of ID (key or user and password). More...

## Static Public Member Functions
static LicenseID | fromKey (const std::string &licenseKey, bool needTrim=true)
| Constructs LicenseID with given license key. More...
static LicenseID | fromKey (const char *licenseKey)
| Constructs LicenseID with given license key. More...
static LicenseID | fromUser (const std::string &user, const std::string &password=std::string(), bool needTrim=true)
| Constructs LicenseID with given user credentials. More...
static LicenseID | fromUser (const char *user, const char *password=nullptr)
| Constructs LicenseID with given user credentials. More...

## Detailed Description

Class that represents License identifier.

For key-based products it is license key, for user-based products it is user credentials - user identifier (typically email) and password.
Please note: password only required for license activation, other API does not require password. This class does not throw exceptions.

Definition at line 18 of file LicenseID.h.

## Constructor & Destructor Documentation

## ◆ LicenseID() [1/2]

LicenseSpring::LicenseID::LicenseID | ( |  | ) |
| default

Default constructor, constructs invalid (empty) LicenseID.

## ◆ LicenseID() [2/2]

LicenseSpring::LicenseID::LicenseID | ( | const LicenseID & |  | ) |
| default

Default copy constructor.

## Member Function Documentation

## ◆ isEmpty()

bool LicenseSpring::LicenseID::isEmpty | ( |  | ) | const

Checks if LicenseID is empty.

LicenseID considered empty if both license key and user are empty strings.

Returns
  True if empty and false otherwise.

## ◆ isValid()

bool LicenseSpring::LicenseID::isValid | ( |  | ) | const

Checks if LicenseID is valid.

LicenseID considered valid if one of the members (key or user) is not empty. Equivalent of !isEmpty().

Returns
  True if valid and false otherwise.

## ◆ id()

const std::string& LicenseSpring::LicenseID::id | ( |  | ) | const

Returns license key or user identifier, depending of what is present.

Returns
  License key or user identifier string.

## ◆ key()

const std::string& LicenseSpring::LicenseID::key | ( |  | ) | const

Returns license key or empty string, if key is not set (for example in case of user-based product).

Returns
  License key or empty string.

## ◆ user()

const std::string& LicenseSpring::LicenseID::user | ( |  | ) | const

Returns user identifier or empty string, if user is not set (for example in case of key-based product).

Returns
  User identifier or empty string.

## ◆ password()

const std::string& LicenseSpring::LicenseID::password | ( |  | ) | const

Returns user password or empty string, if password is not set.

SDK does not store password on disk or anywhere else.

Returns
  Password or empty string.

## ◆ setPassword()

void LicenseSpring::LicenseID::setPassword | ( | const std::string & | password | ) |

Sets user password accordingly to provided string.

Parameters

  password | Password string.

## ◆ trim()

void LicenseSpring::LicenseID::trim | ( |  | ) |

Remove trailing whitespaces from the end and beginning of ID (key or user and password).

## ◆ fromKey() [1/2]

static LicenseID LicenseSpring::LicenseID::fromKey | ( | const std::string & | licenseKey,
|  | bool | needTrim = `true`
| ) |  |
| static

Constructs LicenseID with given license key.

The ID will be automatically trimmed, no need to call trim manually if you use this function.

Parameters

  licenseKey | The license key used to activate your license
  needTrim | Trims whitespaces from beginning and end of ID, if true. True by default.

Returns
  LicenseID object.

Note
  There are multiple methods with the same name and different parameters.

## ◆ fromKey() [2/2]

static LicenseID LicenseSpring::LicenseID::fromKey | ( | const char * | licenseKey | ) |
| static

Constructs LicenseID with given license key.

The ID will be automatically trimmed, no need to call trim manually if you use this function.

Parameters

  licenseKey | The license key used to activate your license

Returns
  LicenseID object.

Note
  There are multiple methods with the same name and different parameters.

## ◆ fromUser() [1/2]

static LicenseID LicenseSpring::LicenseID::fromUser | ( | const std::string & | user,
|  | const std::string & | password = `std::string()`,
|  | bool | needTrim = `true`
| ) |  |
| static

Constructs LicenseID with given user credentials.

The ID will be automatically trimmed, no need to call trim manually if you use this function.

Parameters

  user | The username for the license
  password | The corresponding password for the username, empty by default
  needTrim | Trims whitespaces from beginning and end of ID, if true. True by default.

Returns
  LicenseID object.

Note
  There are multiple methods with the same name and different parameters.

## ◆ fromUser() [2/2]

static LicenseID LicenseSpring::LicenseID::fromUser | ( | const char * | user,
|  | const char * | password = `nullptr`
| ) |  |
| static

Constructs LicenseID with given user credentials.

The ID will be automatically trimmed, no need to call trim manually if you use this function.

Parameters

  user | The username for the license
  password | The corresponding password for the username, empty by default

Returns
  LicenseID object.

Note
  There are multiple methods with the same name and different parameters.

The documentation for this class was generated from the following file:

- LicenseSpring/LicenseID.h