Automatically generated with:
cp dom/.clang-format xpcom/ && mach format xpcom/**.{cpp,h}
Manual changes:
* nsTDependentSubstring.cpp was relying on include order, prevent that
from being changed by clang-format.
* Missing nsAtom.h include from nsGkAtoms.h
* nsWindowsHelpers.h needed to keep the include order
* MemoryPressureLevelMac.h needed mozilla/Attributes.h
Differential Revision: https://phabricator.services.mozilla.com/D311687
33 lines
1.2 KiB
C++
33 lines
1.2 KiB
C++
/* 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 mozilla_Hex_h_
|
|
#define mozilla_Hex_h_
|
|
|
|
#include <cstdint>
|
|
|
|
#include "mozilla/Span.h"
|
|
#include "nsStringFwd.h"
|
|
#include "nsTArrayForwardDeclare.h"
|
|
#include "nscore.h"
|
|
|
|
namespace mozilla {
|
|
|
|
// Replaces |aOut| with the hexadecimal encoding of |aBytes| (two characters per
|
|
// byte; e.g. {0xAB, 0x0C} becomes "ab0c"). The output is lowercase unless
|
|
// |aUpperCase| is true. This is the binary->text analogue of Base64Encode;
|
|
// prefer it over hand-rolling yet another hex loop.
|
|
void HexEncode(Span<const uint8_t> aBytes, nsACString& aOut,
|
|
bool aUpperCase = false);
|
|
|
|
// Decodes the hexadecimal text |aHex| into the raw bytes |aOut|, accepting
|
|
// upper- and lowercase digits; this is the inverse of HexEncode. Returns
|
|
// NS_ERROR_INVALID_ARG (and leaves |aOut| empty) if |aHex| has an odd length or
|
|
// contains a character outside [0-9a-fA-F].
|
|
nsresult HexDecode(const nsACString& aHex, nsTArray<uint8_t>& aOut);
|
|
|
|
} // namespace mozilla
|
|
|
|
#endif // mozilla_Hex_h_
|