*/
#include <memory.h>
+#include <sstream>
#include <libxml/parser.h>
#include "label_properties_parser.h"
#include "xml_parser_utils.h"
#include "simple_debug.h"
#include "put_record.h"
+
+using namespace std;
+
static int
match_alignment(const char* key) {
assert(key != NULL);
a = 0xff;
char temp_string[5] = {"0xFF"};
+
temp_string[2] = key[2];
temp_string[3] = key[3];
- if (sscanf(temp_string, "%x", &r) <= 0) {
- SCLLOG(SclLog::ERROR, "parsing_rgb() has failed.");
+ stringstream convertor_r(temp_string);
+ convertor_r >> hex >> r;
+ if (convertor_r.fail() == true) {
+ SCLLOG(SclLog::ERROR, "parsing_rgb() [r] has failed.");
+ r = 0;
}
temp_string[2] = key[4];
temp_string[3] = key[5];
- if (sscanf(temp_string, "%x", &g) <= 0) {
- SCLLOG(SclLog::ERROR, "parsing_rgb() has failed.");
+ stringstream convertor_g(temp_string);
+ convertor_g >> hex >> g;
+ if (convertor_g.fail() == true) {
+ SCLLOG(SclLog::ERROR, "parsing_rgb() [g] has failed.");
+ g = 0;
}
+
temp_string[2] = key[6];
temp_string[3] = key[7];
- if (sscanf(temp_string, "%x", &b) <= 0) {
- SCLLOG(SclLog::ERROR, "parsing_rgb() has failed.");
+ stringstream convertor_b(temp_string);
+ convertor_b >> hex >> b;
+ if (convertor_b.fail() == true) {
+ SCLLOG(SclLog::ERROR, "parsing_rgb() [b] has failed.");
+ b = 0;
}
temp_string[2] = key[8];
temp_string[3] = key[9];
- if (sscanf(temp_string, "%x", &a) <= 0) {
- SCLLOG(SclLog::ERROR, "parsing_rgb() has failed.");
+ stringstream convertor_a(temp_string);
+ convertor_a >> hex >> a;
+ if (convertor_a.fail() == true) {
+ SCLLOG(SclLog::ERROR, "parsing_rgb() [a] has failed.");
+ a = 0;
}
cur_color.r = r;
#include "layout_parser_helper.h"
#include <stdio.h>
#include <string>
+#include <sstream>
using namespace std;
const string RotationHelper::pcPortrait = "portrait";
}
const int INTTypeHelper::Int(const string str) {
int val = 0;
- sscanf(str.c_str(), "%d", &val);
+ stringstream convertor(str);
+
+ convertor >> val;
+ if (convertor.fail() == true) {
+ val = 0;
+ }
+
return val;
}
const int INTTypeHelper::dexInt(const string str) {
int val = 0;
- sscanf(str.c_str(), "%x", &val);
+ stringstream convertor(str);
+
+ convertor >> hex >> val;
+ if (convertor.fail() == true) {
+ val = 0;
+ }
return val;
}