Instantly share code, notes, and snippets.

Embed
What would you like to do?
#include <iostream>
#include <fstream>
#include <set>
int main() {
std::ifstream file;
file.open("hpp.orb", std::ios::binary);
if (!file.is_open())
return 1;
char *className = new char[128];
std::set<std::string> names;
while(!file.eof()){
char ch = file.get();
if (ch != 'C')
continue;
unsigned short stringSize;
file.seekg(-3, std::ios_base::cur);
file.read((char*) &stringSize, 2);
if (stringSize > 64 || stringSize < 6) {
file.seekg(1, std::ios_base::cur);
continue;
}
file.read(className, stringSize);
className[stringSize] = '\0';
bool isSuitable = 1;
int caps = 0;
for (int i = 0; i < stringSize; ++i) {
if (!isalpha(className[i])) {
isSuitable = 0;
break;
}
if (isupper(className[i])){
caps++;
}
}
if (isSuitable && caps != stringSize)
names.insert(std::string(className));
}
std::cout << names.size() << '\n';
for (auto &name : names) {
std::cout << name << '\n';
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment