ScaleOut C++ Native Client API  5.1
 All Classes Functions Variables Typedefs Enumerations Enumerator Friends Pages
sosscli::ValueComparand Class Reference

A ValueComparand node holds a literal value to be compared with a field or property within objects persisted to StateServer via a TypedNamedCache::put(), TypedNamedCache::insert(), or TypedNamedCache::update() method. More...

#include <value_comparand.h>

Inheritance diagram for sosscli::ValueComparand:
sosscli::ExpressionComparand

Public Member Functions

 ValueComparand (std::string const &value)
 Constructor. More...
 
 ValueComparand (char const *value)
 Constructor. More...
 
 ValueComparand (wchar_t const *value)
 Constructor. More...
 
 ValueComparand (std::wstring const &value)
 Constructor. More...
 
 ValueComparand (uint8_t const *value, size_t length)
 Constructor. More...
 
 ValueComparand (std::vector< uint8_t > const &value)
 Constructor. More...
 
 ValueComparand (sosscli::internal::TypeSignature const &value)
 Constructor. More...
 
 ValueComparand (int32_t value)
 Constructor. More...
 
 ValueComparand (uint32_t value)
 Constructor. More...
 
 ValueComparand (int64_t value)
 Constructor. More...
 
 ValueComparand (uint64_t value)
 Constructor. More...
 
 ValueComparand (double value)
 Constructor. More...
 
 ValueComparand (float value)
 Constructor. More...
 
 ValueComparand (bool value)
 Constructor. More...
 
Filter operator== (ReferenceComparand const &field_ref)
 Creates a Filter object based on a QueryExpression that causes StateServer to compare for equality this ValueComparand with the field values of objects persisted in StateServer corresponding to ReferenceComparand::field_name() of field_ref. More...
 
Filter operator!= (ReferenceComparand const &field_ref)
 Creates a Filter object based on a QueryExpression that causes StateServer to compare for inequality this ValueComparand with the field values of objects persisted in StateServer corresponding to ReferenceComparand::field_name() of field_ref. More...
 
Filter operator> (ReferenceComparand const &field_ref)
 Creates a Filter object based on a QueryExpression that causes StateServer to compare this ValueComparand with the field values of objects persisted in StateServer corresponding to ReferenceComparand::field_name() of field_ref for a greater than condition. More...
 
Filter operator>= (ReferenceComparand const &field_ref)
 Creates a Filter object based on a QueryExpression that causes StateServer to compare this ValueComparand with the field values of objects persisted in StateServer corresponding to ReferenceComparand::field_name() of field_ref for a greater than or equal to condition. More...
 
Filter operator< (ReferenceComparand const &field_ref)
 Creates a Filter object based on a QueryExpression that causes StateServer to compare this ValueComparand with the field values of objects persisted in StateServer corresponding to ReferenceComparand::field_name() of field_ref for a less than condition. More...
 
Filter operator<= (ReferenceComparand const &field_ref)
 Creates a Filter object based on a QueryExpression that causes StateServer to compare this ValueComparand with the field values of objects persisted in StateServer corresponding to ReferenceComparand::field_name() of field_ref for a less than or equal to condition. More...
 
Filter contains (ReferenceComparand const &ref)
 Creates a Filter object based on a QueryExpression that causes StateServer to compare for string containment the value corresponding to this ValueComparand (which must be a string-type value) with the value of the field corresponding to ref's ReferenceComparand::field_name() (which must also be a string-type value) in objects persisted in StateServer. More...
 
int type_code () const
 Returns an opaque "type code" which is interpreted by StateServer as the data type of this ValueComparand. More...
 
bool is_string_type () const
 Returns true if this ValueComparand holds a string value suitable for use with string contains comparisons. More...
 
virtual void accept (QueryExpression::Visitor &v) const
 Initiates the visitor pattern on this node. More...
 
void allocate_value (sosscli::internal::IndexValueWriter &writer) const
 Allocate space for this ValueComparand in the supplied writer. More...
 
void allocate_value_as (sosscli::internal::IndexValueWriter &writer, int type_code) const
 Allocate space for this ValueComparand in the supplied writer after conversion of the value to the type specified by type_code. More...
 
int write_value (sosscli::internal::IndexValueWriter &writer) const
 Write the value of this ValueComparand to the supplied writer. More...
 
int write_value_as (sosscli::internal::IndexValueWriter &writer, int type_code) const
 Convert the value held by this ValueComparand to type indicated by type_code and write the converted value to the supplied writer. More...
 

Static Public Member Functions

static ValueComparand null ()
 Returns a ValueComparand representing a NULL value. More...
 

Friends

std::ostream & operator<< (std::ostream &o, ValueComparand const &p)
 Write a string representation of the this ValueComparand's value to the output stream. More...
 

Detailed Description

A ValueComparand node holds a literal value to be compared with a field or property within objects persisted to StateServer via a TypedNamedCache::put(), TypedNamedCache::insert(), or TypedNamedCache::update() method.

ValueComparand implements a number of comparison operator overloads that serve as Filter factory methods: By writing an expression that compares a ValueOperand with a ReferenceOperand, you create a Filter object. Filters can be subsequently combined with other filters using boolean operator overloads implemented in the Filter class. For example, the following:

Filter filt = ValueComparand(2000) == ReferenceComparand("id");

creates a Filter which can be used as the argument to a NamedCache::query(const Filter &, bool) method call which will translate filt into a StateServer expression that compares the literal value 2000 to the value of the "id" field of objects persisted on the server.

Note
Typically, comparison expressions are written with the ReferenceComparand first as in:
Filter filt = ReferenceComparand("id") == 2000;
In this case, the compiler implicitly converts the literal 2000 to a ValueComparand using the ValueComparand::ValueComparand(int32_t) constructor.
See Also
ReferenceComparand

Constructor & Destructor Documentation

sosscli::ValueComparand::ValueComparand ( std::string const &  value)

Constructor.

Initialize a new ValueComparand instance with value.

Parameters
valueThe value to be held by the new ValueComparand instance.
sosscli::ValueComparand::ValueComparand ( char const *  value)

Constructor.

Initialize a new ValueComparand instance with value.

Parameters
valueThe value to be held by the new ValueComparand instance.
sosscli::ValueComparand::ValueComparand ( wchar_t const *  value)

Constructor.

Initialize a new ValueComparand instance with value.

Parameters
valueThe value to be held by the new ValueComparand instance.
sosscli::ValueComparand::ValueComparand ( std::wstring const &  value)

Constructor.

Initialize a new ValueComparand instance with value.

Parameters
valueThe value to be held by the new ValueComparand instance.
sosscli::ValueComparand::ValueComparand ( uint8_t const *  value,
size_t  length 
)

Constructor.

Initialize a new ValueComparand instance with array value.

Parameters
valueThe value to be held by the new ValueComparand instance.
lengthThe length of the array value
sosscli::ValueComparand::ValueComparand ( std::vector< uint8_t > const &  value)

Constructor.

Initialize a new ValueComparand instance with a vector of bytes, value.

Parameters
valueThe value to be held by the new ValueComparand instance.
sosscli::ValueComparand::ValueComparand ( sosscli::internal::TypeSignature const &  value)

Constructor.

Initialize a new ValueComparand instance with a TypeSignature value.

Parameters
valueThe sosscli::internal::TypeSignature value to be held by the new ValueComparand instance.
See Also
sosscli::internal::TypeSignature
sosscli::ValueComparand::ValueComparand ( int32_t  value)

Constructor.

Initialize a new ValueComparand instance with value.

Parameters
valueThe value to be held by the new ValueComparand instance.
sosscli::ValueComparand::ValueComparand ( uint32_t  value)

Constructor.

Initialize a new ValueComparand instance with value.

Parameters
valueThe value to be held by the new ValueComparand instance.
sosscli::ValueComparand::ValueComparand ( int64_t  value)

Constructor.

Initialize a new ValueComparand instance with value.

Parameters
valueThe value to be held by the new ValueComparand instance.
sosscli::ValueComparand::ValueComparand ( uint64_t  value)

Constructor.

Initialize a new ValueComparand instance with value.

Parameters
valueThe value to be held by the new ValueComparand instance.
sosscli::ValueComparand::ValueComparand ( double  value)

Constructor.

Initialize a new ValueComparand instance with value.

Parameters
valueThe value to be held by the new ValueComparand instance.
sosscli::ValueComparand::ValueComparand ( float  value)

Constructor.

Initialize a new ValueComparand instance with value.

Parameters
valueThe value to be held by the new ValueComparand instance.
sosscli::ValueComparand::ValueComparand ( bool  value)

Constructor.

Initialize a new ValueComparand instance with value.

Parameters
valueThe value to be held by the new ValueComparand instance.

Member Function Documentation

virtual void sosscli::ValueComparand::accept ( QueryExpression::Visitor v) const
virtual

Initiates the visitor pattern on this node.

Calls QueryExpression::Visitor::visit(ReferenceComparand const &) on the supplied visitor, v.

Parameters
vAn implementation of QueryExpression::Visitor.

Implements sosscli::ExpressionComparand.

void sosscli::ValueComparand::allocate_value ( sosscli::internal::IndexValueWriter &  writer) const

Allocate space for this ValueComparand in the supplied writer.

Note
This method is intended to be used by QueryExpression::Visitor implementations to prepare a Filter for use by StateServer.
Parameters
writerThe sosscli::internal::IndexValueWriter in which space should be reserved.
See Also
sosscli::internal::IndexValueWriter
void sosscli::ValueComparand::allocate_value_as ( sosscli::internal::IndexValueWriter &  writer,
int  type_code 
) const

Allocate space for this ValueComparand in the supplied writer after conversion of the value to the type specified by type_code.

Note
This method is intended to be used by QueryExpression::Visitor implementations to prepare a Filter for use by StateServer.
Parameters
writerThe sosscli::internal::IndexValueWriter in which space should be reserved.
type_codeThe StateServer type code to which the value held by this ValueComparand should be converted.
Exceptions
std::invalid_argumentIf the requested type conversion is not possible.
See Also
sosscli::internal::IndexValueWriter
Filter sosscli::ValueComparand::contains ( ReferenceComparand const &  ref)

Creates a Filter object based on a QueryExpression that causes StateServer to compare for string containment the value corresponding to this ValueComparand (which must be a string-type value) with the value of the field corresponding to ref's ReferenceComparand::field_name() (which must also be a string-type value) in objects persisted in StateServer.

Parameters
refA ReferenceComparand holding the name of another field. The field must hold string values.
Returns
A Filter object holding the generated QueryExpression.
bool sosscli::ValueComparand::is_string_type ( ) const

Returns true if this ValueComparand holds a string value suitable for use with string contains comparisons.

See Also
contains
static ValueComparand sosscli::ValueComparand::null ( )
static

Returns a ValueComparand representing a NULL value.

In addition to null-valued strings and byte arrays, StateServer supports the notion of "nullable" value types. Depending on the serializer in use, nullable value types may be used to represent optional or not-present values in the serialized representation of an object on StateServer.

Filter sosscli::ValueComparand::operator!= ( ReferenceComparand const &  field_ref)

Creates a Filter object based on a QueryExpression that causes StateServer to compare for inequality this ValueComparand with the field values of objects persisted in StateServer corresponding to ReferenceComparand::field_name() of field_ref.

Parameters
field_refThe reference holding the field name of the values to compare.
Returns
A Filter object holding the generated QueryExpression.
Filter sosscli::ValueComparand::operator< ( ReferenceComparand const &  field_ref)

Creates a Filter object based on a QueryExpression that causes StateServer to compare this ValueComparand with the field values of objects persisted in StateServer corresponding to ReferenceComparand::field_name() of field_ref for a less than condition.

Parameters
field_refThe reference holding the field name of the values to compare.
Returns
A Filter object holding the generated QueryExpression.
Filter sosscli::ValueComparand::operator<= ( ReferenceComparand const &  field_ref)

Creates a Filter object based on a QueryExpression that causes StateServer to compare this ValueComparand with the field values of objects persisted in StateServer corresponding to ReferenceComparand::field_name() of field_ref for a less than or equal to condition.

Parameters
field_refThe reference holding the field name of the values to compare.
Returns
A Filter object holding the generated QueryExpression.
Filter sosscli::ValueComparand::operator== ( ReferenceComparand const &  field_ref)

Creates a Filter object based on a QueryExpression that causes StateServer to compare for equality this ValueComparand with the field values of objects persisted in StateServer corresponding to ReferenceComparand::field_name() of field_ref.

Parameters
field_refThe reference holding the field name of the values to compare.
Returns
A Filter object holding the generated QueryExpression.
Filter sosscli::ValueComparand::operator> ( ReferenceComparand const &  field_ref)

Creates a Filter object based on a QueryExpression that causes StateServer to compare this ValueComparand with the field values of objects persisted in StateServer corresponding to ReferenceComparand::field_name() of field_ref for a greater than condition.

Parameters
field_refThe reference holding the field name of the values to compare.
Returns
A Filter object holding the generated QueryExpression.
Filter sosscli::ValueComparand::operator>= ( ReferenceComparand const &  field_ref)

Creates a Filter object based on a QueryExpression that causes StateServer to compare this ValueComparand with the field values of objects persisted in StateServer corresponding to ReferenceComparand::field_name() of field_ref for a greater than or equal to condition.

Parameters
field_refThe reference holding the field name of the values to compare.
Returns
A Filter object holding the generated QueryExpression.
int sosscli::ValueComparand::type_code ( ) const

Returns an opaque "type code" which is interpreted by StateServer as the data type of this ValueComparand.

Returns
The StateServer type code.
int sosscli::ValueComparand::write_value ( sosscli::internal::IndexValueWriter &  writer) const

Write the value of this ValueComparand to the supplied writer.

Note
This method is intended to be used by QueryExpression::Visitor implementations to prepare a Filter for use by StateServer.
Parameters
writerThe sosscli::internal::IndexValueWriter into which this ValueComparand's value should be written.
See Also
sosscli::internal::IndexValueWriter
int sosscli::ValueComparand::write_value_as ( sosscli::internal::IndexValueWriter &  writer,
int  type_code 
) const

Convert the value held by this ValueComparand to type indicated by type_code and write the converted value to the supplied writer.

Note
This method is intended to be used by QueryExpression::Visitor implementations to prepare a Filter for use by StateServer.
Parameters
writerThe sosscli::internal::IndexValueWriter into which this ValueComparand's converted value should be written.
type_codeThe StateServer type code to which the value held by this ValueComparand should be converted.
Exceptions
std::invalid_argumentIf the requested type conversion is not possible.
See Also
sosscli::internal::IndexValueWriter

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  o,
ValueComparand const &  p 
)
friend

Write a string representation of the this ValueComparand's value to the output stream.

Parameters
oThe std::ostream to write to.
pThe ValueComparand to write.
Returns
The parameter o.

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