#include
using namespace std;
//Chops last character from string (perl:))
void chop(char *s)
{
int i;
i = strlen(s);
if(i) {
s[i-1] = 0;
}
}
//Removes white spaces around word in string
string remove_spaces(string s)
{
int i;
int a = -1, b = s.length();
if(b<1) { return s; }
for(i=0;i!=b-1;i++) {
if((s[i]!=' ') && (s[i]!='\t')) {
a = i;
break;
}
}
if(a==-1) { a = 0; }
for(i=b-1;i!=0;i--) {
if((s[i]!=' ') && (s[i]!='\t')) {
b = i+1;
break;
}
}
s = s.substr(a,b);
return s;
}
//Check syntax and remove comentars beginning with #
//till end of line
int check_syntax(string &s)
{
int i;
i = s.find('#');
if(i != -1) {
s = s.substr(0, i);
}
if(((int)s.find('=')) == -1) {
return 0;
}
return 1;
}
//returns value on n-th position in string
int string_value(string s, int n)
{
int i;
if(n<1) return -1;
for(i=0; i!=n-1; i++) {
s = s.substr(s.find(",")+1, s.length()-1);
}
if(s.find(",")>0) {
s = s.substr(0, s.find(","));
}
// cout<<"["<
Generated by: georgik on armada on Sat Jul 24 07:07:15 2004, using kdoc 2.0a54. |