oaString.h

Go to the documentation of this file.
00001 // *****************************************************************************
00002 // oaString.h
00003 //
00004 // This file contains the definition for the oaString class. This utility class
00005 // provides type safty and operators for character arrays.
00006 //
00007 // *****************************************************************************
00008 // Except as specified in the OpenAccess terms of use of Cadence or Silicon
00009 // Integration Initiative, this material may not be copied, modified,
00010 // re-published, uploaded, executed, or distributed in any way, in any medium,
00011 // in whole or in part, without prior written permission from Cadence.
00012 //
00013 //                Copyright 2002-2005 Cadence Design Systems, Inc.
00014 //                           All Rights Reserved.
00015 //
00016 //  $Author: icftcm $
00017 //  $Revision: #1 $
00018 //  $Date: 2010/08/09 $
00019 //  $State: Exp $
00020 // *****************************************************************************
00021 // *****************************************************************************
00022 
00023 
00024 
00025 #if !defined(oaString_P)
00026 #define oaString_P
00027 
00028 
00029 
00030 // *****************************************************************************
00031 // Nested includes
00032 // *****************************************************************************
00033 #include "oaBaseTypes.h"
00034 #include <stdarg.h>
00035 
00036 
00037 
00038 // *****************************************************************************
00039 // Declare and define types in the OpenAccess namespace.
00040 // *****************************************************************************
00041 
00042 BEGIN_OA_NAMESPACE
00043 
00044 
00045 
00046 // *****************************************************************************
00047 // Forward Public Class Declarations
00048 // *****************************************************************************
00049 class oaString;
00050 
00051 
00052 
00053 // *****************************************************************************
00054 // Function Declarations
00055 // *****************************************************************************
00056 OA_BASE_DLL_API oaString operator+(const oaString   &s1,
00057                                    const oaString   &s2);
00058 OA_BASE_DLL_API oaBoolean operator<(const oaString  &s1,
00059                                     const oaChar    *s2);
00060 OA_BASE_DLL_API oaBoolean operator<(const oaChar    *s1,
00061                                     const oaString  &s2);
00062 OA_BASE_DLL_API oaBoolean operator>(const oaString  &s1,
00063                                     const oaChar    *s2);
00064 OA_BASE_DLL_API oaBoolean operator>(const oaChar    *s1,
00065                                     const oaString  &s2);
00066 OA_BASE_DLL_API oaBoolean operator==(const oaString &s1,
00067                                      const oaChar   *s2);
00068 OA_BASE_DLL_API oaBoolean operator==(const oaChar   *s1,
00069                                      const oaString &s2);
00070 OA_BASE_DLL_API oaBoolean operator<=(const oaString &s1,
00071                                      const oaChar   *s2);
00072 OA_BASE_DLL_API oaBoolean operator<=(const oaChar   *s1,
00073                                      const oaString &s2);
00074 OA_BASE_DLL_API oaBoolean operator>=(const oaString &s1,
00075                                      const oaChar   *s2);
00076 OA_BASE_DLL_API oaBoolean operator>=(const oaChar   *s1,
00077                                      const oaString &s2);
00078 OA_BASE_DLL_API oaBoolean operator!=(const oaString &s1,
00079                                      const oaChar   *s2);
00080 OA_BASE_DLL_API oaBoolean operator!=(const oaChar   *s1,
00081                                      const oaString &s2);
00082 
00083 
00084 
00085 // *****************************************************************************
00086 // oaString
00087 // *****************************************************************************
00088 class OA_BASE_DLL_API oaString {
00089 public:
00090                                         oaString();
00091     explicit                            oaString(oaUInt4 length);
00092                                         oaString(const oaChar *initialValue);
00093                                         oaString(const oaChar   *initialValue,
00094                                                  oaUInt4        length);
00095                                         oaString(const oaString &s);
00096                                         ~oaString();
00097 
00098     oaString                            &operator=(oaChar c);
00099     oaString                            &operator=(const oaChar *str);
00100     oaString                            &operator=(const oaString &str);
00101     oaString                            &operator+=(oaChar c);
00102     oaString                            &operator+=(const oaChar *str);
00103     oaString                            &operator+=(const oaString &str);
00104     oaBoolean                           operator<(const oaString &str) const;
00105     oaBoolean                           operator>(const oaString &str) const;
00106     oaBoolean                           operator==(const oaString &str) const;
00107     oaBoolean                           operator<=(const oaString &str) const;
00108     oaBoolean                           operator>=(const oaString &str) const;
00109     oaBoolean                           operator!=(const oaString &str) const;
00110 
00111                                         operator const      oaChar*() const;
00112 
00113     oaUInt4                             getLength() const;
00114     oaBoolean                           isEmpty() const;
00115 
00116     oaDouble                            toDouble() const;
00117     int                                 toInt() const;
00118 
00119     void                                toUpper();
00120     void                                toLower();
00121 
00122     void                                resize(oaUInt4 size);
00123     oaUInt4                             getSize() const;
00124 
00125     char                                &operator[](oaUInt4 i);
00126     const oaChar                        &operator[](oaUInt4 i) const;
00127 
00128     oaUInt4                             index(oaChar    c,
00129                                               oaUInt4   offset = 0) const;
00130     oaUInt4                             substr(const oaString   &sub,
00131                                                oaUInt4          offset = 0) const;
00132 
00133     oaBoolean                           isEqual(const oaString  &str,
00134                                                 oaBoolean       ignoreCase) const;
00135 
00136     void                                format(oaUInt4      size,
00137                                                const oaChar *formatStr,
00138                                                ...);
00139     void                                format(const oaChar *formatStr,
00140                                                ...);
00141     void                                format(const oaChar *formatStr,
00142                                                va_list      args);
00143 
00144 private:
00145     oaUInt4                             size;
00146     oaChar                              *data;
00147 
00148     friend OA_BASE_DLL_API oaString     operator+(const oaString    &s1,
00149                                                   const oaString    &s2);
00150     friend OA_BASE_DLL_API oaBoolean    operator<(const oaString    &s1,
00151                                                   const oaChar      *s2);
00152     friend OA_BASE_DLL_API oaBoolean    operator<(const oaChar      *s1,
00153                                                   const oaString    &s2);
00154     friend OA_BASE_DLL_API oaBoolean    operator>(const oaString    &s1,
00155                                                   const oaChar      *s2);
00156     friend OA_BASE_DLL_API oaBoolean    operator>(const oaChar      *s1,
00157                                                   const oaString    &s2);
00158     friend OA_BASE_DLL_API oaBoolean    operator==(const oaString   &s1,
00159                                                    const oaChar     *s2);
00160     friend OA_BASE_DLL_API oaBoolean    operator==(const oaChar     *s1,
00161                                                    const oaString   &s2);
00162     friend OA_BASE_DLL_API oaBoolean    operator<=(const oaString   &s1,
00163                                                    const oaChar     *s2);
00164     friend OA_BASE_DLL_API oaBoolean    operator<=(const oaChar     *s1,
00165                                                    const oaString   &s2);
00166     friend OA_BASE_DLL_API oaBoolean    operator>=(const oaString   &s1,
00167                                                    const oaChar     *s2);
00168     friend OA_BASE_DLL_API oaBoolean    operator>=(const oaChar     *s1,
00169                                                    const oaString   &s2);
00170     friend OA_BASE_DLL_API oaBoolean    operator!=(const oaString   &s1,
00171                                                    const oaChar     *s2);
00172     friend OA_BASE_DLL_API oaBoolean    operator!=(const oaChar     *s1,
00173                                                    const oaString   &s2);
00174 };
00175 
00176 
00177 
00178 END_OA_NAMESPACE
00179 
00180 #endif

Return to top of page