OpenXLSX 1.9.1
Loading...
Searching...
No Matches
OpenXLSX::XLCellValueProxy Class Reference

The XLCellValueProxy class is used for proxy (or placeholder) objects for XLCellValue objects. More...

#include <XLCellValue.hpp>

Public Member Functions

 ~XLCellValueProxy ()
 Destructor.
 
XLCellValueProxyoperator= (const XLCellValueProxy &other)
 Copy assignment operator.
 
template<typename T , typename = std::enable_if_t< std::is_integral_v<T> or std::is_floating_point_v<T> or std::is_same_v<std::decay_t<T>, std::string> || std::is_same_v<std::decay_t<T>, std::string_view> or std::is_same_v<std::decay_t<T>, const char*> || std::is_same_v<std::decay_t<T>, char*> or std::is_same_v<T, XLCellValue> or std::is_same_v<T, XLDateTime> or std::is_same_v<T, OpenXLSX::XLRichText>>>
XLCellValueProxyoperator= (const T &value)
 Templated assignment operator.
 
template<typename T , typename = std::enable_if_t< std::is_integral_v<T> or std::is_floating_point_v<T> or std::is_same_v<std::decay_t<T>, std::string> || std::is_same_v<std::decay_t<T>, std::string_view> or std::is_same_v<std::decay_t<T>, const char*> || std::is_same_v<std::decay_t<T>, char*> or std::is_same_v<T, XLCellValue> or std::is_same_v<T, XLDateTime> or std::is_same_v<T, OpenXLSX::XLRichText>>>
void set (const T &value)
 Sets the cell value using an automatically deduced type proxy.
 
template<typename T , typename = std::enable_if_t< std::is_integral_v<T> or std::is_floating_point_v<T> or std::is_same_v<std::decay_t<T>, std::string> || std::is_same_v<std::decay_t<T>, std::string_view> or std::is_same_v<std::decay_t<T>, const char*> || std::is_same_v<std::decay_t<T>, char*> or std::is_same_v<T, OpenXLSX::XLRichText> or std::is_same_v<T, XLDateTime>>>
get () const
 
XLCellValueProxyclear ()
 Clear the contents of the cell.
 
XLCellValueProxysetError (const std::string &error)
 Set the cell value to a error state.
 
XLValueType type () const
 Get the value type for the cell.
 
const char * typeAsString () const
 Get the value type of the current object, as a string representation.
 
 operator XLCellValue () const
 Implicitly convert the XLCellValueProxy object to a XLCellValue object.
 
template<typename T , typename = std::enable_if_t< std::is_integral_v<T> or std::is_floating_point_v<T> or std::is_same_v<std::decay_t<T>, std::string> || std::is_same_v<std::decay_t<T>, std::string_view> or std::is_same_v<std::decay_t<T>, const char*> || std::is_same_v<std::decay_t<T>, char*> or std::is_same_v<T, OpenXLSX::XLRichText> or std::is_same_v<T, XLDateTime>>>
 operator T () const
 Converts the underlying cell value proxy into the specified type T.
 
std::string_view getStringView () const
 get the cell value as a std::string, regardless of value type
 
std::string getString () const
 

Friends

class XLCell
 
class XLCellValue
 
class XLDocument
 

Detailed Description

The XLCellValueProxy class is used for proxy (or placeholder) objects for XLCellValue objects.

The purpose is to enable implicit conversion during assignment operations. XLCellValueProxy objects can not be constructed manually by the user, only through XLCell objects.

Constructor & Destructor Documentation

◆ ~XLCellValueProxy()

XLCellValueProxy::~XLCellValueProxy ( )
default

Destructor.

Destructor. Default implementation has been used.

Precondition
Postcondition

Member Function Documentation

◆ clear()

XLCellValueProxy & XLCellValueProxy::clear ( )

Clear the contents of the cell.

Returns
A reference to the current object.

Clear the contents of the cell. This removes all children of the cell node.

Precondition
The m_cellNode must not be null, and must point to a valid XML cell node object.
Postcondition
The cell node must be valid, but empty.

◆ get()

template<typename T , typename = std::enable_if_t< std::is_integral_v<T> or std::is_floating_point_v<T> or std::is_same_v<std::decay_t<T>, std::string> || std::is_same_v<std::decay_t<T>, std::string_view> or std::is_same_v<std::decay_t<T>, const char*> || std::is_same_v<std::decay_t<T>, char*> or std::is_same_v<T, OpenXLSX::XLRichText> or std::is_same_v<T, XLDateTime>>>
T OpenXLSX::XLCellValueProxy::get ( ) const
inline
Template Parameters
T
Todo:
Is an explicit conversion operator needed as well?

◆ getString()

std::string OpenXLSX::XLCellValueProxy::getString ( ) const
inline

◆ getStringView()

std::string_view XLCellValueProxy::getStringView ( ) const

get the cell value as a std::string, regardless of value type

Returns
A std::string representation of value
Exceptions
XLValueTypeErrorif the XLCellValue object is not convertible to string.

Get string view of the string cell

Returns
A std::string_view representation of value

◆ operator T()

template<typename T , typename = std::enable_if_t< std::is_integral_v<T> or std::is_floating_point_v<T> or std::is_same_v<std::decay_t<T>, std::string> || std::is_same_v<std::decay_t<T>, std::string_view> or std::is_same_v<std::decay_t<T>, const char*> || std::is_same_v<std::decay_t<T>, char*> or std::is_same_v<T, OpenXLSX::XLRichText> or std::is_same_v<T, XLDateTime>>>
OpenXLSX::XLCellValueProxy::operator T ( ) const
inline

Converts the underlying cell value proxy into the specified type T.

Template Parameters
TThe target type to convert the cell value into (e.g., int, double, std::string).
Returns
The cell value casted to the requested type.

◆ operator XLCellValue()

XLCellValueProxy::operator XLCellValue ( ) const

Implicitly convert the XLCellValueProxy object to a XLCellValue object.

Returns
An XLCellValue object, corresponding to the cell value.

Implicitly convert the XLCellValueProxy object to a XLCellValue object.

Precondition
Postcondition

◆ operator=() [1/2]

template<typename T , typename = std::enable_if_t< std::is_integral_v<T> or std::is_floating_point_v<T> or std::is_same_v<std::decay_t<T>, std::string> || std::is_same_v<std::decay_t<T>, std::string_view> or std::is_same_v<std::decay_t<T>, const char*> || std::is_same_v<std::decay_t<T>, char*> or std::is_same_v<T, XLCellValue> or std::is_same_v<T, XLDateTime> or std::is_same_v<T, OpenXLSX::XLRichText>>>
XLCellValueProxy & OpenXLSX::XLCellValueProxy::operator= ( const T &  value)
inline

Templated assignment operator.

Template Parameters
TThe type of numberValue assigned to the object.
Parameters
valueThe value.
Returns
A reference to the current object.

◆ operator=() [2/2]

XLCellValueProxy & XLCellValueProxy::operator= ( const XLCellValueProxy other)

Copy assignment operator.

Parameters
otherXLCellValueProxy object to be copied.
Returns
A reference to the current object.

Copy assignment operator. The function is implemented in terms of the templated value assignment operators, i.e. it is the XLCellValue that is that is copied, not the object itself.

Precondition
Postcondition

◆ set()

template<typename T , typename = std::enable_if_t< std::is_integral_v<T> or std::is_floating_point_v<T> or std::is_same_v<std::decay_t<T>, std::string> || std::is_same_v<std::decay_t<T>, std::string_view> or std::is_same_v<std::decay_t<T>, const char*> || std::is_same_v<std::decay_t<T>, char*> or std::is_same_v<T, XLCellValue> or std::is_same_v<T, XLDateTime> or std::is_same_v<T, OpenXLSX::XLRichText>>>
void OpenXLSX::XLCellValueProxy::set ( const T &  value)
inline

Sets the cell value using an automatically deduced type proxy.

Template Parameters
TThe deduced type of the assigned value.
Parameters
valueThe value to assign to the cell.

◆ setError()

XLCellValueProxy & XLCellValueProxy::setError ( const std::string &  error)

Set the cell value to a error state.

Returns
A reference to the current object.

Set the cell value to a error state. This will remove all children and attributes, except the type attribute, which is set to "e"

Precondition
The m_cellNode must not be null, and must point to a valid XML cell node object.
Postcondition
The cell node must be valid.

◆ type()

XLValueType XLCellValueProxy::type ( ) const

Get the value type for the cell.

Returns
An XLCellValue corresponding to the cell value.

Get the value type for the cell.

Precondition
The m_cellNode must not be null, and must point to a valid XML cell node object.
Postcondition
No change should be made.

◆ typeAsString()

const char * XLCellValueProxy::typeAsString ( ) const

Get the value type of the current object, as a string representation.

Returns
A std::string representation of the value type.

Get the value type of the current object, as a string representation.

Precondition
Postcondition

Friends And Related Symbol Documentation

◆ XLCell

friend class XLCell
friend

◆ XLCellValue

friend class XLCellValue
friend

◆ XLDocument

friend class XLDocument
friend

The documentation for this class was generated from the following files: