Ejemplo n.º 1
0
void Level::convert_byte_map(){
	for (int i = 0; i < height; i++){
		for (int j = 0; j < width; j++){
			terrain_map[i][j] = convert_byte(i, j, terrain_save_map[i][j]);
		}
	}
}
Ejemplo n.º 2
0
static 
int convert_raw_string(void *raw_data, int max_size, char raw_str[]) {
	int i = 0;
	int endian = 0; //0=le; 1=be
	int base = 16;
	int start_i = 0;
	int data_index = 0;
	uint8_t *data = (uint8_t *) raw_data;
	//convert raw_data string
	int length = strlen(raw_str);
	
	//check endianess
	if((length > 4) && raw_str[start_i] == '(' && raw_str[start_i+3] == ')') {
		if (isalpha(raw_str[start_i+1]) && isalpha(raw_str[start_i+2]) &&
		    toupper(raw_str[start_i+1]) == 'B' && toupper(raw_str[start_i+2]) == 'E') {
				endian = 1;
		}
		
		start_i = 4;
	}	
	
	if((length > start_i + 1) && raw_str[start_i] == '0' && isalpha(raw_str[start_i+1]) && (toupper(raw_str[start_i+1]) == 'X')) { //hex
		base = 16;
		start_i += 2;
	}
	else { //we assume value data is in hex format
		printf("Assuming hex value (base 16)\n");
		base = 16;
	}
	
	char str[2];
	
	for(i=start_i; i<length; i++) {
		if(i+1 < length)
		{
			str[1] = raw_str[i];
			str[0] = raw_str[i+1];
			i++;
		}
		else
		{
			str[1] = 0;
			str[0] = raw_str[i];
		}
		
		data[data_index] = convert_byte(str, base);
		data_index++;
	}
	
	if(endian > 0) {
		//convert from big endian to little endian
		data = raw_inv(data, data_index);
	}
	
	// size in bytes
	return (data_index);
}
Ejemplo n.º 3
0
 std::string binary_archive_content(Buffer const& buffer)
 {
     std::string result;
     if (LPT_ENABLED(debug))
     {
         result.reserve(buffer.data_.size() * 2 + 1);
         for (boost::uint8_t byte: buffer.data_)
         {
             char b[3] = { 0 };
             convert_byte(byte, &b[0], &b[3]);
             result += b;
         }
     }
     return result;
 }
Ejemplo n.º 4
0
void zmq::uuid_t::create_blob ()
{
    const char *buf = (const char*) string_buf;

    blob_buf [0] = convert_byte (buf + 0);
    blob_buf [1] = convert_byte (buf + 2);
    blob_buf [2] = convert_byte (buf + 4);
    blob_buf [3] = convert_byte (buf + 6);

    blob_buf [4] = convert_byte (buf + 9);
    blob_buf [5] = convert_byte (buf + 11);

    blob_buf [6] = convert_byte (buf + 14);
    blob_buf [7] = convert_byte (buf + 16);

    blob_buf [8] = convert_byte (buf + 19);
    blob_buf [9] = convert_byte (buf + 21);

    blob_buf [10] = convert_byte (buf + 24);
    blob_buf [11] = convert_byte (buf + 26);
    blob_buf [12] = convert_byte (buf + 28);
    blob_buf [13] = convert_byte (buf + 30);
    blob_buf [14] = convert_byte (buf + 32);
    blob_buf [15] = convert_byte (buf + 34);
}
Ejemplo n.º 5
0
void zmq::uuid_t::create_blob ()
{
    char *buf = reinterpret_cast<char*>(string_buf);

#ifdef UNICODE // we need to jump twice as far.
	blob_buf [0] = convert_byte (buf + 0);
    blob_buf [1] = convert_byte (buf + 4);
    blob_buf [2] = convert_byte (buf + 8);
    blob_buf [3] = convert_byte (buf + 12);

    blob_buf [4] = convert_byte (buf + 18);
    blob_buf [5] = convert_byte (buf + 22);

    blob_buf [6] = convert_byte (buf + 28);
    blob_buf [7] = convert_byte (buf + 32);

    blob_buf [8] = convert_byte (buf + 38);
    blob_buf [9] = convert_byte (buf + 42);

    blob_buf [10] = convert_byte (buf + 48);
    blob_buf [11] = convert_byte (buf + 52);
    blob_buf [12] = convert_byte (buf + 56);
    blob_buf [13] = convert_byte (buf + 60);
    blob_buf [14] = convert_byte (buf + 64);
    blob_buf [15] = convert_byte (buf + 68);
#else
	blob_buf [0] = convert_byte (buf + 0);
    blob_buf [1] = convert_byte (buf + 2);
    blob_buf [2] = convert_byte (buf + 4);
    blob_buf [3] = convert_byte (buf + 6);

    blob_buf [4] = convert_byte (buf + 9);
    blob_buf [5] = convert_byte (buf + 11);

    blob_buf [6] = convert_byte (buf + 14);
    blob_buf [7] = convert_byte (buf + 16);

    blob_buf [8] = convert_byte (buf + 19);
    blob_buf [9] = convert_byte (buf + 21);

    blob_buf [10] = convert_byte (buf + 24);
    blob_buf [11] = convert_byte (buf + 26);
    blob_buf [12] = convert_byte (buf + 28);
    blob_buf [13] = convert_byte (buf + 30);
    blob_buf [14] = convert_byte (buf + 32);
    blob_buf [15] = convert_byte (buf + 34);
#endif

	buf = NULL; delete buf;
}