Ignore:
Timestamp:
Jan 7, 2007, 5:27:39 PM (19 years ago)
Author:
cinc
Message:

A load of additions and fixes to the string and path classes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/foundation/class_c/nomstring.c

    r146 r180  
    4545
    4646
    47 NOM_Scope PNOMString NOMLINK impl_NOMString_assignString(NOMString* nomSelf, const PNOMString nomString, CORBA_Environment *ev)
     47NOM_Scope PNOMString NOMLINK impl_NOMString_assign(NOMString* nomSelf, const PNOMString nomString,
     48                                                         CORBA_Environment *ev)
    4849{
    49 /* NOMStringData* nomThis=NOMStringGetData(nomSelf); */
     50  /* NOMStringData* nomThis=NOMStringGetData(nomSelf); */
    5051
    51   NOMString_assignCString(nomSelf, NOMString_getCString(nomString, NULLHANDLE), NULLHANDLE);
     52  NOMString_assignCString(nomSelf, NOMString_queryCString(nomString, NULLHANDLE), NULLHANDLE);
    5253  return nomSelf;
    5354}
    5455
    55 /* Assign a C string to this NOMString */
    56 NOM_Scope PNOMString NOMLINK impl_NOMString_assignCString(NOMString* nomSelf, const CORBA_char * chrString, CORBA_Environment *ev)
     56/* Assign a C string to this NOMString. An initially created NOMString object is empty. */
     57NOM_Scope PNOMString NOMLINK impl_NOMString_assignCString(NOMString* nomSelf, const CORBA_char * chrString,
     58                                                          CORBA_Environment *ev)
    5759{
    5860  NOMStringData* nomThis=NOMStringGetData(nomSelf);
    5961
    60   g_string_assign(_gString, chrString);
     62  g_string_assign(_gString, chrString); /* This copies the input string */
    6163  return nomSelf;
    6264}
    6365
    64 /* Returns the C string held by this NOMString */
    65 NOM_Scope CORBA_string NOMLINK impl_NOMString_getCString(NOMString* nomSelf, CORBA_Environment *ev)
     66/* Returns the C string held by this NOMString. */
     67NOM_Scope CORBA_string NOMLINK impl_NOMString_queryCString(NOMString* nomSelf, CORBA_Environment *ev)
    6668{
    6769  NOMStringData* nomThis=NOMStringGetData(nomSelf);
     
    7072}
    7173
     74/* Returns a copy of the C string held by this NOMString. */
     75NOM_Scope CORBA_string NOMLINK impl_NOMString_copyCString(NOMString* nomSelf, CORBA_Environment *ev)
     76{
     77  NOMStringData* nomThis=NOMStringGetData(nomSelf);
    7278
    73 NOM_Scope PNOMString NOMLINK impl_NOMString_appendString(NOMString* nomSelf, const PNOMString nomString, CORBA_Environment *ev)
     79  return g_strdup(_gString->str);
     80}
     81
     82NOM_Scope PNOMString NOMLINK impl_NOMString_appendCString(NOMString* nomSelf, const CORBA_char * chrString,
     83                                                          CORBA_Environment *ev)
     84{
     85  NOMStringData* nomThis=NOMStringGetData(nomSelf);
     86  PNOMString nomRetval=(PNOMString) NOMString_new(nomSelf, NULLHANDLE);
     87  GString* gStrTmp;
     88
     89  gStrTmp=g_string_new(_gString->str);
     90  g_string_append(gStrTmp, chrString);
     91  NOMString_assignCString(nomRetval, gStrTmp->str, NULLHANDLE);
     92  g_string_free(gStrTmp, TRUE);
     93
     94  return nomRetval;
     95}
     96
     97NOM_Scope PNOMString NOMLINK impl_NOMString_append(NOMString* nomSelf, const PNOMString nomString,
     98                                                         CORBA_Environment *ev)
    7499{
    75100  /*  NOMStringData* nomThis=NOMStringGetData(nomSelf); */
    76101
    77   NOMString_appendCString(nomSelf, NOMString_getCString(nomString, NULLHANDLE), NULLHANDLE);
    78   return nomSelf;
     102  return NOMString_appendCString(nomSelf, NOMString_queryCString(nomString, NULLHANDLE), NULLHANDLE);
    79103}
    80104
    81 NOM_Scope PNOMString NOMLINK impl_NOMString_prependString(NOMString* nomSelf, const PNOMString nomString, CORBA_Environment *ev)
     105NOM_Scope PNOMString NOMLINK impl_NOMString_prepend(NOMString* nomSelf, const PNOMString nomString,
     106                                                          CORBA_Environment *ev)
    82107{
    83108/* NOMStringData* nomThis=NOMStringGetData(nomSelf); */
    84109
    85   NOMString_prependCString(nomSelf, NOMString_getCString(nomString, NULLHANDLE), NULLHANDLE);
    86   return nomSelf;
    87 }
    88 
    89 NOM_Scope PNOMString NOMLINK impl_NOMString_appendCString(NOMString* nomSelf, const CORBA_char * chrString, CORBA_Environment *ev)
    90 {
    91   NOMStringData* nomThis=NOMStringGetData(nomSelf);
    92 
    93   g_string_append(_gString, chrString);
    94   return nomSelf;
     110  return NOMString_prependCString(nomSelf, NOMString_queryCString(nomString, NULLHANDLE), NULLHANDLE);
    95111}
    96112
     
    98114{
    99115  NOMStringData* nomThis=NOMStringGetData(nomSelf);
     116  PNOMString nomRetval=(PNOMString)NOMString_new(nomSelf, NULLHANDLE);
     117  GString* gStrTmp;
    100118
    101   g_string_prepend(_gString, chrString);
     119  gStrTmp=g_string_new(_gString->str);
     120  g_string_prepend(gStrTmp, chrString);
     121  NOMString_assignCString(nomRetval, gStrTmp->str, NULLHANDLE);
     122  g_string_free(gStrTmp, TRUE);
    102123
    103   return nomSelf;
     124  return nomRetval;
    104125}
    105126
     
    111132}
    112133
    113 NOM_Scope PNOMString NOMLINK impl_NOMString_truncateString(NOMString* nomSelf, const CORBA_unsigned_long ulNewLen,
     134NOM_Scope PNOMString NOMLINK impl_NOMString_truncate(NOMString* nomSelf, const CORBA_unsigned_long ulNewLen,
    114135                                                           CORBA_Environment *ev)
    115136{
    116137  NOMStringData* nomThis=NOMStringGetData(nomSelf);
     138  PNOMString nomRetval=(PNOMString)NOMString_new(nomSelf, NULLHANDLE);
     139  GString* gStrTmp;
    117140
    118   g_string_truncate(_gString, ulNewLen);
     141  gStrTmp=g_string_new(_gString->str);
     142  g_string_truncate(gStrTmp, ulNewLen);
     143  NOMString_assignCString(nomRetval, gStrTmp->str, NULLHANDLE);
     144  g_string_free(gStrTmp, TRUE);
    119145
    120   return nomSelf;
     146  return nomRetval;
    121147}
    122148
    123 NOM_Scope PNOMString NOMLINK impl_NOMString_copyString(NOMString* nomSelf, CORBA_Environment *ev)
     149NOM_Scope PNOMString NOMLINK impl_NOMString_copy(NOMString* nomSelf, CORBA_Environment *ev)
    124150{
    125151  /*  NOMStringData* nomThis=NOMStringGetData(nomSelf); */
    126   PNOMString nomRetval=NOMStringNew();
     152  PNOMString nomRetval;
     153  NOMClass* nomCls;
    127154
    128   NOMString_assignString(nomRetval, nomSelf, ev);
     155  /* We don't know which class we're actually. So we can't just create a new NOMString here.
     156     It is possible that we are called by a subclass. So get the class object and let the
     157     class object create the correct class. */
     158  nomCls=NOMObject_nomGetClass((PNOMObject) nomSelf, NULLHANDLE);
     159  nomRetval=(PNOMString)NOMString_new(nomSelf, NULLHANDLE);
     160
     161  NOMString_assign(nomRetval, nomSelf, ev);
    129162
    130163  return nomRetval;
Note: See TracChangeset for help on using the changeset viewer.