Exemple #1
0
/*
 * Function name: create_object
 * Description  : Constructor. It is called to create this object.
 */
nomask public void
create_object()
{
    set_name("editor");
    set_pname("editors");
    add_name("edit");
    add_name("date_edit");
    set_adj("data");

    set_short("data editor");
    set_pshort("data editors");

    set_long(break_string("With this data editor it is possible to list " +
	"and manipulate LPC-datafiles. One command, data_edit, is linked to " +
	"this editor. There is a general help-page on the command. Also, " +
	"within the editor, you can get help by typing ? or h[elp]. The " +
	"syntax for data_edit is 'data_edit <filename>'.", 75) + "\n");

    remove_prop(OBJ_I_VALUE);
    remove_prop(OBJ_I_VOLUME);
    remove_prop(OBJ_I_WEIGHT);

    add_prop(OBJ_I_NO_STEAL,    1);
    add_prop(OBJ_I_NO_TELEPORT, 1);
    add_prop(OBJ_S_WIZINFO,
	"Just examine the data editor for information. /Mercade\n");
}
bool ConfigElem::remove_prop( const char *propname, unsigned short *psval )
{
    string temp;
    if (remove_prop( propname, &temp ))
    {
#if CFGFILE_USES_TRANSLATION_TABLE
        TranslationTable* tbl = translations.get_trans_table( propname );
        if (tbl != NULL)
            tbl->translate( &temp );
#endif

        // FIXME isdigit isxdigit - +
        // or, use endptr

        char *endptr = NULL;
        *psval = (unsigned short) strtoul( temp.c_str(), &endptr, 0 );
        if ((endptr != NULL) &&
                (*endptr != '\0') &&
                !isspace(*endptr))
        {
            string errmsg;
            errmsg = "Poorly formed number in property '";
            errmsg += propname;
            errmsg += "': " + temp;
            throw_error( errmsg );
        }
        // FIXME check range within unsigned short
        return true;
    }
    return false;
}
unsigned long ConfigElem::remove_ulong( const char *propname, unsigned long dflt )
{
    unsigned long temp;
    if (remove_prop( propname, &temp))
        return temp;
    else
        return dflt;
}
string ConfigElem::remove_string( const char *propname, const char *dflt )
{
    string temp;
    if (remove_prop( propname, &temp ))
        return temp;
    else
        return dflt;
}
unsigned short ConfigElem::remove_ushort( const char *propname, unsigned short dflt )
{
    unsigned short temp;
    if (remove_prop( propname, &temp))
        return temp;
    else
        return dflt;
}
double ConfigElem::remove_double( const char *propname, double dflt )
{
    string tmp;
    if (remove_prop( propname, &tmp ))
    {
        return strtod( tmp.c_str(), NULL );
    }
    else
    {
        return dflt;
    }
}
float ConfigElem::remove_float( const char *propname, float dflt )
{
    string tmp;
    if (remove_prop( propname, &tmp ))
    {
        return static_cast<float>(strtod( tmp.c_str(), NULL ));
    }
    else
    {
        return dflt;
    }
}
unsigned ConfigElem::remove_unsigned( const char *propname, int dflt )
{
    string temp;
    if (remove_prop( propname, &temp ))
    {
        return strtoul( temp.c_str(), NULL, 0  ); // TODO check unsigned range
    }
    else
    {
        return dflt;
    }
}
int ConfigElem::remove_int( const char *propname, int dflt )
{
    string temp;
    if (remove_prop( propname, &temp ))
    {
        return atoi( temp.c_str() );
    }
    else
    {
        return dflt;
    }
}
Exemple #10
0
unsigned long ConfigElem::remove_ulong( const char *propname )
{
    unsigned long temp;
    if (remove_prop( propname, &temp))
    {
        return temp;
    }
    else
    {
        prop_not_found( propname );
        return 0; // this is not reached, prop_not_found throws
    }
}
Exemple #11
0
void ConfigElem::clear_prop( const char *propname )
{
    unsigned long dummy;
    while (remove_prop( propname, &dummy ))
        continue;
}