]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/source/DataFormatters/TypeValidator.cpp
Update expat to 2.2.6
[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/Utility/StreamString.h"
19
20 using namespace lldb;
21 using namespace lldb_private;
22
23 TypeValidatorImpl::TypeValidatorImpl(const Flags &flags)
24     : m_flags(flags), m_my_revision(0) {}
25
26 TypeValidatorImpl::~TypeValidatorImpl() {}
27
28 TypeValidatorImpl::ValidationResult TypeValidatorImpl::Success() {
29   return ValidationResult{TypeValidatorResult::Success, ""};
30 }
31
32 TypeValidatorImpl::ValidationResult
33 TypeValidatorImpl::Failure(std::string message) {
34   return ValidationResult{TypeValidatorResult::Failure, message};
35 }
36
37 TypeValidatorImpl_CXX::TypeValidatorImpl_CXX(
38     ValidatorFunction f, std::string d, const TypeValidatorImpl::Flags &flags)
39     : TypeValidatorImpl(flags), m_description(d), m_validator_function(f) {}
40
41 TypeValidatorImpl_CXX::~TypeValidatorImpl_CXX() {}
42
43 TypeValidatorImpl::ValidationResult
44 TypeValidatorImpl_CXX::FormatObject(ValueObject *valobj) const {
45   if (!valobj)
46     return Success(); // I guess there's nothing wrong with a null valueobject..
47
48   return m_validator_function(valobj);
49 }
50
51 std::string TypeValidatorImpl_CXX::GetDescription() {
52   StreamString sstr;
53   sstr.Printf("%s%s%s%s", m_description.c_str(),
54               Cascades() ? "" : " (not cascading)",
55               SkipsPointers() ? " (skip pointers)" : "",
56               SkipsReferences() ? " (skip references)" : "");
57   return sstr.GetString();
58 }