Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

more/gen/string.h

Go to the documentation of this file.
00001 //  more/gen/string.h -- Additional string functions
00002 //  Copyright (C) 2001--2002  Petter Urkedal
00003 //
00004 //  This file is free software; you can redistribute it and/or modify
00005 //  it under the terms of the GNU General Public License as published by
00006 //  the Free Software Foundation; either version 2 of the License, or
00007 //  (at your option) any later version.
00008 //
00009 //  This file is distributed in the hope that it will be useful,
00010 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 //  GNU General Public License for more details.
00013 //
00014 //  You should have received a copy of the GNU General Public License
00015 //  along with this program; if not, write to the Free Software
00016 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00017 //
00018 //  As a special exception, you may use this file as part of a free
00019 //  software library without restriction.  Specifically, if other files
00020 //  instantiate templates or use macros or inline functions from this
00021 //  file, or you compile this file and link it with other files to
00022 //  produce an executable, this file does not by itself cause the
00023 //  resulting executable to be covered by the GNU General Public
00024 //  License.  This exception does not however invalidate any other
00025 //  reasons why the executable file might be covered by the GNU General
00026 //  Public License.
00027 //
00028 //  $Id: string.h,v 1.2 2002/08/24 13:56:26 petter_urkedal Exp $
00029 
00030 #ifndef MORE_GEN_STRING_H
00031 #define MORE_GEN_STRING_H
00032 
00033 #include <more/bits/config.h>
00034 #include <cstring>
00035 
00036 namespace more {
00037 namespace gen {
00038 
00039   /** Returns a unique pointer for all lexically equal strings.  The
00040       string argument must have static lifetime. */
00041   char const* struniq_static(char const*);
00042 
00043   /** Returns a unique pointer for all lexically equal strings. */
00044   char const* struniq_copy(char const*);
00045 
00046   /** Returns a unique pointer for all lexically equal strings.  The
00047       string argument must have static lifetime. */
00048   wchar_t const* struniq_static(wchar_t const*);
00049 
00050   /** Returns a unique pointer for all lexically equal strings. */
00051   wchar_t const* struniq_copy(wchar_t const*);
00052 
00053   /** Returns a unique string pointer for each argument.  The string
00054       is a valid C identifier.  The global time and space complexty
00055       scales lineary with the maximum absolute value of the argument,
00056       in addition to amortized constant time and zero space for each
00057       call.  */
00058   char const* struniq_dense(int);
00059 
00060   /** Returns a unique string pointer for each argument.  The string
00061       is a valid C identifier.  The time complexity is logarithmic in
00062       the number of distinct uniqstr_* pointers returned. */
00063   char const* struniq_sparse(int);
00064 
00065   /** Returns a copy of str allocated by new. */
00066   inline char*
00067   strcpy_new(char const* str)
00068   {
00069       char* s = new char[strlen(str) + 1];
00070       std::strcpy(s, str);
00071       return s;
00072   }
00073 
00074 #ifdef HAVE_BDWGC
00075   /** A version of wcstombs which stores its result in garbage
00076    ** collected memory. */
00077   char* wcstombs_gc(wchar_t const* ws);
00078 
00079   /** A version of mbstowcs which stores its result in collected
00080    ** memory. */
00081   wchar_t* mbstowcs_gc(char const* str);
00082 #endif
00083 
00084 }}
00085 
00086 #endif

Generated on Sat Sep 7 19:11:14 2002 for more with Doxygen 1.2.13.1. Doxygen 1.2.13.1 is written and copyright 1997-2002 by Dimitri van Heesch.