MCPcopy Create free account
hub / github.com/cuberite/cuberite / isConvertibleTo

Method isConvertibleTo

lib/jsoncpp/src/lib_json/json_value.cpp:829–877  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

827
828
829bool
830Value::isConvertibleTo( ValueType other ) const
831{
832 switch ( type_ )
833 {
834 case nullValue:
835 return true;
836 case intValue:
837 return ( other == nullValue && value_.int_ == 0 )
838 || other == intValue
839 || ( other == uintValue && value_.int_ >= 0 )
840 || other == realValue
841 || other == stringValue
842 || other == booleanValue;
843 case uintValue:
844 return ( other == nullValue && value_.uint_ == 0 )
845 || ( other == intValue && value_.uint_ <= (unsigned)maxInt )
846 || other == uintValue
847 || other == realValue
848 || other == stringValue
849 || other == booleanValue;
850 case realValue:
851 return ( other == nullValue && value_.real_ == 0.0 )
852 || ( other == intValue && value_.real_ >= minInt && value_.real_ <= maxInt )
853 || ( other == uintValue && value_.real_ >= 0 && value_.real_ <= maxUInt )
854 || other == realValue
855 || other == stringValue
856 || other == booleanValue;
857 case booleanValue:
858 return ( other == nullValue && value_.bool_ == false )
859 || other == intValue
860 || other == uintValue
861 || other == realValue
862 || other == stringValue
863 || other == booleanValue;
864 case stringValue:
865 return other == stringValue
866 || ( other == nullValue && (!value_.string_ || value_.string_[0] == 0) );
867 case arrayValue:
868 return other == arrayValue
869 || ( other == nullValue && value_.map_->size() == 0 );
870 case objectValue:
871 return other == objectValue
872 || ( other == nullValue && value_.map_->size() == 0 );
873 default:
874 JSON_ASSERT_UNREACHABLE;
875 }
876 return false; // unreachable;
877}
878
879
880/// Number of values in array or object

Callers

nothing calls this directly

Calls 1

sizeMethod · 0.80

Tested by

no test coverage detected