Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 645294 | Differences between
and this patch

Collapse All | Expand All

(-)shogun-5.0.0/src/shogun/io/SerializableJsonFile.cpp_orig (-14 / +12 lines)
Lines 45-51 Link Here
45
                         m_stack_stream.back(), STR_KEY_FILETYPE, &buf);
45
                         m_stack_stream.back(), STR_KEY_FILETYPE, &buf);
46
46
47
	if (!success || buf == NULL
47
	if (!success || buf == NULL
48
		|| is_error(buf)
49
		|| (ftype = json_object_get_string(buf)) == NULL)
48
		|| (ftype = json_object_get_string(buf)) == NULL)
50
		return NULL;
49
		return NULL;
51
50
Lines 80-90 Link Here
80
CSerializableJsonFile::get_object(json_object** dest, json_object* src,
79
CSerializableJsonFile::get_object(json_object** dest, json_object* src,
81
								  const char* key, json_type t)
80
								  const char* key, json_type t)
82
{
81
{
83
        bool success = true ;
82
       bool success = true;
84
        success = json_object_object_get_ex(src, key, & *dest);
83
       success = json_object_object_get_ex(src, key, &*dest);
85
84
86
	return success && *dest != NULL && !is_error(*dest)
85
	return success && *dest != nullptr && json_object_is_type(*dest, t);
87
		&& json_object_is_type(*dest, t);
88
}
86
}
89
87
90
void
88
void
Lines 100-106 Link Here
100
	switch (m_task) {
98
	switch (m_task) {
101
	case 'r':
99
	case 'r':
102
		buf = json_object_from_file((char*) fname);
100
		buf = json_object_from_file((char*) fname);
103
		if (is_error(buf)) {
101
		if (buf == nullptr) {
104
			SG_ERROR("Could not open file `%s' for reading!\n",
102
			SG_ERROR("Could not open file `%s' for reading!\n",
105
					   fname);
103
					   fname);
106
			return;
104
			return;
Lines 222-228 Link Here
222
		break;
220
		break;
223
	}
221
	}
224
222
225
	if (is_error(m_stack_stream.back()))
223
	if (m_stack_stream.back() == nullptr)
226
		return false;
224
		return false;
227
225
228
	return true;
226
	return true;
Lines 292-298 Link Here
292
	push_object(json_object_new_object());
290
	push_object(json_object_new_object());
293
291
294
	json_object* buf = json_object_new_array();
292
	json_object* buf = json_object_new_array();
295
	if (is_error(buf))
293
	if (buf == nullptr)
296
		return false;
294
		return false;
297
295
298
	json_object_object_add(m_stack_stream.back(),
296
	json_object_object_add(m_stack_stream.back(),
Lines 322-328 Link Here
322
	push_object(buf);
320
	push_object(buf);
323
321
324
	buf = json_object_new_int(feat_index);
322
	buf = json_object_new_int(feat_index);
325
	if (is_error(buf))
323
	if (buf == nullptr)
326
		return false;
324
		return false;
327
325
328
	json_object_object_add(m_stack_stream.back(),
326
	json_object_object_add(m_stack_stream.back(),
Lines 383-389 Link Here
383
381
384
	json_object* buf;
382
	json_object* buf;
385
	buf = json_object_new_string(sgserializable_name);
383
	buf = json_object_new_string(sgserializable_name);
386
	if (is_error(buf))
384
	if (buf == nullptr)
387
		return false;
385
		return false;
388
386
389
	json_object_object_add(m_stack_stream.back(),
387
	json_object_object_add(m_stack_stream.back(),
Lines 393-399 Link Here
393
		string_t buf_str;
391
		string_t buf_str;
394
		TSGDataType::ptype_to_string(buf_str, generic, STRING_LEN);
392
		TSGDataType::ptype_to_string(buf_str, generic, STRING_LEN);
395
		buf = json_object_new_string(buf_str);
393
		buf = json_object_new_string(buf_str);
396
		if (is_error(buf))
394
		if (buf == nullptr)
397
			return false;
395
			return false;
398
396
399
		json_object_object_add(m_stack_stream.back(),
397
		json_object_object_add(m_stack_stream.back(),
Lines 401-407 Link Here
401
	}
399
	}
402
400
403
	buf = json_object_new_object();
401
	buf = json_object_new_object();
404
	if (is_error(buf))
402
	if (buf == nullptr)
405
		return false;
403
		return false;
406
	json_object_object_add(m_stack_stream.back(), STR_KEY_INSTANCE,
404
	json_object_object_add(m_stack_stream.back(), STR_KEY_INSTANCE,
407
						   buf);
405
						   buf);
Lines 426-432 Link Here
426
	const TSGDataType* type, const char* name, const char* prefix)
424
	const TSGDataType* type, const char* name, const char* prefix)
427
{
425
{
428
	json_object* buf = json_object_new_object();
426
	json_object* buf = json_object_new_object();
429
	if (is_error(buf))
427
	if (buf == nullptr)
430
		return false;
428
		return false;
431
429
432
	json_object_object_add(m_stack_stream.back(), name, buf);
430
	json_object_object_add(m_stack_stream.back(), name, buf);
Lines 435-441 Link Here
435
	string_t str_buf;
433
	string_t str_buf;
436
	type->to_string(str_buf, STRING_LEN);
434
	type->to_string(str_buf, STRING_LEN);
437
	buf = json_object_new_string(str_buf);
435
	buf = json_object_new_string(str_buf);
438
	if (is_error(buf))
436
	if (buf == nullptr)
439
		return false;
437
		return false;
440
438
441
	json_object_object_add(m_stack_stream.back(), STR_KEY_TYPE, buf);
439
	json_object_object_add(m_stack_stream.back(), STR_KEY_TYPE, buf);

Return to bug 645294