static char* process_fixed_string(char *source) { unsigned int value; char *destination; source += 8; destination = source; while (source[0]) { value = (unsigned char)source[0]; if (value == '\\' && source[1] == 'x' && is_hex_number(source[2]) && is_hex_number(source[3])) { value = hex_number_value(source[2]) << 4 | hex_number_value(source[3]); source += 3; } source++; *destination++ = value; } if (destination[-1] == '\n') { destination--; destination[0] = '\0'; } return destination; }
void getColorAttributeFromNode(dom::NodePtr theStyleNode, const std::string& theAttributeName, asl::Vector4f & theMember) { if (theStyleNode->getAttribute(theAttributeName)) { std::string myAttribute = theStyleNode->getAttribute(theAttributeName)->nodeValue(); if (myAttribute.substr(0, 1) == "[") { asl::fromString(myAttribute, theMember); } else if (myAttribute.size() == 6) { // hex color conversion unsigned r = 0; unsigned g = 0; unsigned b = 0; bool success = is_hex_number(myAttribute.substr(0, 2), r); success &= is_hex_number(myAttribute.substr(2, 2), g); success &= is_hex_number(myAttribute.substr(4, 2), b); if (success) { theMember[0]= r/255.0f; theMember[1]= g/255.0f; theMember[2]= b/255.0f; theMember[3] = 1.0f; } } else { throw asl::Exception("unknown textstyle color format " + myAttribute, PLUS_FILE_LINE); } } }
bool lex_stream_t::implementation_t::is_number(char c, stream_lex_token_t& result) { return is_hex_number(c, result) || is_dec_number(c, result); }