Synopsis - Cross-Reference
File: /Synopsis/Parsers/IDL/idlfixed.h1// -*- c++ -*- 2// Package : omniidl 3// idlfixed.h Created on: 2001/01/30 4// Author : Duncan Grisby (dpg1) 5// 6// Copyright (C) 2001 AT&T Laboratories Cambridge 7// 8// This file is part of omniidl. 9// 10// omniidl is free software; you can redistribute it and/or modify it 11// under the terms of the GNU General Public License as published by 12// the Free Software Foundation; either version 2 of the License, or 13// (at your option) any later version. 14// 15// This program is distributed in the hope that it will be useful, 16// but WITHOUT ANY WARRANTY; without even the implied warranty of 17// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18// General Public License for more details. 19// 20// You should have received a copy of the GNU General Public License 21// along with this program; if not, write to the Free Software 22// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 23// 02111-1307, USA. 24// 25// Description: 26// 27// Implementation of fixed point type 28 29// $Log: idlfixed.h,v $ 30// Revision 1.1.4.1 2003/03/23 21:01:45 dgrisby 31// Start of omniORB 4.1.x development branch. 32// 33// Revision 1.1.2.2 2002/01/15 16:38:14 dpg1 34// On the road to autoconf. Dependencies refactored, configure.ac 35// written. No makefiles yet. 36// 37// Revision 1.1.2.1 2001/03/13 10:32:12 dpg1 38// Fixed point support. 39// 40 41#ifndef _idlfixed_h_ 42#define _idlfixed_h_ 43 44#include <idlsysdep.h> 45 46 47#ifndef OMNI_FIXED_DIGITS 48# define OMNI_FIXED_DIGITS 31 49#endif 50 51 52class IDL_Fixed { 53public: 54 55 // Subset of functions from CORBA::Fixed 56 57 IDL_Fixed(); 58 IDL_Fixed(const IDL_Fixed& f); 59 IDL_Fixed(const char* s, const char* file = 0, int line = 0); 60 61 IDL_Fixed(const IDL_Octet* val, IDL_UShort digits, 62 IDL_UShort scale, IDL_Boolean negative); 63 64 ~IDL_Fixed(); 65 66 IDL_Fixed truncate(IDL_UShort scale); 67 68 IDL_Fixed& operator=(const IDL_Fixed& f); 69 70 IDL_Fixed operator-() const; 71 72 IDL_UShort fixed_digits() const { return digits_; } 73 IDL_UShort fixed_scale() const { return scale_; } 74 75 char* asString() const; 76 // Return the value of the fixed as a string. Caller frees. 77 78 const IDL_Octet* val() const { return val_; } 79 IDL_Boolean negative() const { return negative_; } 80 81 class Overflow {}; 82 class DivideByZero {}; 83 // Exceptions thrown when fixed digits overflow or divide by zero 84 85private: 86 IDL_Octet val_[OMNI_FIXED_DIGITS]; 87 IDL_UShort digits_; 88 IDL_UShort scale_; 89 IDL_Boolean negative_; // true if negative; false if positive 90}; 91 92IDL_Fixed operator+(const IDL_Fixed& a, const IDL_Fixed& b); 93IDL_Fixed operator-(const IDL_Fixed& a, const IDL_Fixed& b); 94IDL_Fixed operator*(const IDL_Fixed& a, const IDL_Fixed& b); 95IDL_Fixed operator/(const IDL_Fixed& a, const IDL_Fixed& b); 96 97 98#endif // _idlfixed_h_