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.

Peter
  • 328
  • 4
  • 18
  • 2
    Is there some reason you wouldn't use exceptions? – Crowman Oct 11 '13 at 21:49
  • Yes. I want errors to be fed through my console. – Peter Oct 11 '13 at 21:53
  • 4
    So catch the exception and output a message to your console. – Crowman Oct 11 '13 at 21:53
  • Have you tried overloading `<<` operator? Check out this link about overloading http://stackoverflow.com/questions/4421706/operator-overloading. Also, check this out: http://en.cppreference.com/w/cpp/language/operators – ipinak Oct 11 '13 at 22:48

0 Answers0