0

I'm having a little bit of a design problem with my scripting language that I'm creating for my C++ game engine. What I'm trying to do is have an object named SScript call a method to load necessary files, and check the script file's suffix. I also have a base class called SMessage than another class named SErrorMessage derives from. Here's some example code to do illustrate exactly what I want to do:

SScript::SScript(const std::string& filepath)
{
    if (load(filepath) == SError(SError::Error_Codes::ERROR_CUSTOM))
    {

    }
}

SMessage& SScript::load(const std::string& filepath)
{

}

Here's the header file for SError:

class SError : public SMessage
{
public:
    enum class Error_Codes
    {
        ERROR_CUSTOM = 1,
        ERROR_LOADING_SCRIPT = 2,
        ERROR_SCRIPT_INCORRECT_SUFFIX = 3,
    };

    SError(Error_Codes errorCode);
    SError(Error_Codes errorCode, const std::string& contents);

    virtual void message(const std::string& contents);

    inline bool operator=(const Error_Codes errorCode)
    {

    }

private:
    SError() {};

    Error_Codes m_error_code;

    void organizeString(const std::string& contents);
};

In SScript::SScript() I want to call load and compare it to various SMessages or SErrorMessages. I tried implementing an operator overload, but I don't think that will solve the problem. I've sort of hit a brick wall, and I need a serious design rethinking. Any help is welcomed and thank you very much!

Peter
  • 328
  • 4
  • 18
  • 2
    You're likely going to get considerably more interaction with this question if you make the title remotely relevant to the *content of the problem* rather than your current state of mind. – WhozCraig Oct 06 '13 at 21:21
  • Are you asking about error handling? I would highly recommend you utilize exceptions rather than constructs like "if (load(filepath) == SError(SError::Error_Codes::ERROR_CUSTOM))" – namezero Oct 06 '13 at 21:30

0 Answers0