47 @return True/False depending on the status of parameter-file open statement. |
47 @return True/False depending on the status of parameter-file open statement. |
48 */ |
48 */ |
49 bool CParameterFileProcessor::OpenFile() |
49 bool CParameterFileProcessor::OpenFile() |
50 { |
50 { |
51 |
51 |
52 iParamFile.open(iParamFileName.data(),std::ios::binary); |
52 iParamFile.open(iParamFileName.data(),ios_base::binary); |
53 if (iParamFile.is_open()) |
53 if (iParamFile.is_open()) |
54 return true; |
54 return true; |
55 else |
55 else |
56 { |
56 { |
57 std::cout<<"Error: Couldn't open parameter-file for reading:"<<iParamFileName.c_str()<<"\n"; |
57 cout<<"Error: Couldn't open parameter-file for reading:"<<iParamFileName.c_str()<<"\n"; |
58 return false; |
58 return false; |
59 } |
59 } |
60 } |
60 } |
61 |
61 |
62 |
62 |
73 if(OpenFile()) |
73 if(OpenFile()) |
74 { |
74 { |
75 while(!iParamFile.eof()) |
75 while(!iParamFile.eof()) |
76 { |
76 { |
77 // Read the parameter-file line by line. |
77 // Read the parameter-file line by line. |
78 String line; |
78 string line; |
79 std::getline(iParamFile,line); |
79 getline(iParamFile,line); |
80 |
80 |
81 // Read the line till the occurence of character ';' or EOL. |
81 // Read the line till the occurence of character ';' or EOL. |
82 unsigned int pos = line.find_first_of(";\r\n"); |
82 unsigned int pos = line.find_first_of(";\r\n"); |
83 if (pos != std::string::npos) |
83 if (pos != string::npos) |
84 line = line.substr(0,pos); |
84 line = line.substr(0,pos); |
85 |
85 |
86 // Split the line if multiple parameters are provided |
86 // Split the line if multiple parameters are provided |
87 // in a single line. |
87 // in a single line. |
88 if(!SplitLine(line)) |
88 if(!SplitLine(line)) |
114 @internalComponent |
114 @internalComponent |
115 @released |
115 @released |
116 |
116 |
117 @return True/False depending on the status of spliting. |
117 @return True/False depending on the status of spliting. |
118 */ |
118 */ |
119 bool CParameterFileProcessor::SplitLine(String& aLine) |
119 bool CParameterFileProcessor::SplitLine(string& aLine) |
120 { |
120 { |
121 unsigned int startPos=0; |
121 unsigned int startPos=0; |
122 unsigned int endPos=0; |
122 unsigned int endPos=0; |
123 |
123 |
124 // Segregate parameters based on white-space or tabs. |
124 // Segregate parameters based on white-space or tabs. |
125 startPos= aLine.find_first_not_of(" \t",endPos); |
125 startPos= aLine.find_first_not_of(" \t",endPos); |
126 while(startPos != std::string::npos) |
126 while(startPos != string::npos) |
127 { |
127 { |
128 endPos= aLine.find_first_of(" \t",startPos); |
128 endPos= aLine.find_first_of(" \t",startPos); |
129 String paramStr= aLine.substr(startPos,endPos-startPos); |
129 string paramStr= aLine.substr(startPos,endPos-startPos); |
130 |
130 |
131 unsigned int position= aLine.find_first_of("\"",startPos); |
131 unsigned int position= aLine.find_first_of("\"",startPos); |
132 |
132 |
133 // If the parameter contains double quotes('"') then also include the spaces(if provided) |
133 // If the parameter contains double quotes('"') then also include the spaces(if provided) |
134 // within the quotes. |
134 // within the quotes. |
135 if((position!=std::string::npos) && position<=endPos) |
135 if((position!=string::npos) && position<=endPos) |
136 { |
136 { |
137 endPos= aLine.find_first_of("\"",position+1); |
137 endPos= aLine.find_first_of("\"",position+1); |
138 if(endPos!= std::string::npos) |
138 if(endPos!= string::npos) |
139 { |
139 { |
140 endPos= aLine.find_first_of(" \t",endPos+1); |
140 endPos= aLine.find_first_of(" \t",endPos+1); |
141 if(endPos != std::string::npos) |
141 if(endPos != string::npos) |
142 { |
142 { |
143 paramStr= aLine.substr(startPos,endPos-startPos); |
143 paramStr= aLine.substr(startPos,endPos-startPos); |
144 } |
144 } |
145 |
145 |
146 // Remove '"' from parameter |
146 // Remove '"' from parameter |
200 unsigned int paramSize = iParameters.size(); |
200 unsigned int paramSize = iParameters.size(); |
201 iParamFileArgs=new char*[paramSize+1]; |
201 iParamFileArgs=new char*[paramSize+1]; |
202 |
202 |
203 for (unsigned int count=1; count<=paramSize; count++) |
203 for (unsigned int count=1; count<=paramSize; count++) |
204 { |
204 { |
205 String param = iParameters.at(count-1); |
205 string param = iParameters.at(count-1); |
206 *(iParamFileArgs+count) = new char[param.size()+1]; |
206 *(iParamFileArgs+count) = new char[param.size()+1]; |
207 strcpy(*(iParamFileArgs+count),param.c_str()); |
207 strcpy(*(iParamFileArgs+count),param.c_str()); |
208 } |
208 } |
209 } |
209 } |
210 |
210 |