43 lines
1.0 KiB
C++
43 lines
1.0 KiB
C++
#include <fstream>
|
|
#include <sstream>
|
|
#include <iostream>
|
|
#include <vector>
|
|
|
|
#include "TranslationUnit.hpp"
|
|
|
|
using namespace std;
|
|
|
|
void TranslationUnit::parseTranslationUnit(string filename, std::list<string> args){
|
|
ifstream fileStream(filename);
|
|
|
|
|
|
int currentLineNumber = 0;
|
|
string currentLine;
|
|
while(getline(fileStream, currentLine)){
|
|
|
|
bool insideString = false;
|
|
|
|
int lineBegin = 0;
|
|
vector<string> splittedLines;
|
|
for(int i = 0; i< currentLine.size(); i++){
|
|
if(currentLine.at(i) == '\"'){
|
|
if(insideString){
|
|
insideString = false;
|
|
}else{
|
|
insideString = true;
|
|
}
|
|
}else if((currentLine.at(i)== ':' && !insideString) || i == currentLine.size() - 1){
|
|
cout << currentLine.substr(lineBegin, i- lineBegin) << endl;
|
|
splittedLines.push_back(currentLine.substr(lineBegin, i - lineBegin));
|
|
lineBegin = i+1;
|
|
}
|
|
}
|
|
/*
|
|
splittedLines.push_back(currentLine.substr(lineBegin, i - lineBegin));
|
|
cout << currentLine.substr(lineBegin, currentLine.size() - lineBegin) << endl;
|
|
*/
|
|
currentLineNumber++;
|
|
}
|
|
|
|
fileStream.close();
|
|
} |