Bruce Mitchener | 39e8823 | 2015-07-21 13:09:39 +0000 | [diff] [blame] | 1 | //===-- MICmnMIValueResult.cpp ----------------------------------*- C++ -*-===// |
Deepak Panickal | 6f9c468 | 2014-05-16 10:51:01 +0000 | [diff] [blame] | 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 | |
Deepak Panickal | 6f9c468 | 2014-05-16 10:51:01 +0000 | [diff] [blame] | 10 | // In-house headers: |
| 11 | #include "MICmnMIValueResult.h" |
| 12 | #include "MICmnResources.h" |
| 13 | |
| 14 | // Instantiations: |
Zachary Turner | 1d6af02 | 2014-11-17 18:06:21 +0000 | [diff] [blame] | 15 | const CMIUtilString CMICmnMIValueResult::ms_constStrEqual("="); |
Deepak Panickal | 6f9c468 | 2014-05-16 10:51:01 +0000 | [diff] [blame] | 16 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 17 | //++ |
| 18 | //------------------------------------------------------------------------------------ |
Zachary Turner | 1d6af02 | 2014-11-17 18:06:21 +0000 | [diff] [blame] | 19 | // Details: CMICmnMIValueResult constructor. |
| 20 | // Type: Method. |
| 21 | // Args: None. |
| 22 | // Return: None. |
| 23 | // Throws: None. |
Deepak Panickal | 6f9c468 | 2014-05-16 10:51:01 +0000 | [diff] [blame] | 24 | //-- |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 25 | CMICmnMIValueResult::CMICmnMIValueResult() : m_bEmptyConstruction(true) {} |
Deepak Panickal | 6f9c468 | 2014-05-16 10:51:01 +0000 | [diff] [blame] | 26 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 27 | //++ |
| 28 | //------------------------------------------------------------------------------------ |
Zachary Turner | 1d6af02 | 2014-11-17 18:06:21 +0000 | [diff] [blame] | 29 | // Details: CMICmnMIValueResult constructor. |
| 30 | // Type: Method. |
| 31 | // Args: vrVariable - (R) MI value's name. |
| 32 | // vrValue - (R) The MI value. |
| 33 | // Return: None. |
| 34 | // Throws: None. |
Deepak Panickal | 6f9c468 | 2014-05-16 10:51:01 +0000 | [diff] [blame] | 35 | //-- |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 36 | CMICmnMIValueResult::CMICmnMIValueResult(const CMIUtilString &vrVariable, |
| 37 | const CMICmnMIValue &vrValue) |
| 38 | : m_strPartVariable(vrVariable), m_partMIValue(vrValue), |
| 39 | m_bEmptyConstruction(false), m_bUseSpacing(false) { |
| 40 | BuildResult(); |
Deepak Panickal | 6f9c468 | 2014-05-16 10:51:01 +0000 | [diff] [blame] | 41 | } |
| 42 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 43 | //++ |
| 44 | //------------------------------------------------------------------------------------ |
Zachary Turner | 1d6af02 | 2014-11-17 18:06:21 +0000 | [diff] [blame] | 45 | // Details: CMICmnMIValueResult constructor. |
| 46 | // Type: Method. |
| 47 | // Args: vrVariable - (R) MI value's name. |
| 48 | // vrValue - (R) The MI value. |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 49 | // vbUseSpacing - (R) True = put space separators into the string, |
| 50 | // false = no spaces used. |
Zachary Turner | 1d6af02 | 2014-11-17 18:06:21 +0000 | [diff] [blame] | 51 | // Return: None. |
| 52 | // Throws: None. |
Deepak Panickal | 6f9c468 | 2014-05-16 10:51:01 +0000 | [diff] [blame] | 53 | //-- |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 54 | CMICmnMIValueResult::CMICmnMIValueResult(const CMIUtilString &vrVariable, |
| 55 | const CMICmnMIValue &vrValue, |
| 56 | const bool vbUseSpacing) |
| 57 | : m_strPartVariable(vrVariable), m_partMIValue(vrValue), |
| 58 | m_bEmptyConstruction(false), m_bUseSpacing(vbUseSpacing) { |
| 59 | BuildResult(); |
Deepak Panickal | 6f9c468 | 2014-05-16 10:51:01 +0000 | [diff] [blame] | 60 | } |
| 61 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 62 | //++ |
| 63 | //------------------------------------------------------------------------------------ |
Zachary Turner | 1d6af02 | 2014-11-17 18:06:21 +0000 | [diff] [blame] | 64 | // Details: CMICmnMIValueResult destructor. |
| 65 | // Type: Overrideable. |
| 66 | // Args: None. |
| 67 | // Return: None. |
| 68 | // Throws: None. |
Deepak Panickal | 6f9c468 | 2014-05-16 10:51:01 +0000 | [diff] [blame] | 69 | //-- |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 70 | CMICmnMIValueResult::~CMICmnMIValueResult() {} |
Deepak Panickal | 6f9c468 | 2014-05-16 10:51:01 +0000 | [diff] [blame] | 71 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 72 | //++ |
| 73 | //------------------------------------------------------------------------------------ |
Zachary Turner | 1d6af02 | 2014-11-17 18:06:21 +0000 | [diff] [blame] | 74 | // Details: Build the MI value result string. |
| 75 | // Type: Method. |
| 76 | // Args: None. |
Bruce Mitchener | 2c674d3 | 2015-07-22 17:07:27 +0000 | [diff] [blame] | 77 | // Return: None. |
Zachary Turner | 1d6af02 | 2014-11-17 18:06:21 +0000 | [diff] [blame] | 78 | // Throws: None. |
Deepak Panickal | 6f9c468 | 2014-05-16 10:51:01 +0000 | [diff] [blame] | 79 | //-- |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 80 | void CMICmnMIValueResult::BuildResult() { |
| 81 | const char *pFormat = m_bUseSpacing ? "%s %s %s" : "%s%s%s"; |
| 82 | m_strValue = CMIUtilString::Format(pFormat, m_strPartVariable.c_str(), |
| 83 | ms_constStrEqual.c_str(), |
| 84 | m_partMIValue.GetString().c_str()); |
Deepak Panickal | 6f9c468 | 2014-05-16 10:51:01 +0000 | [diff] [blame] | 85 | } |
| 86 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 87 | //++ |
| 88 | //------------------------------------------------------------------------------------ |
Zachary Turner | 1d6af02 | 2014-11-17 18:06:21 +0000 | [diff] [blame] | 89 | // Details: Build the MI value result string. |
| 90 | // Type: Method. |
| 91 | // Args: vrVariable - (R) MI value's name. |
| 92 | // vrValue - (R) The MI value. |
Bruce Mitchener | 2c674d3 | 2015-07-22 17:07:27 +0000 | [diff] [blame] | 93 | // Return: None. |
Zachary Turner | 1d6af02 | 2014-11-17 18:06:21 +0000 | [diff] [blame] | 94 | // Throws: None. |
Deepak Panickal | 6f9c468 | 2014-05-16 10:51:01 +0000 | [diff] [blame] | 95 | //-- |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 96 | void CMICmnMIValueResult::BuildResult(const CMIUtilString &vVariable, |
| 97 | const CMICmnMIValue &vValue) { |
| 98 | const char *pFormat = m_bUseSpacing ? "%s, %s %s %s" : "%s,%s%s%s"; |
| 99 | m_strValue = CMIUtilString::Format( |
| 100 | pFormat, m_strValue.c_str(), vVariable.c_str(), ms_constStrEqual.c_str(), |
| 101 | vValue.GetString().c_str()); |
Deepak Panickal | 6f9c468 | 2014-05-16 10:51:01 +0000 | [diff] [blame] | 102 | } |
| 103 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 104 | //++ |
| 105 | //------------------------------------------------------------------------------------ |
Zachary Turner | 1d6af02 | 2014-11-17 18:06:21 +0000 | [diff] [blame] | 106 | // Details: Append another MI value object to *this MI value result. |
| 107 | // Type: Method. |
| 108 | // Args: vrVariable - (R) MI value's name. |
| 109 | // vrValue - (R) The MI value. |
| 110 | // Return: MIstatus::success - Functional succeeded. |
| 111 | // MIstatus::failure - Functional failed. |
| 112 | // Throws: None. |
Deepak Panickal | 6f9c468 | 2014-05-16 10:51:01 +0000 | [diff] [blame] | 113 | //-- |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 114 | void CMICmnMIValueResult::Add(const CMIUtilString &vrVariable, |
| 115 | const CMICmnMIValue &vrValue) { |
| 116 | if (!m_bEmptyConstruction) |
| 117 | BuildResult(vrVariable, vrValue); |
| 118 | else { |
| 119 | m_bEmptyConstruction = false; |
| 120 | m_strPartVariable = vrVariable; |
| 121 | m_partMIValue = vrValue; |
| 122 | BuildResult(); |
| 123 | } |
Deepak Panickal | 6f9c468 | 2014-05-16 10:51:01 +0000 | [diff] [blame] | 124 | } |