1 | /* |
2 | * Copyright 2015 Aerospike, Inc. |
3 | * |
4 | * Portions may be licensed to Aerospike, Inc. under one or more |
5 | * contributor license agreements. |
6 | * |
7 | * Licensed under the Apache License, Version 2.0 (the "License"); you |
8 | * may not use this file except in compliance with the License. You |
9 | * may obtain a copy of the License at |
10 | * http://www.apache.org/licenses/LICENSE-2.0 |
11 | * |
12 | * Unless required by applicable law or agreed to in writing, software |
13 | * distributed under the License is distributed on an "AS IS" BASIS, |
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or |
15 | * implied. See the License for the specific language governing |
16 | * permissions and limitations under the License. |
17 | */ |
18 | |
19 | #ifndef __throwstream_h |
20 | #define __throwstream_h 1 |
21 | |
22 | #include <iostream> |
23 | #include <sstream> |
24 | |
25 | // The throwstream macro assembles the string argument to the |
26 | // exception constructor from an iostream. |
27 | // |
28 | #define throwstream(__except, __msg) \ |
29 | do { \ |
30 | std::ostringstream __ostrm; \ |
31 | __ostrm << __msg; \ |
32 | throw __except(__ostrm.str().c_str()); \ |
33 | } while (false) |
34 | |
35 | #endif // __throwstream_h |
36 | |