예제 #1
0
ModelFileT::StatusT ModelFileT::GetTitle(StringT& title) const
{
    if (fMode != kRead)
        return kFail;
    else
    {
        ifstreamT in(sComment, fFileName);
        if (AdvanceStream(in, keyword[ktitle]) == kOK)
        {
            /* advance */
            in.next_char();
            title.GetLineFromStream(in);

            return in.good() ? kOK : kFail;
        }
        else
            return kFail;
    }
}
예제 #2
0
/* read value from stream */
bool ArgSpecT::ReadValue(istream& in)
{
	switch (fType)
	{
		case int_:
		{
			int a = -991991;
			in >> a;
			if (a != -991991) {
				SetValue(a);
				return true;
			}
		}
		case double_:
		{
			double a = -991.991;
			in >> a;
			if (a != -991.991) {
				SetValue(a);
				return true;
			}
		}
		case string_:
		{
			StringT a;
			a.GetLineFromStream(in);
			if (a.StringLength() > 0) {
				SetValue(a);
				return true;
			}
		}
		case bool_:
		{
			/* get next non-white space character */
			char a;	
			in.get(a);
			while (in.good() && isspace(a)) 
				in.get(a);	

			/* resolve */
			switch (a)
			{
				case '1':
				case 't':
				case 'T':
					SetValue(true);
					return true;
				case '0':
				case 'f':
				case 'F':
					SetValue(false);
					return true;
				default:
					return false;
			}
		}
		case float_:
		{
			float a = -91.91;
			in >> a;
			if (a != -91.91) {
				SetValue(a);
				return true;
			}
		}
		default:
			cout << "\n ArgSpecT::operator=: unknown value type" << endl;
			throw ExceptionT::kGeneralFail;
	}

	/* dummy */
	return false;
}