#ifndef SECURESTRING_H
#define SECURESTRING_H

#include <string>

/// Class to safely store secrets
///
/// The used memory is wiped after destruction.
class SecureString
{
  public:
    // Initial creation
    // `str` will be overwritten and cleared after return
    SecureString(std::string &str);
    ~SecureString();

    SecureString(const SecureString &) = delete;
    SecureString &operator=(const SecureString &) = delete;
    SecureString(SecureString &&) = delete;
    SecureString &operator=(SecureString &&) = delete;

    // Return a '\0' delimited C-string
    const char *c_str() const;

    bool empty() const;

  private:
    char *m_data;
    size_t m_len; // length including '\0'
};

#endif // SECURESTRING_H
