DDLogValue.h (1425B)
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim:set ts=2 sw=2 sts=2 et cindent: */ 3 /* This Source Code Form is subject to the terms of the Mozilla Public 4 * License, v. 2.0. If a copy of the MPL was not distributed with this 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 #ifndef DDLogValue_h_ 8 #define DDLogValue_h_ 9 10 #include "DDLogObject.h" 11 #include "MediaResult.h" 12 #include "mozilla/Variant.h" 13 #include "nsString.h" 14 15 namespace mozilla { 16 17 // Placeholder when no value is needed. 18 struct DDNoValue {}; 19 20 // Value capturing a range (typically an offset and a number of bytes in a 21 // resource). 22 struct DDRange { 23 const int64_t mOffset; 24 const int64_t mBytes; 25 DDRange(int64_t aOffset, int64_t aBytes) : mOffset(aOffset), mBytes(aBytes) {} 26 }; 27 28 // Value associated with a log message. 29 using DDLogValue = Variant<DDNoValue, DDLogObject, 30 const char*, // Assumed to be a literal string. 31 const nsCString, bool, int8_t, uint8_t, int16_t, 32 uint16_t, int32_t, uint32_t, int64_t, uint64_t, 33 double, DDRange, nsresult, MediaResult>; 34 35 void AppendToString(const DDLogValue& aValue, nsCString& aString); 36 37 class JSONWriter; 38 void ToJSON(const DDLogValue& aValue, JSONWriter& aJSONWriter, 39 const char* aPropertyName); 40 41 } // namespace mozilla 42 43 #endif // DDLogValue_h_