Logo ROOT  
Reference Guide
TClingValue.cxx
Go to the documentation of this file.
1// @(#)root/core/meta:$Id$
2// Author: Vassil Vassilev 14/03/2013
3
4/*******************************************************************************
5* Copyright (C) 1995-2013, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 ******************************************************************************/
11
12/** \class TClingValue
13Bridge between cling::Value and ROOT.
14*/
15
16#include "TClingValue.h"
17
18#include "cling/Interpreter/Value.h"
19#include "llvm/Support/raw_ostream.h"
20
21#include <cassert>
22
24 // We default initialize to invalid value to keep a "sane" state.
25 assert(sizeof(fValue) >= sizeof(cling::Value)
26 && "sizeof(fValue) too small!");
27 new (&fValue) cling::Value();
28}
29
32 assert(sizeof(fValue) >= sizeof(cling::Value)
33 && "sizeof(fValue) too small!");
34 new (&fValue) cling::Value(Other.ToCV());
35}
36
38 ToCV().~Value();
39}
40
42 using namespace cling;
43 ToCV() = Other.ToCV();
44 return *this;
45}
46
47std::pair<std::string, std::string> TClingValue::ToTypeAndValueString() const {
48 std::string output = ToString();
49 int paren_level = 0;
50
51 for (size_t pos = 0; pos < output.size(); ++pos) {
52 if (output[pos] == '(')
53 ++paren_level;
54 else if (output[pos] == ')') {
55 --paren_level;
56 if (!paren_level)
57 return std::make_pair(output.substr(0, pos + 1), output.substr(pos + 2));
58 }
59 }
60
61 return std::make_pair("", output);
62}
63
65 return ToCV().isValid();
66}
67
69 return ToCV().getDouble();
70}
71
73 return ToCV().getLL();
74}
75
77 return ToCV().getULL();
78}
79
81 return ToCV().getPtr();
82}
83
84std::string TClingValue::ToString() const {
85 std::string retVal;
86 llvm::raw_string_ostream ost(retVal);
87 ToCV().print(ost);
88 return ost.str();
89}
long Long_t
Definition: RtypesCore.h:54
unsigned long ULong_t
Definition: RtypesCore.h:55
Bridge between cling::Value and ROOT.
Definition: TClingValue.h:36
ULong_t GetAsUnsignedLong() const override
Definition: TClingValue.cxx:76
std::pair< std::string, std::string > ToTypeAndValueString() const override
Definition: TClingValue.cxx:47
TClingValue & operator=(TClingValue &Other)
Definition: TClingValue.cxx:41
struct TClingValue::HasTheSameSizeAsClingValue fValue
Bool_t IsValid() const override
Definition: TClingValue.cxx:64
void * GetAsPointer() const override
Definition: TClingValue.cxx:80
Long_t GetAsLong() const override
Definition: TClingValue.cxx:72
Double_t GetAsDouble() const override
Definition: TClingValue.cxx:68
std::string ToString() const override
Definition: TClingValue.cxx:84
cling::Value & ToCV()
Definition: TClingValue.h:45
const char * Value
Definition: TXMLSetup.cxx:73
static void output()