]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - tools/lldb-mi/MICmnMIValueConst.cpp
Vendor import of lldb trunk r290819:
[FreeBSD/FreeBSD.git] / tools / lldb-mi / MICmnMIValueConst.cpp
1 //===-- MICmnMIValueConst.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 // In-house headers:
11 #include "MICmnMIValueConst.h"
12
13 // Instantiations:
14 const CMIUtilString CMICmnMIValueConst::ms_constStrDblQuote("\"");
15
16 //++
17 //------------------------------------------------------------------------------------
18 // Details: CMICmnMIValueConst constructor.
19 // Type:    Method.
20 // Args:    vString - (R) MI Const c-string value.
21 // Return:  None.
22 // Throws:  None.
23 //--
24 CMICmnMIValueConst::CMICmnMIValueConst(const CMIUtilString &vString)
25     : m_strPartConst(vString), m_bNoQuotes(false) {
26   BuildConst();
27 }
28
29 //++
30 //------------------------------------------------------------------------------------
31 // Details: CMICmnMIValueConst constructor.
32 // Type:    Method.
33 // Args:    vString     - (R) MI Const c-string value.
34 //          vbNoQuotes  - (R) True = return string not surrounded with quotes,
35 //          false = use quotes.
36 // Return:  None.
37 // Throws:  None.
38 //--
39 CMICmnMIValueConst::CMICmnMIValueConst(const CMIUtilString &vString,
40                                        const bool vbNoQuotes)
41     : m_strPartConst(vString), m_bNoQuotes(vbNoQuotes) {
42   BuildConst();
43 }
44
45 //++
46 //------------------------------------------------------------------------------------
47 // Details: CMICmnMIValueConst destructor.
48 // Type:    Overrideable.
49 // Args:    None.
50 // Return:  None.
51 // Throws:  None.
52 //--
53 CMICmnMIValueConst::~CMICmnMIValueConst() {}
54
55 //++
56 //------------------------------------------------------------------------------------
57 // Details: Build the Value Const data.
58 // Type:    Method.
59 // Args:    None.
60 // Return:  MIstatus::success - Functional succeeded.
61 //          MIstatus::failure - Functional failed.
62 // Throws:  None.
63 //--
64 bool CMICmnMIValueConst::BuildConst() {
65   if (m_strPartConst.length() != 0) {
66     const CMIUtilString strValue(m_strPartConst.StripCREndOfLine());
67     if (m_bNoQuotes) {
68       m_strValue = strValue;
69     } else {
70       const char *pFormat = "%s%s%s";
71       m_strValue =
72           CMIUtilString::Format(pFormat, ms_constStrDblQuote.c_str(),
73                                 strValue.c_str(), ms_constStrDblQuote.c_str());
74     }
75   } else {
76     const char *pFormat = "%s%s";
77     m_strValue = CMIUtilString::Format(pFormat, ms_constStrDblQuote.c_str(),
78                                        ms_constStrDblQuote.c_str());
79   }
80
81   return MIstatus::success;
82 }