Exemple #1
0
    void CouchbaseEmbedFunctionContext::getStringResult(size32_t &chars, char * &result)
    {
        auto value = nextResultScalar();
        if (value && *value)
        {
            unsigned numchars = rtlUtf8Length(strlen(value), value);
            rtlUtf8ToStrX(chars, result, numchars, value);
        }

        NullFieldProcessor p(NULL);
        rtlStrToStrX(chars, result, p.resultChars, p.stringResult);
    }
Exemple #2
0
    void CouchbaseRowBuilder::getStringResult(const RtlFieldInfo *field, size32_t &chars, char * &result)
    {
         const char * value = nextField(field);

        if (!value || !*value)
        {
            NullFieldProcessor p(field);
            rtlStrToStrX(chars, result, p.resultChars, p.stringResult);
            return;
        }

        unsigned numchars = rtlUtf8Length(strlen(value), value);  // MORE - is it a good assumption that it is utf8 ? Depends how the database is configured I think
        rtlUtf8ToStrX(chars, result, numchars, value);
        return;
    }
Exemple #3
0
static void getStringResult(const RtlFieldInfo *field, sqlite3_value *val, size32_t &chars, char * &result)
{
    assertex(val);
    if (isNull(val))
    {
        NullFieldProcessor p(field);
        rtlStrToStrX(chars, result, p.resultChars, p.stringResult);
        return;
    }
    if (sqlite3_value_type(val) != SQLITE_TEXT)
        typeError("string", field);
    const char *text = (const char *) sqlite3_value_text(val);
    int bytes = sqlite3_value_bytes(val);
    unsigned numchars = rtlUtf8Length(bytes, text);
    rtlUtf8ToStrX(chars, result, numchars, text);
}
Exemple #4
0
static void getDateTimeText(const MYSQL_BIND &bound, size32_t &chars, char * &result)
{
    const MYSQL_TIME * time = (const MYSQL_TIME *) bound.buffer;
    char temp[20];
    switch (bound.buffer_type)
    {
    case MYSQL_TYPE_TIMESTAMP:
    case MYSQL_TYPE_DATETIME:
        _snprintf(temp, sizeof(temp), "%4u-%02u-%02u %02u:%02u:%02u", time->year, time->month, time->day, time->hour, time->minute, time->second);
        break;
    case MYSQL_TYPE_DATE:
        _snprintf(temp, sizeof(temp), "%4u-%02u-%02u", time->year, time->month, time->day);
        break;
    case MYSQL_TYPE_TIME:
        _snprintf(temp, sizeof(temp), "%02u:%02u:%02u", time->hour, time->minute, time->second);
        break;
    default:
        throwUnexpected();
    }
    rtlStrToStrX(chars, result, strlen(temp), temp);
}
Exemple #5
0
static void getStringResult(const RtlFieldInfo *field, const MYSQL_BIND &bound, size32_t &chars, char * &result)
{
    if (*bound.is_null)
    {
        NullFieldProcessor p(field);
        rtlStrToStrX(chars, result, p.resultChars, p.stringResult);
        return;
    }

    if (isDateTime(bound.buffer_type))
    {
        getDateTimeText(bound, chars, result);
        return;
    }
    if (!isString(bound.buffer_type))
        typeError("string", field);

    const char *text = (const char *) bound.buffer;
    unsigned long bytes = *bound.length;
    unsigned numchars = rtlUtf8Length(bytes, text);  // MORE - is it a good assumption that it is utf8 ? Depends how the database is configured I think
    rtlUtf8ToStrX(chars, result, numchars, text);
}