Skip to content

Commit 0e6439b

Browse files
authored
scoopxyz/revert (#492)
* revert API changes for 1.1.0 release * add pragma ignore warnings for DLL * fix typos and add function descriptors (courtesy of @hodoulp)
1 parent 927e81d commit 0e6439b

File tree

2 files changed

+45
-58
lines changed

2 files changed

+45
-58
lines changed

export/OpenColorIO/OpenColorIO.h

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3030
#ifndef INCLUDED_OCIO_OPENCOLORIO_H
3131
#define INCLUDED_OCIO_OPENCOLORIO_H
3232

33-
#include <stdexcept>
33+
#include <exception>
3434
#include <iosfwd>
35+
#include <string>
3536
#include <cstddef>
3637

3738
#include "OpenColorABI.h"
@@ -84,15 +85,32 @@ OCIO_NAMESPACE_ENTER
8485
//
8586
// .. warning::
8687
// All functions in the Config class can potentially throw this exception.
87-
class OCIOEXPORT Exception : public std::runtime_error
88+
class OCIOEXPORT Exception : public std::exception
8889
{
8990
public:
9091
//!cpp:function:: Constructor that takes a string as the exception message.
9192
Exception(const char *) throw();
92-
//!cpp:function:: Constructor that takes an existing exception.
93+
//!cpp:function:: Constructor that takes an exception pointer.
9394
Exception(const Exception&) throw();
94-
//!cpp:function:: Destructor
95+
//!cpp:function:: Constructor that takes an exception pointer and returns an exception pointer (???).
96+
Exception& operator=(const Exception&) throw();
97+
//!cpp:function::
9598
virtual ~Exception() throw();
99+
//!cpp:function::
100+
virtual const char* what() const throw();
101+
102+
private:
103+
//Add pragma warnings, STL member is private and not consumed by client of DLL
104+
#ifdef _WIN32
105+
#pragma warning(push)
106+
#pragma warning(disable:4251)
107+
#endif // _WIN32
108+
109+
std::string msg_;
110+
111+
#ifdef _WIN32
112+
#pragma warning(pop)
113+
#endif // _WIN32
96114
};
97115

98116
//!cpp:class:: An exception class for errors detected at
@@ -191,6 +209,7 @@ OCIO_NAMESPACE_ENTER
191209
// See :ref:`developers-usageexamples`
192210

193211
//!cpp:function:: Get the current configuration.
212+
194213
extern OCIOEXPORT ConstConfigRcPtr GetCurrentConfig();
195214

196215
//!cpp:function:: Set the current configuration. This will then store a copy of the specified config.
@@ -210,9 +229,9 @@ OCIO_NAMESPACE_ENTER
210229

211230
//!cpp:function:: Constructor a default empty configuration.
212231
static ConfigRcPtr Create();
213-
//!cpp:function:: Constructor a configuration using the SYNCOLOR environment variable.
232+
//!cpp:function:: Constructor a configuration using the OCIO environmnet variable.
214233
static ConstConfigRcPtr CreateFromEnv();
215-
//!cpp:function:: Constructor a configuration using specific config file.
234+
//!cpp:function:: Constructor a configuration using a specific config file.
216235
static ConstConfigRcPtr CreateFromFile(const char * filename);
217236
//!cpp:function::
218237
static ConstConfigRcPtr CreateFromStream(std::istream & istream);
@@ -1151,7 +1170,7 @@ OCIO_NAMESPACE_ENTER
11511170
//!cpp:function::
11521171
GpuLanguage getLanguage() const;
11531172

1154-
//!cpp:function:: Set the function name of the shader program
1173+
//!cpp:function:: Set the function name of the shader program
11551174
void setFunctionName(const char * name);
11561175
//!cpp:function::
11571176
const char * getFunctionName() const;

src/core/Exception.cpp

Lines changed: 19 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,36 @@ OCIO_NAMESPACE_ENTER
3232
{
3333

3434
Exception::Exception(const char * msg) throw()
35-
: std::runtime_error(msg)
35+
: std::exception(),
36+
msg_(msg)
3637
{}
3738

3839
Exception::Exception(const Exception& e) throw()
39-
: std::runtime_error(e)
40+
: std::exception(),
41+
msg_(e.msg_)
4042
{}
4143

44+
//*** operator=
45+
Exception& Exception::operator=(const Exception& e) throw()
46+
{
47+
msg_ = e.msg_;
48+
return *this;
49+
}
50+
4251
//*** ~Exception
4352
Exception::~Exception() throw()
4453
{
4554
}
4655

56+
//*** what
57+
const char* Exception::what() const throw()
58+
{
59+
return msg_.c_str();
60+
}
4761

62+
63+
64+
4865
ExceptionMissingFile::ExceptionMissingFile(const char * msg) throw()
4966
: Exception(msg)
5067
{}
@@ -55,52 +72,3 @@ OCIO_NAMESPACE_ENTER
5572

5673
}
5774
OCIO_NAMESPACE_EXIT
58-
59-
60-
///////////////////////////////////////////////////////////////////////////////
61-
62-
#ifdef OCIO_UNIT_TEST
63-
64-
namespace OCIO = OCIO_NAMESPACE;
65-
#include "UnitTest.h"
66-
67-
#include <string.h>
68-
69-
70-
OIIO_ADD_TEST(Exception, Basic)
71-
{
72-
static const char* dummyErrorStr = "Dummy error";
73-
74-
// Test 1
75-
76-
try
77-
{
78-
throw OCIO::Exception(dummyErrorStr);
79-
}
80-
catch(const std::exception& ex)
81-
{
82-
OIIO_CHECK_EQUAL(strcmp(ex.what(), dummyErrorStr), 0);
83-
}
84-
catch(...)
85-
{
86-
OIIO_CHECK_ASSERT(!"Wrong exception type");
87-
}
88-
89-
// Test 2
90-
91-
try
92-
{
93-
OCIO::Exception ex(dummyErrorStr);
94-
throw OCIO::Exception(ex);
95-
}
96-
catch(const std::exception& ex)
97-
{
98-
OIIO_CHECK_EQUAL(strcmp(ex.what(), dummyErrorStr), 0);
99-
}
100-
catch(...)
101-
{
102-
OIIO_CHECK_ASSERT(!"Wrong exception type");
103-
}
104-
}
105-
106-
#endif // OCIO_UNIT_TEST

0 commit comments

Comments
 (0)