netwerk/base/nsBase64Encoder.h
author Wes Kocher <wkocher@mozilla.com>
Fri, 12 May 2017 18:24:42 -0700
changeset 358155 d7711b69b0136381c4da5cd292619d514ffee1ee
parent 234863 ac4464790ec4896a5188fa50cfc69ae0ffeddc08
child 365628 6352096eb0de303cba9440092279e4254a1ec586
permissions -rw-r--r--
Backed out changeset 95ff98f1c2e5 (bug 1319111) for talos failures a=backout MozReview-Commit-ID: Gs09moFm5rQ

/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#ifndef NSBASE64ENCODER_H_
#define NSBASE64ENCODER_H_

#include "nsIOutputStream.h"
#include "nsString.h"
#include "mozilla/Attributes.h"

/**
 * A base64 encoder. Usage: Instantiate class, write to it using
 * Write(), then call Finish() to get the base64-encoded data.
 */
class nsBase64Encoder final : public nsIOutputStream {
  public:
    nsBase64Encoder() {}

    NS_DECL_ISUPPORTS
    NS_DECL_NSIOUTPUTSTREAM

    nsresult Finish(nsCSubstring& _result);
  private:
    ~nsBase64Encoder() {}

    /// The data written to this stream. nsCString can deal fine with
    /// binary data.
    nsCString mData;
};

#endif