#include <cstdlib>
#include <stdio.h>
#include <fstream>
#include <vector>
#include <iostream>
#include <boost/algorithm/string.hpp>
using namespace std;
using namespace boost;
int main(int argc, char** argv) {
ifstream file("C:/home/shk/circles.xbm", ios_base::in | ios_base::binary);
file.seekg(0, ios::end);
int len = file.tellg();
file.seekg(0, ios::beg);
char* s = new char[len];
file.read(s, len);
//
// Here file data
//
string line(s);
size_t pos_brace1 = line.find("{");
size_t pos_brace2 = line.find("}");
string str2 = line.substr ((int)pos_brace1 + 1, (int)pos_brace2);
//
// trim string
//
trim(str2);
//
// Delete }; at the *.xbm end
//
str2.erase(str2.length() - 2);
//
// Split string by ', '
// PixelVector - dynamic array with pixels
typedef vector<string> split_vector_type;
split_vector_type PixelVector;
split( PixelVector, str2, is_any_of(", "), token_compress_on );
//
// Width and height parsing
// Example:
// str 3 =
// #define icon_width 16
// #define icon_height 16
// #define icon_x_hot 4
// #define icon_y_hot 4
size_t pos_brace3 = line.find("#define");
size_t pos_brace4 = line.find("static");
string str3 = line.substr ((int)pos_brace3, (int)pos_brace4);
//
// Split #define width
//
split_vector_type PixelVector2;
split( PixelVector2, str3, is_any_of(" \n"), token_compress_on );
//
// vector Parameters - width heigth hot points
//
vector<string> Parameters;
int count = 0;
for (int i = 0; i < PixelVector2.size() - 1; i++){
++count;
if (count == 3){
Parameters.push_back(PixelVector2.at(i));
count = 0;
}
}
file.close();
return 0;
}