tools/profiler/JSStreamWriter.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     2 /* This Source Code Form is subject to the terms of the Mozilla Public
     3  * License, v. 2.0. If a copy of the MPL was not distributed with this
     4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     6 #ifndef JSSTREAMWRITER_H
     7 #define JSSTREAMWRITER_H
     9 #include <ostream>
    10 #include <stdlib.h>
    11 #include "nsDeque.h"
    13 class JSStreamWriter
    14 {
    15 public:
    16   JSStreamWriter(std::ostream& aStream);
    17   ~JSStreamWriter();
    19   void BeginObject();
    20   void EndObject();
    21   void BeginArray();
    22   void EndArray();
    23   void Name(const char *name);
    24   void Value(int value);
    25   void Value(double value);
    26   void Value(const char *value, size_t valueLength);
    27   void Value(const char *value);
    28   template <typename T>
    29   void NameValue(const char *aName, T aValue)
    30   {
    31     Name(aName);
    32     Value(aValue);
    33   }
    35 private:
    36   std::ostream& mStream;
    37   bool mNeedsComma;
    38   bool mNeedsName;
    40   nsDeque mStack;
    42   // This class can't be copied
    43   JSStreamWriter(const JSStreamWriter&);
    44   JSStreamWriter& operator=(const JSStreamWriter&);
    46   void* operator new(size_t);
    47   void* operator new[](size_t);
    48   void operator delete(void*) {
    49     // Since JSStreamWriter has a virtual destructor the compiler
    50     // has to provide a destructor in the object file that will call
    51     // operate delete in case there is a derived class since its
    52     // destructor won't know how to free this instance.
    53     abort();
    54   }
    55   void operator delete[](void*);
    56 };
    58 #endif

mercurial