system_string.cpp

Go to the documentation of this file.
00001 #ifndef SYSTEM_STRING_IMPLEMENTATION_FILE
00002 #define SYSTEM_STRING_IMPLEMENTATION_FILE
00003 
00004 /*****************************************************************************\
00005 *                                                                             *
00006 *  Name   : system_string                                                     *
00007 *  Author : Chris Koeritz                                                     *
00008 *                                                                             *
00009 *******************************************************************************
00010 * Copyright (c) 1991-$now By Author.  This program is free software; you can  *
00011 * redistribute it and/or modify it under the terms of the GNU General Public  *
00012 * License as published by the Free Software Foundation; either version 2 of   *
00013 * the License or (at your option) any later version.  This is online at:      *
00014 *     http://www.fsf.org/copyleft/gpl.html                                    *
00015 * Please send any updates to: fred@gruntose.com                               *
00016 \*****************************************************************************/
00017 
00018 // Some original system string code was by Douglas Young.
00019 
00020 #include "system_string.h"
00021 #include "wp_implementation.h"
00022 
00023 system_string::system_string(const char *str)
00024 { contents = XmStringCreate((char *)str, XmSTRING_DEFAULT_CHARSET); }
00025 
00026 system_string::system_string(const istring &str)
00027 { contents = XmStringCreate((char *)str.s(), XmSTRING_DEFAULT_CHARSET); }
00028 
00029 system_string::system_string(int n, const char *lines[], concatenation_method how)
00030 {
00031   contents = XmStringCreate((char *)"", XmSTRING_DEFAULT_CHARSET);
00032   if (n <= 0) return;
00033   else {
00034     for (int i = 0; i < n; i++) {
00035       // skip out if there is no entry left...
00036       if (!lines[i]) break;
00037       // perform the extra insertion for space or index style separation...
00038       if ( (how == SPACE_SEPARATE) && (i > 0) )
00039         contents = XmStringConcat
00040           (contents, XmStringCreate((char *)" ", XmSTRING_DEFAULT_CHARSET));
00041       else if ( (how == INDEX_SEPARATE) && (i > 0) ) 
00042 // bogus code:
00043         contents = XmStringConcat
00044           (contents, XmStringCreate((char *)" ", XmSTRING_DEFAULT_CHARSET));
00045 // real code to be used below:
00046 //        contents = XmStringConcat(contents, XmStringSeparatorCreate());
00047       // concatenate an item created according to the how...
00048       if (how == EOL_SEPARATE) contents = XmStringConcat
00049         (contents, XmStringLtoRCreate((char *)lines[i], XmSTRING_DEFAULT_CHARSET));
00050       else contents = XmStringConcat
00051         (contents, XmStringCreate((char *)lines[i], XmSTRING_DEFAULT_CHARSET));
00052     }
00053   }
00054 }
00055 
00056 system_string::~system_string() { XmStringFree(contents); }
00057 
00058 system_string::operator window_string () const { return contents; }
00059 
00060 int compound_length(const char *str[])
00061 { int i; for (i = 0; *str[i]; i++) {}; return i; }
00062 
00063 
00064 #endif //SYSTEM_STRING_IMPLEMENTATION_FILE
00065 

Generated on Fri Nov 28 04:29:05 2008 for HOOPLE Libraries by  doxygen 1.5.1