MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / CVT_get_string_ptr_common

Function CVT_get_string_ptr_common

src/common/cvt.cpp:2883–2955  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2881
2882
2883USHORT CVT_get_string_ptr_common(const dsc* desc, USHORT* ttype, UCHAR** address,
2884 vary* temp, USHORT length, DecimalStatus decSt, Callbacks* cb)
2885{
2886/**************************************
2887 *
2888 * C V T _ g e t _ s t r i n g _ p t r
2889 *
2890 **************************************
2891 *
2892 * Functional description
2893 * Get address and length of string, converting the value to
2894 * string, if necessary. The caller must provide a sufficiently
2895 * large temporary. The address of the resultant string is returned
2896 * by reference. Get_string returns the length of the string (in bytes).
2897 *
2898 * The text-type of the string is returned in ttype.
2899 *
2900 * Note: If the descriptor is known to be a string type, the fourth
2901 * argument (temp buffer) may be NULL.
2902 *
2903 * If input (desc) is already a string, the output pointers
2904 * point to the data of the same text_type. If (desc) is not
2905 * already a string, output pointers point to ttype_ascii.
2906 *
2907 **************************************/
2908 fb_assert(desc != NULL);
2909 fb_assert(ttype != NULL);
2910 fb_assert(address != NULL);
2911 fb_assert(cb != NULL);
2912 fb_assert((temp != NULL && length > 0) || desc->isText() || desc->isDbKey());
2913
2914 // If the value is already a string (fixed or varying), just return
2915 // the address and length.
2916
2917 if (desc->isText())
2918 {
2919 *address = desc->dsc_address;
2920 *ttype = INTL_TTYPE(desc);
2921 if (desc->dsc_dtype == dtype_text)
2922 return desc->dsc_length;
2923 if (desc->dsc_dtype == dtype_cstring)
2924 return MIN((USHORT) strlen((char *) desc->dsc_address), desc->dsc_length - 1);
2925 if (desc->dsc_dtype == dtype_varying)
2926 {
2927 vary* varying = (vary*) desc->dsc_address;
2928 *address = reinterpret_cast<UCHAR*>(varying->vary_string);
2929 return MIN(varying->vary_length, (USHORT) (desc->dsc_length - sizeof(USHORT)));
2930 }
2931 }
2932
2933 // Also trivial case - DB_KEY
2934
2935 if (desc->dsc_dtype == dtype_dbkey)
2936 {
2937 *address = desc->dsc_address;
2938 *ttype = ttype_binary;
2939 return desc->dsc_length;
2940 }

Callers 3

CVT_get_string_ptrFunction · 0.85
CVT_move_commonFunction · 0.85
CVT_get_string_ptrFunction · 0.85

Calls 4

CVT_move_commonFunction · 0.85
isTextMethod · 0.80
isDbKeyMethod · 0.80
setTextTypeMethod · 0.80

Tested by

no test coverage detected