]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/tools/lldb-mi/MICmnMIValueConst.cpp
MFV r353613: 10731 zfs: NULL pointer errors
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lldb / tools / lldb-mi / MICmnMIValueConst.cpp
1 //===-- MICmnMIValueConst.cpp -----------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8
9 // In-house headers:
10 #include "MICmnMIValueConst.h"
11
12 // Instantiations:
13 const CMIUtilString CMICmnMIValueConst::ms_constStrDblQuote("\"");
14
15 //++
16 // Details: CMICmnMIValueConst constructor.
17 // Type:    Method.
18 // Args:    vString - (R) MI Const c-string value.
19 // Return:  None.
20 // Throws:  None.
21 //--
22 CMICmnMIValueConst::CMICmnMIValueConst(const CMIUtilString &vString)
23     : m_strPartConst(vString), m_bNoQuotes(false) {
24   BuildConst();
25 }
26
27 //++
28 // Details: CMICmnMIValueConst constructor.
29 // Type:    Method.
30 // Args:    vString     - (R) MI Const c-string value.
31 //          vbNoQuotes  - (R) True = return string not surrounded with quotes,
32 //          false = use quotes.
33 // Return:  None.
34 // Throws:  None.
35 //--
36 CMICmnMIValueConst::CMICmnMIValueConst(const CMIUtilString &vString,
37                                        const bool vbNoQuotes)
38     : m_strPartConst(vString), m_bNoQuotes(vbNoQuotes) {
39   BuildConst();
40 }
41
42 //++
43 // Details: CMICmnMIValueConst destructor.
44 // Type:    Overrideable.
45 // Args:    None.
46 // Return:  None.
47 // Throws:  None.
48 //--
49 CMICmnMIValueConst::~CMICmnMIValueConst() {}
50
51 //++
52 // Details: Build the Value Const data.
53 // Type:    Method.
54 // Args:    None.
55 // Return:  MIstatus::success - Functional succeeded.
56 //          MIstatus::failure - Functional failed.
57 // Throws:  None.
58 //--
59 bool CMICmnMIValueConst::BuildConst() {
60   if (m_strPartConst.length() != 0) {
61     const CMIUtilString strValue(m_strPartConst.StripCREndOfLine());
62     if (m_bNoQuotes) {
63       m_strValue = strValue;
64     } else {
65       const char *pFormat = "%s%s%s";
66       m_strValue =
67           CMIUtilString::Format(pFormat, ms_constStrDblQuote.c_str(),
68                                 strValue.c_str(), ms_constStrDblQuote.c_str());
69     }
70   } else {
71     const char *pFormat = "%s%s";
72     m_strValue = CMIUtilString::Format(pFormat, ms_constStrDblQuote.c_str(),
73                                        ms_constStrDblQuote.c_str());
74   }
75
76   return MIstatus::success;
77 }