dmake: do not set MAKEFLAGS=k
[unleashed/tickless.git] / usr / src / cmd / audio / include / AudioError.h
blobde4e67f9868db18e927608ec373f9c202898e450
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
7 * with the License.
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
20 * CDDL HEADER END
23 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #ifndef _MULTIMEDIA_AUDIOERROR_H
28 #define _MULTIMEDIA_AUDIOERROR_H
30 #pragma ident "%Z%%M% %I% %E% SMI"
32 #include <locale.h>
33 #include <errno.h>
34 #include <audio_errno.h> /* to get enum for error codes */
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
40 #if !defined(TEXT_DOMAIN) /* Should be defined by cc -D */
41 #define TEXT_DOMAIN "SYS_TEST" /* Use this only if it weren't */
42 #endif
44 #define _MGET_(str) (char *)dgettext(TEXT_DOMAIN, str)
45 #define _GETTEXT_(str) (char *)gettext(str)
47 // The AudioError class allows various interesting automatic conversions
48 class AudioError {
49 private:
50 audioerror_t code; // error code
52 public:
53 int sys; // system error code
55 inline AudioError(audioerror_t val = AUDIO_SUCCESS): // Constructor
56 code(val), sys(0)
57 { if (code == AUDIO_UNIXERROR) sys = errno; }
58 inline AudioError(int val): // Constructor from int
59 code((audioerror_t)val), sys(0)
60 { if (code == AUDIO_UNIXERROR) sys = errno; }
62 inline AudioError operator = (AudioError val) // Assignment
63 { code = val.code; sys = val.sys; return (*this); }
64 inline operator int() // Cast to integer
65 { return (code); }
66 inline int operator == (audioerror_t e) // Compare
67 { return (code == e); }
68 inline int operator != (audioerror_t e) // Compare
69 { return (code != e); }
70 inline int operator == (AudioError e) // Compare
71 { return ((code == e.code) && (sys == e.sys)); }
72 inline int operator != (AudioError e) // Compare
73 { return ((code != e.code) || (sys != e.sys)); }
75 char *msg(); // Return error string
78 #ifdef __cplusplus
80 #endif
82 #endif /* !_MULTIMEDIA_AUDIOERROR_H */