]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/source/DataFormatters/TypeValidator.cpp
MFV r302260: expat 2.2.0
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lldb / source / DataFormatters / TypeValidator.cpp
1 //===-- TypeValidator.cpp ---------------------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 // C Includes
11
12 // C++ Includes
13
14 // Other libraries and framework includes
15
16 // Project includes
17 #include "lldb/DataFormatters/TypeValidator.h"
18 #include "lldb/Core/StreamString.h"
19
20 using namespace lldb;
21 using namespace lldb_private;
22
23 TypeValidatorImpl::TypeValidatorImpl(const Flags &flags) :
24     m_flags(flags),
25     m_my_revision(0)
26 {
27 }
28
29 TypeValidatorImpl::~TypeValidatorImpl()
30 {
31 }
32
33 TypeValidatorImpl::ValidationResult
34 TypeValidatorImpl::Success ()
35 {
36     return ValidationResult { TypeValidatorResult::Success, "" };
37 }
38
39 TypeValidatorImpl::ValidationResult
40 TypeValidatorImpl::Failure (std::string message)
41 {
42     return ValidationResult { TypeValidatorResult::Failure, message };
43 }
44
45 TypeValidatorImpl_CXX::TypeValidatorImpl_CXX (ValidatorFunction f, std::string d, const TypeValidatorImpl::Flags& flags) :
46     TypeValidatorImpl(flags),
47     m_description(d),
48     m_validator_function(f)
49 {
50 }
51
52 TypeValidatorImpl_CXX::~TypeValidatorImpl_CXX()
53 {
54 }
55
56 TypeValidatorImpl::ValidationResult
57 TypeValidatorImpl_CXX::FormatObject (ValueObject *valobj) const
58 {
59     if (!valobj)
60         return Success(); // I guess there's nothing wrong with a null valueobject..
61     
62     return m_validator_function(valobj);
63 }
64
65 std::string
66 TypeValidatorImpl_CXX::GetDescription()
67 {
68     StreamString sstr;
69     sstr.Printf ("%s%s%s%s",
70                  m_description.c_str(),
71                  Cascades() ? "" : " (not cascading)",
72                  SkipsPointers() ? " (skip pointers)" : "",
73                  SkipsReferences() ? " (skip references)" : "");
74     return sstr.GetString();
75 }