Esempio n. 1
0
    string CircularArray::toString() {
        string history_string;

        history_string =
            "Max size: " + double_to_string(maxSize) +
            ", Size: " + double_to_string(size) +
            ", Start: " + double_to_string(start) + "\n\t";

        for (int i = 0; i < size; i++)
            history_string += double_to_string(getValue(i)) + " ";

        return history_string;
    }
Esempio n. 2
0
void set_double (const char * section, const char * name, double value)
{
    char * string = double_to_string (value);
    g_return_if_fail (string);
    set_string (section, name, string);
    g_free (string);
}
Esempio n. 3
0
//!Get string representation of the externalFuncs
//! \return std::string Representation of externalFuncs
std::string transitionFuncParam::stringify() {
    std::string exFuncString;
    exFuncString+="[ FUNCTION:\t" + transFuncName + "\t";
    exFuncString+="TRACK:\t" + trackName + "\t";
    if (transFuncTraceback) {
        exFuncString+= (transFuncTracebackIdentifier == STATE_NAME)  ? "TO_STATE:\t" + transFuncTracebackString + "\t":
                       (transFuncTracebackIdentifier == STATE_LABEL) ? "TO_LABEL:\t" + transFuncTracebackString + "\t":
                       (transFuncTracebackIdentifier == STATE_GFF)   ? "TO_GFF:\t" + transFuncTracebackString   + "\t":
                       (transFuncTracebackIdentifier == START_INIT)  ? "TO_START:\t": "DIFF_STATE:\t" ;

        exFuncString+=  (transFuncCombineIdentifier == STATENAME) ? "COMBINE_STATE:\t" + transFuncCombineString + "\t":
                        (transFuncCombineIdentifier == STATELABEL) ? "COMBINE_LABEL:\t" + transFuncCombineString + "\t":
                        (transFuncCombineIdentifier == STATEGFF) ? "COMBINE_GFF:\t" + transFuncCombineString :"NO_COMBINE:\t";
    }

    if (transFuncScaling!=NULL) {
        if (transFuncScaling->isAbsolute()) {
            exFuncString+="SCALE:\t" + double_to_string(transFuncScaling->getAbsolute());
        }
        else {
            exFuncString+="SCALE:\t" + transFuncScaling->getName();
        }
    }

    exFuncString += " ]";

    return exFuncString;
}
Esempio n. 4
0
std::string simpleTrellis::stringify() {
    size_t state_size = hmm->state_size();
    size_t seq_size = seq->getLength();

    std::string output("");

    //Header
    output+= ",,,,,,,,,,Stochastic Viterbi Scores, Stochastic Forward Scores\n";
    output+= "Position, State Name, State Label, Emission, Transition, Forward, Backward, Posterior, Viterbi, Viterbi Traceback Pointer";

    std::string state_names("");
    for(size_t i=0; i<state_size; i++) {
        state_names+="," + hmm->getStateName(i);
    }

    output+= state_names + state_names + "\n";

    for(size_t position = 0 ; position<seq_size; ++position) {
        for (size_t state_iter = 0 ; state_iter<state_size; ++state_iter) {
            simpleCell& cell = trell[position][state_iter];

            if (cell.forw!=-INFINITY || cell.viti!=-INFINITY || cell.back!=-INFINITY) {
                output += position + ",";
                output += hmm->getStateName(state_iter) + ",";
                output += hmm->getStateLabel(state_iter) + ",";
                output += double_to_string(cell.emm) + ",";

                //Need to do state transitions

                output += double_to_string(cell.forw) + ",";
                output += double_to_string(cell.back) + ",";
                output += double_to_string(cell.viti) + ",";
                if (cell.statePtr != NULL) {
                    output += cell.statePtr->getName();
                }
            }
        }
    }

    return output;
}
Esempio n. 5
0
char* reduce_avg(state_item_t* d, int length)
{
	// avg of all item values (treated as double)
	double sum = 0;
	int i = 0;
	for(i=0; i < length; i++)
	{
		//printf("reduce(avg) input: n_id=%s ts=%lu value=%s\n", d[i].node_identifier, d[i].timestamp,  d[i].data);
		sum += string_to_double(d[i].data);
	}
	return (char*)double_to_string(sum/(double)length).c_str();
}
Esempio n. 6
0
String* Float::to_s_minimal(STATE) {
    char buffer[FLOAT_TO_S_STRLEN];

    int len = double_to_string(buffer, FLOAT_TO_S_STRLEN, val);
    String* str = String::create(state, buffer, len);
    infect(state, str);
    str->encoding(state, Encoding::usascii_encoding(state));
    str->ascii_only(state, cTrue);
    str->valid_encoding(state, cTrue);

    return str;
}
irom static app_action_t application_function_i2c_sensor_calibrate(application_parameters_t ap)
{
	i2c_sensor_t sensor;
	float factor;
	float offset;
	uint16_t length;

	sensor = atoi((*ap.args)[1]);
	factor = string_to_double((*ap.args)[2]);
	offset = string_to_double((*ap.args)[3]);

	if(!i2c_sensor_setcal(sensor, factor, offset))
	{
		snprintf(ap.dst, ap.size, "> invalid i2c sensor: %d\n", (int)sensor);
		return(app_action_error);
	}

	length = snprintf(ap.dst, ap.size, "> i2c sensor %d calibration set to factor ", (int)sensor);
	ap.dst += length;
	ap.size -= length;

	length = double_to_string(config->i2c_sensors.sensor[sensor].calibration.factor, 4, 1e10, ap.size, ap.dst);
	ap.dst += length;
	ap.size -= length;

	length = snprintf(ap.dst, ap.size, ", offset: ");
	ap.dst += length;
	ap.size -= length;

	length = double_to_string(config->i2c_sensors.sensor[sensor].calibration.offset, 4, 1e10, ap.size, ap.dst);
	ap.dst += length;
	ap.size -= length;

	length = snprintf(ap.dst, ap.size, "\n");
	ap.dst += length;
	ap.size -= length;

	return(app_action_normal);
}
Esempio n. 8
0
	std::string matrixPosition::stringify(){
		std::string mat;
		mat = "NAME:\t" + name + "\n";
		
		if (thresholdSet){
			mat+= "THRESHOLD:\t" + double_to_string(threshold) + "\n";
		}
		
		if (transition_names.size() > 0){
			mat += "TRANSITIONS:" + join(transition_names, ',') + "\n";
		}
		
		mat += positionMatrix->stringify();
		return mat;
	}
Esempio n. 9
0
//!Get string representation of the externalFuncs
//! \return std::string Representation of externalFuncs
std::string emissionFuncParam::stringify() {
    std::string exFuncString;
    exFuncString+="[ FUNCTION:\t" + emissionFuncName + "\t";
    exFuncString+="TRACK:\t" + trackName + "\t";

    if (emissionFuncScaling!=NULL) {
        if (emissionFuncScaling->isAbsolute()) {
            exFuncString+="SCALE:\t" + double_to_string(emissionFuncScaling->getAbsolute());
        }
        else {
            exFuncString+="SCALE:\t" + emissionFuncScaling->getName();
        }
    }

    exFuncString += " ]";

    return exFuncString;
}
Esempio n. 10
0
	std::string PWM::stringify(){
		std::string pwm;
		std::string split("#################################\n");
		pwm += "#POSITION WEIGHT MATRIX\n\n";
		
		if ( simpleThreshold!= -INFINITY){
			pwm +="<THRESHOLD DEFINITION>\n";
			pwm += split;
			pwm += double_to_string(simpleThreshold);
			pwm += "\n\n";
		}
		
		pwm +="<TRACK SYMBOL DEFINITIONS>\n";
		pwm += split;
		pwm += trk->stringify();
		pwm += "\n";
		
		
		if (bgWeight != NULL){
			pwm += "<BACKGROUND DEFINITION>\n";
			pwm += split;
			pwm += bgWeight->stringify();
		}
		
		if (undefinedSpacer){
			pwm += "<SPACER DEFINITIONS>\n";
			pwm += split;
			pwm += frontWeightName + "-SPACER-" + backWeightName + ":";
			pwm += join(undefSpacerSizes, ',');
			pwm += "\n\n";
		}
		
		
		pwm +="<POSITION WEIGHT DEFINITIONS>\n";
		pwm += split;
		
		
		for(size_t i=0; i< weightMatrix.size(); i++){
			pwm += weightMatrix[i]->stringify();
			pwm += split;
		}
		pwm += "//END";
		return pwm;
	}
/* ECMA-262 3rd Edition    9.8 */
HRESULT to_string(script_ctx_t *ctx, jsval_t val, jsstr_t **str)
{
    const WCHAR undefinedW[] = {'u','n','d','e','f','i','n','e','d',0};
    const WCHAR nullW[] = {'n','u','l','l',0};
    const WCHAR trueW[] = {'t','r','u','e',0};
    const WCHAR falseW[] = {'f','a','l','s','e',0};

    switch(jsval_type(val)) {
    case JSV_UNDEFINED:
        *str = jsstr_alloc(undefinedW);
        break;
    case JSV_NULL:
        *str = jsstr_alloc(nullW);
        break;
    case JSV_NUMBER:
        return double_to_string(get_number(val), str);
    case JSV_STRING:
        *str = jsstr_addref(get_string(val));
        break;
    case JSV_OBJECT: {
        jsval_t prim;
        HRESULT hres;

        hres = to_primitive(ctx, val, &prim, HINT_STRING);
        if(FAILED(hres))
            return hres;

        hres = to_string(ctx, prim, str);
        jsval_release(prim);
        return hres;
    }
    case JSV_BOOL:
        *str = jsstr_alloc(get_bool(val) ? trueW : falseW);
        break;
    default:
        FIXME("unsupported %s\n", debugstr_jsval(val));
        return E_NOTIMPL;
    }

    return *str ? S_OK : E_OUTOFMEMORY;
}
Esempio n. 12
0
static void
add_kvp_value_node(xmlNodePtr node, const gchar *tag, KvpValue* val)
{
    xmlNodePtr val_node;

    switch (val->get_type())
    {
    case KvpValue::Type::STRING:
    {
	auto newstr = g_strdup(val->get<const char*>());
        val_node = xmlNewTextChild(node, NULL, BAD_CAST tag,
				   checked_char_cast (newstr));
	g_free (newstr);
        break;
    }
    case KvpValue::Type::TIMESPEC:
        val_node = NULL;
        break;
    case KvpValue::Type::GDATE:
    {
        auto d = val->get<GDate>();
        val_node = gdate_to_dom_tree(tag, &d);
        xmlAddChild (node, val_node);
        break;
    }
    default:
        val_node = xmlNewTextChild(node, NULL, BAD_CAST tag, NULL);
        break;
    }

    switch (val->get_type())
    {
    case KvpValue::Type::INT64:
        add_text_to_node(val_node, "integer",
                         g_strdup_printf("%" G_GINT64_FORMAT,
                                         val->get<int64_t>()));
        break;
    case KvpValue::Type::DOUBLE:
        add_text_to_node(val_node, "double",
                         double_to_string(val->get<double>()));
        break;
    case KvpValue::Type::NUMERIC:
        add_text_to_node(val_node, "numeric",
                         gnc_numeric_to_string(val->get<gnc_numeric>()));
        break;
    case KvpValue::Type::STRING:
        xmlSetProp(val_node, BAD_CAST "type", BAD_CAST "string");
        break;
    case KvpValue::Type::GUID:
    {
        gchar guidstr[GUID_ENCODING_LENGTH+1];
        guid_to_string_buff(val->get<GncGUID*>(), guidstr);
        add_text_to_node(val_node, "guid", guidstr);
        break;
    }
    case KvpValue::Type::TIMESPEC:
    {
        auto ts = val->get<Timespec>();
        val_node = timespec_to_dom_tree (tag, &ts);
        xmlSetProp (val_node, BAD_CAST "type", BAD_CAST "timespec");
        xmlAddChild (node, val_node);
        break;
    }
    case KvpValue::Type::GDATE:
        xmlSetProp(val_node, BAD_CAST "type", BAD_CAST "gdate");
        break;
    case KvpValue::Type::GLIST:
        xmlSetProp(val_node, BAD_CAST "type", BAD_CAST "list");
        for (auto cursor = val->get<GList*>(); cursor; cursor = cursor->next)
        {
            auto val = static_cast<KvpValue*>(cursor->data);
            add_kvp_value_node(val_node, "slot:value", val);
        }
        break;
    case KvpValue::Type::FRAME:
    {
        xmlSetProp(val_node, BAD_CAST "type", BAD_CAST "frame");

        auto frame = val->get<KvpFrame*>();
        if (!frame)
            break;
        frame->for_each_slot(add_kvp_slot, static_cast<void*>(val_node));
        break;
    }
    default:
	break;
    }
}
Esempio n. 13
0
static void mathg_math_cog_close (mathgMathCog *self, gdouble ans) {
	gdouble hyp = 0.0;
	mathgElmnt* _tmp0_ = NULL;
	gint _tmp0__length1 = 0;
	gint _tmp1_ = 0;
	mathgElmnt _tmp2_ = {0};
	const gchar* _tmp3_ = NULL;
	gdouble _tmp4_ = 0.0;
	gdouble d = 0.0;
	gdouble _tmp5_ = 0.0;
	gdouble _tmp6_ = 0.0;
	gdouble _tmp7_ = 0.0;
	gdouble _tmp8_ = 0.0;
	gdouble _tmp9_ = 0.0;
	gdouble _tmp10_ = 0.0;
	gdouble _tmp11_ = 0.0;
	gdouble _tmp12_ = 0.0;
	mathgElmnt* _tmp13_ = NULL;
	gint _tmp13__length1 = 0;
	gint _tmp14_ = 0;
	gdouble _tmp15_ = 0.0;
	gchar* _tmp16_ = NULL;
	gchar* _tmp17_ = NULL;
	const gchar* _tmp18_ = NULL;
	gdouble _tmp19_ = 0.0;
	gchar* _tmp20_ = NULL;
	gchar* _tmp21_ = NULL;
	const gchar* _tmp22_ = NULL;
	gchar* _tmp23_ = NULL;
	mathgElmnt* _tmp24_ = NULL;
	gint _tmp24__length1 = 0;
	gint _tmp25_ = 0;
	mathgElmnt* _tmp26_ = NULL;
	gint _tmp26__length1 = 0;
	gint _tmp27_ = 0;
	const gchar* _tmp28_ = NULL;
	gchar* _tmp29_ = NULL;
	gchar* _tmp30_ = NULL;
	gchar* _tmp31_ = NULL;
	gchar* _tmp32_ = NULL;
	gchar* _tmp33_ = NULL;
	gchar* _tmp34_ = NULL;
	const gchar* _tmp35_ = NULL;
	gdouble _tmp36_ = 0.0;
	gdouble _tmp37_ = 0.0;
	gint _tmp38_ = 0;
	gchar* _tmp39_ = NULL;
	gchar* _tmp40_ = NULL;
	gchar* _tmp41_ = NULL;
	const gchar* _tmp42_ = NULL;
	gdouble _tmp43_ = 0.0;
	gchar* _tmp44_ = NULL;
	gchar* _tmp45_ = NULL;
	const gchar* _tmp46_ = NULL;
	gchar* _tmp47_ = NULL;
	gchar* _tmp48_ = NULL;
	gchar* _tmp49_ = NULL;
	gchar* _tmp50_ = NULL;
	gchar* _tmp51_ = NULL;
	gint _tmp52_ = 0;
	gint _tmp53_ = 0;
	mathgElmnt* _tmp54_ = NULL;
	gint _tmp54__length1 = 0;
	gint _tmp55_ = 0;
	_tmp0_ = (*self).stra;
	_tmp0__length1 = (*self).stra_length1;
	_tmp1_ = (*self).straind;
	_tmp2_ = _tmp0_[_tmp1_];
	_tmp3_ = _tmp2_.guess;
	_tmp4_ = mathg_number_utils_td (&(*self).nu, _tmp3_);
	hyp = _tmp4_;
	_tmp5_ = hyp;
	_tmp6_ = ans;
	_tmp7_ = fabs (_tmp5_ - _tmp6_);
	d = _tmp7_;
	_tmp8_ = (*self).cor;
	_tmp9_ = ans;
	_tmp10_ = fabs (_tmp9_);
	(*self).cor = _tmp8_ + _tmp10_;
	_tmp11_ = (*self).err;
	_tmp12_ = d;
	(*self).err = _tmp11_ + _tmp12_;
	_tmp13_ = (*self).stra;
	_tmp13__length1 = (*self).stra_length1;
	_tmp14_ = (*self).straind;
	_tmp15_ = ans;
	_tmp16_ = mathg_number_utils_ts (&(*self).nu, _tmp15_);
	_tmp17_ = _tmp16_;
	_tmp18_ = string_to_string (_tmp17_);
	_tmp19_ = d;
	_tmp20_ = mathg_number_utils_ts (&(*self).nu, _tmp19_);
	_tmp21_ = _tmp20_;
	_tmp22_ = string_to_string (_tmp21_);
	_tmp23_ = g_strconcat (" ans=", _tmp18_, " Δ=", _tmp22_, " t=", NULL);
	_g_free0 (_tmp13_[_tmp14_].result);
	_tmp13_[_tmp14_].result = _tmp23_;
	_g_free0 (_tmp21_);
	_g_free0 (_tmp17_);
	_tmp24_ = (*self).stra;
	_tmp24__length1 = (*self).stra_length1;
	_tmp25_ = (*self).straind;
	_tmp26_ = (*self).stra;
	_tmp26__length1 = (*self).stra_length1;
	_tmp27_ = (*self).straind;
	_tmp28_ = _tmp26_[_tmp27_].result;
	_tmp29_ = mathg_my_timer_to_string (&(*self).problem);
	_tmp30_ = _tmp29_;
	_tmp31_ = g_strconcat (_tmp30_, "ms", NULL);
	_tmp32_ = _tmp31_;
	_tmp33_ = g_strconcat (_tmp28_, _tmp32_, NULL);
	_g_free0 (_tmp26_[_tmp27_].result);
	_tmp26_[_tmp27_].result = _tmp33_;
	_g_free0 (_tmp32_);
	_g_free0 (_tmp30_);
	_tmp34_ = g_strdup ("tot Δ‰=");
	_g_free0 ((*self).res);
	(*self).res = _tmp34_;
	_tmp35_ = (*self).res;
	_tmp36_ = (*self).err;
	_tmp37_ = (*self).cor;
	_tmp38_ = (*self).pm;
	_tmp39_ = double_to_string ((_tmp36_ / _tmp37_) * _tmp38_);
	_tmp40_ = _tmp39_;
	_tmp41_ = g_strconcat (_tmp35_, _tmp40_, NULL);
	_g_free0 ((*self).res);
	(*self).res = _tmp41_;
	_g_free0 (_tmp40_);
	_tmp42_ = (*self).res;
	_tmp43_ = (*self).err;
	_tmp44_ = mathg_number_utils_ts (&(*self).nu, _tmp43_);
	_tmp45_ = _tmp44_;
	_tmp46_ = string_to_string (_tmp45_);
	_tmp47_ = mathg_my_timer_to_string (&(*self).total);
	_tmp48_ = _tmp47_;
	_tmp49_ = g_strconcat (" Δ=", _tmp46_, " t=", _tmp48_, "ms", NULL);
	_tmp50_ = _tmp49_;
	_tmp51_ = g_strconcat (_tmp42_, _tmp50_, NULL);
	_g_free0 ((*self).res);
	(*self).res = _tmp51_;
	_g_free0 (_tmp50_);
	_g_free0 (_tmp48_);
	_g_free0 (_tmp45_);
	_tmp53_ = (*self).straind;
	_tmp54_ = (*self).stra;
	_tmp54__length1 = (*self).stra_length1;
	if (_tmp53_ < (_tmp54__length1 - 1)) {
		_tmp52_ = 1;
	} else {
		_tmp52_ = 0;
	}
	_tmp55_ = (*self).straind;
	(*self).straind = _tmp55_ + _tmp52_;
}
 void log_double_string_string(double double_value1, char* value2, char* value3) {
     
 calls_table->insert_3_strings(double_to_string(double_value1), value2, value3);
 }
 void log_jump(int new_pc,int old_pc) {
     jumps_table->insert_3_strings(double_to_string(new_pc), double_to_string(new_pc), "");
 }
Esempio n. 16
0
// # Insert data adds data to the Map before flushing to the database
void easy_sqlite_table::insert_data(std::string data) {
    int count = 0;
    map_of_values.insert(TemplateOfStrStrPair(data, double_to_string(count)));
}
static void
add_kvp_value_node(xmlNodePtr node, gchar *tag, kvp_value* val)
{
    xmlNodePtr val_node;
    gchar *tmp_str1;
    kvp_value_t kvp_type;

    kvp_type = kvp_value_get_type(val);

    if (kvp_type == KVP_TYPE_STRING)
        val_node = xmlNewTextChild(node, NULL, BAD_CAST tag, BAD_CAST kvp_value_get_string(val));
    else if (kvp_type == KVP_TYPE_TIMESPEC)
        val_node = NULL;
    else if (kvp_type == KVP_TYPE_GDATE)
    {
        GDate d = kvp_value_get_gdate(val);
        val_node = gdate_to_dom_tree(tag, &d);
        xmlAddChild (node, val_node);
    }
    else
        val_node = xmlNewTextChild(node, NULL, BAD_CAST tag, NULL);

    switch (kvp_value_get_type(val))
    {
    case KVP_TYPE_GINT64:
        add_text_to_node(val_node, "integer",
                         g_strdup_printf("%" G_GINT64_FORMAT,
                                         kvp_value_get_gint64(val)));
        break;
    case KVP_TYPE_DOUBLE:
        add_text_to_node(val_node, "double",
                         double_to_string(kvp_value_get_double(val)));
        break;
    case KVP_TYPE_NUMERIC:
        add_text_to_node(val_node, "numeric",
                         gnc_numeric_to_string(kvp_value_get_numeric(val)));
        break;
    case KVP_TYPE_STRING:
        xmlSetProp(val_node, BAD_CAST "type", BAD_CAST "string");
        break;
    case KVP_TYPE_GUID:
        /* THREAD-UNSAFE */
        add_text_to_node(val_node, "guid",
                         g_strdup(guid_to_string(kvp_value_get_guid(val))));
        break;
    case KVP_TYPE_TIMESPEC:
    {
        Timespec ts = kvp_value_get_timespec (val);

        val_node = timespec_to_dom_tree (tag, &ts);
        xmlSetProp (val_node, BAD_CAST "type", BAD_CAST "timespec");
        xmlAddChild (node, val_node);
    }
    break;
    case KVP_TYPE_GDATE:
        xmlSetProp(val_node, BAD_CAST "type", BAD_CAST "gdate");
        break;
    case KVP_TYPE_BINARY:
    {
        guint64 size;
        void *binary_data = kvp_value_get_binary(val, &size);
        xmlSetProp(val_node, BAD_CAST "type", BAD_CAST "binary");
        g_return_if_fail(binary_data);
        tmp_str1 = binary_to_string(binary_data, size);
        xmlNodeSetContent(val_node, BAD_CAST tmp_str1);
        g_free(tmp_str1);
    }
    break;
    case KVP_TYPE_GLIST:
    {
        GList *cursor;

        xmlSetProp(val_node, BAD_CAST "type", BAD_CAST "list");
        for (cursor = kvp_value_get_glist(val); cursor; cursor = cursor->next)
        {
            kvp_value *val = (kvp_value*)cursor->data;
            add_kvp_value_node(val_node, "slot:value", val);
        }
    }

    break;
    case KVP_TYPE_FRAME:
    {
        kvp_frame *frame;

        xmlSetProp(val_node, BAD_CAST "type", BAD_CAST "frame");

        frame = kvp_value_get_frame (val);
        if (!frame || !kvp_frame_get_hash (frame))
            break;

        g_hash_table_foreach_sorted(kvp_frame_get_hash(frame),
                                    add_kvp_slot, val_node, (GCompareFunc)strcmp);
    }
    break;

    }
}
Esempio n. 18
0
File: json.c Progetto: AmesianX/wine
/* ECMA-262 5.1 Edition    15.12.3 (abstract operation Str) */
static HRESULT stringify(stringify_ctx_t *ctx, jsval_t val)
{
    jsval_t value;
    HRESULT hres;

    if(is_object_instance(val) && get_object(val)) {
        jsdisp_t *obj;
        DISPID id;

        obj = iface_to_jsdisp((IUnknown*)get_object(val));
        if(!obj)
            return S_FALSE;

        hres = jsdisp_get_id(obj, toJSONW, 0, &id);
        jsdisp_release(obj);
        if(hres == S_OK)
            FIXME("Use toJSON.\n");
    }

    /* FIXME: Support replacer replacer. */

    hres = maybe_to_primitive(ctx->ctx, val, &value);
    if(FAILED(hres))
        return hres;

    switch(jsval_type(value)) {
    case JSV_NULL:
        if(!append_string(ctx, nullW))
            hres = E_OUTOFMEMORY;
        break;
    case JSV_BOOL:
        if(!append_string(ctx, get_bool(value) ? trueW : falseW))
            hres = E_OUTOFMEMORY;
        break;
    case JSV_STRING: {
        jsstr_t *str = get_string(value);
        const WCHAR *ptr = jsstr_flatten(str);
        if(ptr)
            hres = json_quote(ctx, ptr, jsstr_length(str));
        else
            hres = E_OUTOFMEMORY;
        break;
    }
    case JSV_NUMBER: {
        double n = get_number(value);
        if(is_finite(n)) {
            const WCHAR *ptr;
            jsstr_t *str;

            /* FIXME: Optimize. There is no need for jsstr_t here. */
            hres = double_to_string(n, &str);
            if(FAILED(hres))
                break;

            ptr = jsstr_flatten(str);
            assert(ptr != NULL);
            hres = ptr && !append_string_len(ctx, ptr, jsstr_length(str)) ? E_OUTOFMEMORY : S_OK;
            jsstr_release(str);
        }else {
            if(!append_string(ctx, nullW))
                hres = E_OUTOFMEMORY;
        }
        break;
    }
    case JSV_OBJECT: {
        jsdisp_t *obj;

        obj = iface_to_jsdisp((IUnknown*)get_object(value));
        if(!obj) {
            hres = S_FALSE;
            break;
        }

        if(!is_callable(obj))
            hres = is_class(obj, JSCLASS_ARRAY) ? stringify_array(ctx, obj) : stringify_object(ctx, obj);
        else
            hres = S_FALSE;

        jsdisp_release(obj);
        break;
    }
    case JSV_UNDEFINED:
        hres = S_FALSE;
        break;
    case JSV_VARIANT:
        FIXME("VARIANT\n");
        hres = E_NOTIMPL;
        break;
    }

    jsval_release(value);
    return hres;
}
Esempio n. 19
0
static void
add_kvp_value_node(xmlNodePtr node, gchar *tag, KvpValue* val)
{
    xmlNodePtr val_node;
    kvp_value_t kvp_type;

    kvp_type = kvp_value_get_type(val);

    if (kvp_type == KVP_TYPE_STRING)
    {
	gchar *newstr = g_strdup (kvp_value_get_string(val));
        val_node = xmlNewTextChild(node, NULL, BAD_CAST tag,
				   checked_char_cast (newstr));
	g_free (newstr);
    }
    else if (kvp_type == KVP_TYPE_TIMESPEC)
        val_node = NULL;
    else if (kvp_type == KVP_TYPE_GDATE)
    {
        GDate d = kvp_value_get_gdate(val);
        val_node = gdate_to_dom_tree(tag, &d);
        xmlAddChild (node, val_node);
    }
    else
        val_node = xmlNewTextChild(node, NULL, BAD_CAST tag, NULL);

    switch (kvp_value_get_type(val))
    {
    case KVP_TYPE_GINT64:
        add_text_to_node(val_node, "integer",
                         g_strdup_printf("%" G_GINT64_FORMAT,
                                         kvp_value_get_gint64(val)));
        break;
    case KVP_TYPE_DOUBLE:
        add_text_to_node(val_node, "double",
                         double_to_string(kvp_value_get_double(val)));
        break;
    case KVP_TYPE_NUMERIC:
        add_text_to_node(val_node, "numeric",
                         gnc_numeric_to_string(kvp_value_get_numeric(val)));
        break;
    case KVP_TYPE_STRING:
        xmlSetProp(val_node, BAD_CAST "type", BAD_CAST "string");
        break;
    case KVP_TYPE_GUID:
    {
        gchar guidstr[GUID_ENCODING_LENGTH+1];
        guid_to_string_buff(kvp_value_get_guid(val), guidstr);
        add_text_to_node(val_node, "guid", guidstr);
        break;
    }
    case KVP_TYPE_TIMESPEC:
    {
        Timespec ts = kvp_value_get_timespec (val);

        val_node = timespec_to_dom_tree (tag, &ts);
        xmlSetProp (val_node, BAD_CAST "type", BAD_CAST "timespec");
        xmlAddChild (node, val_node);
    }
    break;
    case KVP_TYPE_GDATE:
        xmlSetProp(val_node, BAD_CAST "type", BAD_CAST "gdate");
    break;
    case KVP_TYPE_GLIST:
    {
        GList *cursor;

        xmlSetProp(val_node, BAD_CAST "type", BAD_CAST "list");
        for (cursor = kvp_value_get_glist(val); cursor; cursor = cursor->next)
        {
            KvpValue *val = (KvpValue*)cursor->data;
            add_kvp_value_node(val_node, "slot:value", val);
        }
    }

    break;
    case KVP_TYPE_FRAME:
    {
        KvpFrame *frame;
        const char ** keys;
        unsigned int i;

        xmlSetProp(val_node, BAD_CAST "type", BAD_CAST "frame");

        frame = kvp_value_get_frame (val);
        if (!frame)
            break;

        keys = kvp_frame_get_keys(frame);
        for (i = 0; keys[i]; ++i)
            add_kvp_slot(keys[i], kvp_frame_get_value(frame, keys[i]), val_node);
        g_free(keys);
    }
    break;
    default:
	break;
    }
}
Esempio n. 20
0
void speedtest(column_list_cref_t columns, bool b_global, bool b_legacy, bool b_date)
{
	static_api_ptr_t<playlist_manager> playlist_api;
	static_api_ptr_t<titleformat_compiler> titleformat_api;
	service_ptr_t<genrand_service> p_genrand;
	p_genrand = genrand_service::g_create();

	unsigned activeplaylist_item_count = playlist_api->activeplaylist_get_item_count();

	bool b_global_colour_used = false;
	bool b_column_times_valid = false;

	unsigned column_count = columns.get_count();
	pfc::array_t<column_times> times_columns;
	times_columns.set_size(column_count);

	{
		unsigned i; 
		for (i=0; i<column_count; i++)
			if (!columns[i]->use_custom_colour)
			{
				b_global_colour_used = true;
				break;
			}
	}


	global_variable_list p_vars;

	double time_compile_global = 0, time_compile_global_colour = 0, time_global = 0, time_colour = 0;

	service_ptr_t<titleformat_object> to_global;
	service_ptr_t<titleformat_object> to_global_colour;

	{
		double time_temp = 0;
		unsigned i;
		if (b_global && column_count)
			for (i=0; i<10; i++)
			{
				to_global.release();
				pfc::hires_timer timer;
				timer.start();
				titleformat_api->compile_safe(to_global, cfg_globalstring);
				time_temp += timer.query();
			}
			time_compile_global = time_temp / 10;
	}

	{
		double time_temp = 0;
		unsigned i;
		if (b_global_colour_used)
			for (i=0; i<10; i++)
			{
				to_global_colour.release();
				pfc::hires_timer timer;
				timer.start();
				titleformat_api->compile_safe(to_global_colour, cfg_colour);
				time_temp += timer.query();
			}
			time_compile_global_colour = time_temp / 10;
	}

	pfc::array_t<unsigned> tracks;
	tracks.set_size(16);

	if (activeplaylist_item_count >= 1)
	{

		b_column_times_valid = true;

		{
			unsigned i;
			for (i=0; i<16; i++)
				tracks[i] = p_genrand->genrand(activeplaylist_item_count);
		}

		SYSTEMTIME st;
		if (b_date) GetLocalTime(&st);

		{
			pfc::string8_fast_aggressive str_temp;
			str_temp.prealloc(512);

			{
				double time_temp = 0;
				unsigned i;
				if (b_global && column_count)
					for (i=0; i<10; i++)
					{
						unsigned j;
						for (j=0;j<16;j++)
						{
							p_vars.delete_all();
							pfc::hires_timer timer;
							timer.start();
							{
								if (b_date)
								{
									playlist_api->activeplaylist_item_format_title(tracks[j], &titleformat_hook_impl_splitter(&titleformat_hook_set_global<true,false>(p_vars,b_legacy), b_date ? &titleformat_hook_date(&st) : 0), str_temp, to_global, 0, play_control::display_level_all);
								}
								else
								{
									playlist_api->activeplaylist_item_format_title(tracks[j], &titleformat_hook_set_global<true,false>(p_vars,b_legacy), str_temp, to_global, 0, play_control::display_level_all);
								}


								//	if (map_codes) extra_formatted.replace_char(3, 6);

								if (b_legacy)
								{
									const char * ptr = str_temp;

									const char * start = ptr;

									while(*ptr)
									{
										start = ptr;
										while (*ptr && *ptr != '\x07') ptr++;
										if (ptr > start)
										{
											const char * p_equal = strchr_n(start+1, '=', ptr-start-1);
											if (p_equal)
											{
												p_vars.add_item(start,p_equal-start,p_equal+1,ptr-p_equal-1);
											}
										}
										while (*ptr && *ptr == '\x07') ptr++;
									}
								}
							}
							time_temp += timer.query();
						}
					}
					time_global = time_temp / (10 * 16);
			}

			{
				double time_temp = 0;
				unsigned i;
				if (b_global_colour_used)
					for (i=0; i<10; i++)
					{
						unsigned j;
						for (j=0;j<16;j++)
						{
							colourinfo col_item(0,0,0,0,0,0);
							pfc::hires_timer timer;
							timer.start();
							playlist_api->activeplaylist_item_format_title(tracks[j], &titleformat_hook_splitter_pt3(&titleformat_hook_style(col_item),b_global ? &titleformat_hook_set_global<false,true>(p_vars, b_legacy) : 0,b_date ? &titleformat_hook_date(&st) : 0), str_temp, to_global_colour, 0, play_control::display_level_all);
							time_temp += timer.query();
						}
					}
					time_colour = time_temp / (10 * 16);
			}


			unsigned n;
			for (n=0; n<column_count; n++)
			{
				{
					double time_temp = 0;
					unsigned i;
					for (i=0; i<10; i++)
					{
						times_columns[n].to_display.release();
						pfc::hires_timer timer;
						timer.start();
						titleformat_api->compile_safe(times_columns[n].to_display, columns[n]->spec);
						time_temp += timer.query();
					}
					times_columns[n].time_display_compile = time_temp / 10;
					time_temp=0;
					for (i=0; i<10; i++)
					{
						unsigned j;
						for (j=0;j<16;j++)
						{
							pfc::hires_timer timer;
							timer.start();
							playlist_api->activeplaylist_item_format_title(tracks[j], &titleformat_hook_impl_splitter( b_global ? &titleformat_hook_set_global<false,true>(p_vars, b_legacy) :0, b_date ? &titleformat_hook_date(&st) : 0), str_temp, times_columns[n].to_display, 0, play_control::display_level_all);
							time_temp += timer.query();
						}
					}
					times_columns[n].time_display = time_temp / (10  * 16);
				}
				{
					times_columns[n].time_colour_compile = 0;
					times_columns[n].time_colour = 0;

					if (columns[n]->use_custom_colour)
					{
						double time_temp = 0;
						unsigned i;
						for (i=0; i<10; i++)
						{
							times_columns[n].to_colour.release();
							pfc::hires_timer timer;
							timer.start();
							titleformat_api->compile_safe(times_columns[n].to_colour, columns[n]->colour_spec);
							time_temp += timer.query();
						}
						times_columns[n].time_colour_compile = time_temp / 10;
						time_temp=0;
						for (i=0; i<10; i++)
						{
							unsigned j;
							for (j=0;j<16;j++)
							{
								colourinfo col_item(0,0,0,0,0,0);
								pfc::hires_timer timer;
								timer.start();
								playlist_api->activeplaylist_item_format_title(tracks[j], &titleformat_hook_splitter_pt3(&titleformat_hook_style(col_item),b_global ? &titleformat_hook_set_global<false,true>(p_vars, b_legacy) : 0,b_date ? &titleformat_hook_date(&st) : 0), str_temp, times_columns[n].to_colour, 0, play_control::display_level_all);
								time_temp += timer.query();
							}
						}
						times_columns[n].time_colour = time_temp / (10  * 16);
					}
				}
			}
		}
	}

	{
		pfc::string8_fast_aggressive buffer;
		buffer.prealloc(512);
		buffer += "script compile tests\n========\n";
		buffer += "(track)\x09\x09""variable\x09""style";
		buffer += "\n\x9\x9";
		double_to_string(time_compile_global, buffer);
		buffer += "\x9";
		double_to_string(time_compile_global_colour, buffer);

		if (b_column_times_valid)
		{
			unsigned n;

			buffer += "\n\n(column)\x09""display\x09\x09""style";

			for (n=0; n<column_count; n++)
			{
				buffer += "\ncolumn ";
				buffer.add_string(pfc::format_int(n+1));
				buffer.add_byte('\x9');
				double_to_string(times_columns[n].time_display_compile, buffer);
				buffer.add_byte('\x9');
				double_to_string(times_columns[n].time_colour_compile, buffer);
			}

			buffer += "\n\nper-track script execution tests\n========\n";
			buffer += "tracks chosen to test\n";

			for (n=0; n<16; n++)
			{
				if (n) buffer.add_string(", ");
				buffer.add_string(pfc::format_int(tracks[n]));
			}

			buffer += "\n\n(track)\x09\x09""variable\x09""style";
			buffer += "\n\x9\x9";
			double_to_string(time_global, buffer);
			buffer += "\x9";
			double_to_string(time_colour, buffer);

			buffer += "\n\n(column)\x9""display\x9\x9""style";

			for (n=0; n<column_count; n++)
			{
				buffer += "\ncolumn ";
				buffer.add_string(pfc::format_int((n+1)));
				buffer.add_byte('\x9');
				double_to_string(times_columns[n].time_display, buffer);
				buffer.add_byte('\x9');
				double_to_string(times_columns[n].time_colour, buffer);
			}

			buffer += "\n\nnotes\n========\nUnits measured in seconds.\nScipts that are never executed during use will show 0 seconds for its compilation and execution time.";

		}

		popup_message::g_show(buffer, "speedtest results");
	}
}
Esempio n. 21
0
 std::string float_to_string(float f, real_display_t display, unsigned width, unsigned precision)
   throw(std::invalid_argument)
 {
   return double_to_string((double)f, display, width, precision);
 }
Esempio n. 22
0
boost::any ConfigOptionsGroup::get_config_value(DynamicPrintConfig& config, std::string opt_key, int opt_index/* = -1*/)
{
	size_t idx = opt_index == -1 ? 0 : opt_index;
	
	boost::any ret;
	wxString text_value = wxString("");
	const ConfigOptionDef* opt = config.def()->get(opt_key);
	switch (opt->type){
	case coFloatOrPercent:{
		const auto &value = *config.option<ConfigOptionFloatOrPercent>(opt_key);
		if (value.percent)
		{
			text_value = wxString::Format(_T("%i"), int(value.value));
			text_value += "%";
		}
		else
			text_value = double_to_string(value.value);
		ret = text_value;
		break;
	}
	case coPercent:{
		double val = config.option<ConfigOptionPercent>(opt_key)->value;
		text_value = wxString::Format(_T("%i"), int(val));
		ret = text_value;// += "%";
	}
		break;
	case coPercents:
	case coFloats:
	case coFloat:{
		double val = opt->type == coFloats ?
					config.opt_float(opt_key, idx) :
						opt->type == coFloat ? config.opt_float(opt_key) :
						config.option<ConfigOptionPercents>(opt_key)->values.at(idx);
		ret = double_to_string(val);
		}
		break;
	case coString:
		ret = static_cast<wxString>(config.opt_string(opt_key));
		break;
	case coStrings:
		if (config.option<ConfigOptionStrings>(opt_key)->values.empty())
			ret = text_value;
		else
			ret = static_cast<wxString>(config.opt_string(opt_key, static_cast<unsigned int>(idx)));
		break;
	case coBool:
		ret = config.opt_bool(opt_key);
		break;
	case coBools:
		ret = config.opt_bool(opt_key, idx);
		break;
	case coInt:
		ret = config.opt_int(opt_key);
		break;
	case coInts:
		ret = config.opt_int(opt_key, idx);
		break;
	case coEnum:{
		if (opt_key.compare("external_fill_pattern") == 0 ||
			opt_key.compare("fill_pattern") == 0 ){
			ret = static_cast<int>(config.option<ConfigOptionEnum<InfillPattern>>(opt_key)->value);
		}
		else if (opt_key.compare("gcode_flavor") == 0 ){
			ret = static_cast<int>(config.option<ConfigOptionEnum<GCodeFlavor>>(opt_key)->value);
		}
		else if (opt_key.compare("support_material_pattern") == 0){
			ret = static_cast<int>(config.option<ConfigOptionEnum<SupportMaterialPattern>>(opt_key)->value);
		}
		else if (opt_key.compare("seam_position") == 0)
			ret = static_cast<int>(config.option<ConfigOptionEnum<SeamPosition>>(opt_key)->value);
	}
		break;
	case coPoints:{
		const auto &value = *config.option<ConfigOptionPoints>(opt_key);
		ret = value.values.at(idx);
		}
		break;
	case coNone:
	default:
		break;
	}
	return ret;
}
Esempio n. 23
0
/*
 * csql_db_value_as_string() - convert DB_VALUE to string
 *   return: formatted string
 *   value(in): value to convert
 *   length(out): length of output string
 *   plain_output(in): refine string for plain output
 */
char *
csql_db_value_as_string (DB_VALUE * value, int *length, bool plain_string)
{
  char *result = NULL;
  int len = 0;

  if (value == NULL)
    {
      return (NULL);
    }

  switch (DB_VALUE_TYPE (value))
    {
    case DB_TYPE_BIGINT:
      result =
	bigint_to_string (DB_GET_BIGINT (value), default_bigint_profile.fieldwidth, default_bigint_profile.leadingzeros,
			  default_bigint_profile.leadingsymbol, default_bigint_profile.commas,
			  default_bigint_profile.format);
      if (result)
	{
	  len = strlen (result);
	}
      break;
    case DB_TYPE_INTEGER:
      result =
	bigint_to_string (DB_GET_INTEGER (value), default_int_profile.fieldwidth, default_int_profile.leadingzeros,
			  default_int_profile.leadingsymbol, default_int_profile.commas, default_int_profile.format);
      if (result)
	{
	  len = strlen (result);
	}
      break;
    case DB_TYPE_SHORT:
      result =
	bigint_to_string (SHORT_TO_INT (DB_GET_SHORT (value)), default_short_profile.fieldwidth,
			  default_short_profile.leadingzeros, default_short_profile.leadingsymbol,
			  default_short_profile.commas, default_short_profile.format);
      if (result)
	{
	  len = strlen (result);
	}
      break;
    case DB_TYPE_FLOAT:
      result =
	double_to_string ((double) DB_GET_FLOAT (value), default_float_profile.fieldwidth,
			  default_float_profile.precision, default_float_profile.leadingsign, NULL, NULL,
			  default_float_profile.leadingzeros, default_float_profile.trailingzeros,
			  default_float_profile.commas, default_float_profile.format);
      if (result)
	{
	  len = strlen (result);
	}
      break;
    case DB_TYPE_DOUBLE:
      result =
	double_to_string (DB_GET_DOUBLE (value), default_double_profile.fieldwidth, default_double_profile.precision,
			  default_double_profile.leadingsign, NULL, NULL, default_double_profile.leadingzeros,
			  default_double_profile.trailingzeros, default_double_profile.commas,
			  default_double_profile.format);
      if (result)
	{
	  len = strlen (result);
	}
      break;
    case DB_TYPE_NUMERIC:
      result = numeric_to_string (value, default_numeric_profile.commas);
      if (result)
	{
	  len = strlen (result);
	}
      break;
    case DB_TYPE_VARCHAR:
    case DB_TYPE_CHAR:
      {
	int dummy, bytes_size, decomp_size;
	bool need_decomp = false;
	char *str;
	char *decomposed = NULL;

	str = db_get_char (value, &dummy);
	bytes_size = db_get_string_size (value);
	if (bytes_size > 0 && DB_GET_STRING_CODESET (value) == INTL_CODESET_UTF8)
	  {
	    need_decomp =
	      unicode_string_need_decompose (str, bytes_size, &decomp_size, lang_get_generic_unicode_norm ());
	  }

	if (need_decomp)
	  {
	    decomposed = (char *) malloc (decomp_size * sizeof (char));
	    if (decomposed != NULL)
	      {
		unicode_decompose_string (str, bytes_size, decomposed, &decomp_size, lang_get_generic_unicode_norm ());

		str = decomposed;
		bytes_size = decomp_size;
	      }
	    else
	      {
		return NULL;
	      }
	  }

	result = string_to_string (str, default_string_profile.string_delimiter, '\0', bytes_size, &len, plain_string);

	if (decomposed != NULL)
	  {
	    free_and_init (decomposed);
	  }

      }
      break;
    case DB_TYPE_VARNCHAR:
    case DB_TYPE_NCHAR:
      {
	int dummy, bytes_size, decomp_size;
	bool need_decomp = false;
	char *str;
	char *decomposed = NULL;

	str = db_get_char (value, &dummy);
	bytes_size = db_get_string_size (value);
	if (bytes_size > 0 && DB_GET_STRING_CODESET (value) == INTL_CODESET_UTF8)
	  {
	    need_decomp =
	      unicode_string_need_decompose (str, bytes_size, &decomp_size, lang_get_generic_unicode_norm ());
	  }

	if (need_decomp)
	  {
	    decomposed = (char *) malloc (decomp_size * sizeof (char));
	    if (decomposed != NULL)
	      {
		unicode_decompose_string (str, bytes_size, decomposed, &decomp_size, lang_get_generic_unicode_norm ());

		str = decomposed;
		bytes_size = decomp_size;
	      }
	    else
	      {
		return NULL;
	      }
	  }

	result = string_to_string (str, default_string_profile.string_delimiter, 'N', bytes_size, &len, plain_string);

	if (decomposed != NULL)
	  {
	    free_and_init (decomposed);
	  }
      }
      break;
    case DB_TYPE_VARBIT:
    case DB_TYPE_BIT:
      result = bit_to_string (value, default_string_profile.string_delimiter, plain_string);
      if (result)
	{
	  len = strlen (result);
	}
      break;
    case DB_TYPE_OBJECT:
      result = object_to_string (DB_GET_OBJECT (value), get_object_print_format ());
      if (result == NULL)
	{
	  result = duplicate_string ("NULL");
	}
      if (result)
	{
	  len = strlen (result);
	}
      break;
    case DB_TYPE_VOBJ:
      result = object_to_string (DB_GET_OBJECT (value), get_object_print_format ());
      if (result == NULL)
	{
	  result = duplicate_string ("NULL");
	}
      if (result)
	{
	  len = strlen (result);
	}
      break;
    case DB_TYPE_SET:
    case DB_TYPE_MULTISET:
    case DB_TYPE_SEQUENCE:
      result =
	set_to_string (value, default_set_profile.begin_notation, default_set_profile.end_notation,
		       default_set_profile.max_entries, plain_string);
      if (result)
	{
	  len = strlen (result);
	}
      break;
    case DB_TYPE_TIME:
      {
	char buf[TIME_BUF_SIZE];
	if (db_time_to_string (buf, sizeof (buf), DB_GET_TIME (value)))
	  {
	    result = duplicate_string (buf);
	  }
	if (result)
	  {
	    len = strlen (result);
	  }
	break;
      }
    case DB_TYPE_TIMETZ:
      {
	char buf[TIMETZ_BUF_SIZE];
	DB_TIMETZ *time_tz = DB_GET_TIMETZ (value);
	if (db_timetz_to_string (buf, sizeof (buf), &(time_tz->time), &time_tz->tz_id))
	  {
	    result = duplicate_string (buf);
	  }

	if (result)
	  {
	    len = strlen (result);
	  }
      }
      break;
    case DB_TYPE_TIMELTZ:
      {
	char buf[TIMETZ_BUF_SIZE];

	if (db_timeltz_to_string (buf, sizeof (buf), DB_GET_TIME (value)))
	  {
	    result = duplicate_string (buf);
	  }

	if (result)
	  {
	    len = strlen (result);
	  }
      }
      break;
    case DB_TYPE_MONETARY:
      {
	char *leading_str = NULL;
	char *trailing_str = NULL;
	DB_CURRENCY currency = ((DB_GET_MONETARY (value))->type);

	if (default_monetary_profile.currency_symbol)
	  {
	    if (intl_get_currency_symbol_position (currency) == 1)
	      {
		trailing_str = intl_get_money_symbol_console (currency);
	      }
	    else
	      {
		leading_str = intl_get_money_symbol_console (currency);
	      }
	  }

	result =
	  (DB_GET_MONETARY (value) == NULL) ? NULL : double_to_string ((DB_GET_MONETARY (value))->amount,
								       default_monetary_profile.fieldwidth,
								       default_monetary_profile.decimalplaces,
								       default_monetary_profile.leadingsign,
								       leading_str, trailing_str,
								       default_monetary_profile.leadingzeros,
								       default_monetary_profile.trailingzeros,
								       default_monetary_profile.commas,
								       DOUBLE_FORMAT_DECIMAL);

	if (result)
	  {
	    len = strlen (result);
	  }
      }
      break;
    case DB_TYPE_DATE:
      /* default format for all locales */
      result = date_as_string (DB_GET_DATE (value), default_date_profile.format);
      if (result)
	{
	  len = strlen (result);
	}
      break;
    case DB_TYPE_UTIME:
      {
	char buf[TIMESTAMP_BUF_SIZE];
	if (db_utime_to_string (buf, sizeof (buf), DB_GET_UTIME (value)))
	  {
	    result = duplicate_string (buf);
	  }

	if (result)
	  {
	    len = strlen (result);
	  }
      }
      break;
    case DB_TYPE_TIMESTAMPTZ:
      {
	char buf[TIMESTAMPTZ_BUF_SIZE];
	DB_TIMESTAMPTZ *ts_tz = DB_GET_TIMESTAMPTZ (value);
	if (db_timestamptz_to_string (buf, sizeof (buf), &(ts_tz->timestamp), &(ts_tz->tz_id)))
	  {
	    result = duplicate_string (buf);
	  }

	if (result)
	  {
	    len = strlen (result);
	  }
      }
      break;
    case DB_TYPE_TIMESTAMPLTZ:
      {
	char buf[TIMESTAMPTZ_BUF_SIZE];

	if (db_timestampltz_to_string (buf, sizeof (buf), DB_GET_UTIME (value)))
	  {
	    result = duplicate_string (buf);
	  }

	if (result)
	  {
	    len = strlen (result);
	  }
      }
      break;
    case DB_TYPE_DATETIME:
      {
	char buf[DATETIME_BUF_SIZE];
	if (db_datetime_to_string (buf, sizeof (buf), DB_GET_DATETIME (value)))
	  {
	    result = duplicate_string (buf);
	  }

	if (result)
	  {
	    len = strlen (result);
	  }
      }
      break;
    case DB_TYPE_DATETIMETZ:
      {
	char buf[DATETIMETZ_BUF_SIZE];
	DB_DATETIMETZ *dt_tz = DB_GET_DATETIMETZ (value);
	if (db_datetimetz_to_string (buf, sizeof (buf), &(dt_tz->datetime), &(dt_tz->tz_id)))
	  {
	    result = duplicate_string (buf);
	  }

	if (result)
	  {
	    len = strlen (result);
	  }
      }
      break;
    case DB_TYPE_DATETIMELTZ:
      {
	char buf[DATETIMETZ_BUF_SIZE];

	if (db_datetimeltz_to_string (buf, sizeof (buf), DB_GET_DATETIME (value)))
	  {
	    result = duplicate_string (buf);
	  }

	if (result)
	  {
	    len = strlen (result);
	  }
      }
      break;
    case DB_TYPE_NULL:
      result = duplicate_string ("NULL");
      if (result)
	{
	  len = strlen (result);
	}
      break;

    case DB_TYPE_BLOB:
    case DB_TYPE_CLOB:
      {
	DB_ELO *elo = DB_GET_ELO (value);

	if (elo != NULL)
	  {
	    result = duplicate_string (elo->locator);
	  }

	if (result != NULL)
	  {
	    len = strlen (result);
	  }
      }
      break;

    case DB_TYPE_ENUMERATION:
      {
	int bytes_size, decomp_size;
	bool need_decomp = false;
	const char *str;
	char *decomposed = NULL;

	if (db_get_enum_short (value) == 0 && db_get_enum_string (value) == NULL)
	  {
	    /* ENUM special error value */
	    str = "";
	    bytes_size = 0;
	  }
	else
	  {
	    str = db_get_enum_string (value);
	    bytes_size = db_get_enum_string_size (value);
	  }
	if (bytes_size > 0 && db_get_enum_codeset (value) == INTL_CODESET_UTF8)
	  {
	    need_decomp =
	      unicode_string_need_decompose (str, bytes_size, &decomp_size, lang_get_generic_unicode_norm ());
	  }

	if (need_decomp)
	  {
	    decomposed = (char *) malloc (decomp_size * sizeof (char));
	    if (decomposed != NULL)
	      {
		unicode_decompose_string (str, bytes_size, decomposed, &decomp_size, lang_get_generic_unicode_norm ());

		str = decomposed;
		bytes_size = decomp_size;
	      }
	    else
	      {
		return NULL;
	      }
	  }

	result = string_to_string (str, default_string_profile.string_delimiter, '\0', bytes_size, &len, plain_string);
	if (decomposed != NULL)
	  {
	    free_and_init (decomposed);
	  }
      }
      break;

    default:
      {
	char temp_buffer[256];

	(void) sprintf (temp_buffer, "<%s>", db_get_type_name (DB_VALUE_TYPE (value)));
	result = duplicate_string (temp_buffer);
	if (result)
	  {
	    len = strlen (result);
	  }
      }
    }

  if (length)
    {
      *length = len;
    }
  return result;
}