1 /************************************************************************** 2 * 3 * Copyright 2010-2016 VMware, Inc. 4 * All Rights Reserved. 5 * 6 * Permission is hereby granted, free of charge, to any person obtaining a copy 7 * of this software and associated documentation files (the "Software"), to deal 8 * in the Software without restriction, including without limitation the rights 9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 * copies of the Software, and to permit persons to whom the Software is 11 * furnished to do so, subject to the following conditions: 12 * 13 * The above copyright notice and this permission notice shall be included in 14 * all copies or substantial portions of the Software. 15 * 16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 * THE SOFTWARE. 23 * 24 **************************************************************************/ 25 26 27 #pragma once 28 29 #include "highlight.hpp" 30 #include "trace_dump.hpp" 31 32 33 namespace trace { 34 35 36 class Dumper : public Visitor 37 { 38 protected: 39 std::ostream &os; 40 DumpFlags dumpFlags; 41 const highlight::Highlighter & highlighter; 42 const highlight::Attribute & normal; 43 const highlight::Attribute & bold; 44 const highlight::Attribute & italic; 45 const highlight::Attribute & strike; 46 const highlight::Attribute & red; 47 const highlight::Attribute & pointer; 48 const highlight::Attribute & literal; 49 50 public: 51 Dumper(std::ostream &_os, DumpFlags _flags); 52 virtual ~Dumper(); 53 54 virtual void visit(Null *) override; 55 virtual void visit(Bool *node) override; 56 virtual void visit(SInt *node) override; 57 virtual void visit(UInt *node) override; 58 virtual void visit(Float *node) override; 59 virtual void visit(Double *node) override; 60 61 template< typename C > 62 void visitString(const C *value); 63 virtual void visit(String *node) override; 64 virtual void visit(WString *node) override; 65 virtual void visit(Enum *node) override; 66 virtual void visit(Bitmask *bitmask) override; 67 virtual const char * 68 visitMembers(Struct *s, const char *sep = ""); 69 virtual void visit(Struct *s) override; 70 virtual void visit(Array *array) override; 71 virtual void visit(Blob *blob) override; 72 virtual void visit(Pointer *p) override; 73 virtual void visit(Repr *r) override; 74 virtual void visit(StackFrame *frame); 75 virtual void visit(Backtrace & backtrace); 76 virtual void visit(Call *call); 77 }; 78 79 80 } /* namespace trace */ 81 82