home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 3 / AACD03.BIN / AACD / Programming / sofa / archive / exml.lha / exml / compiler_specific / se / character_array.e < prev    next >
Text File  |  1999-04-13  |  1KB  |  58 lines

  1. class
  2.     CHARACTER_ARRAY
  3. inherit
  4.     CHARACTER_ARRAY_ABS
  5. creation
  6.     make_from_c
  7. feature {NONE} -- Initialisation
  8.     make_from_c (content_ptr: POINTER; len: INTEGER) is
  9.         require
  10.             content_ptr_not_void: content_ptr /= Void
  11.             len >= 0
  12.       local
  13.             needed: INTEGER;
  14.             ptr: POINTER
  15.       do
  16.             lower := 1;
  17.             upper := len;
  18.             needed := len;
  19.  
  20.             -- allocate storage space
  21.             -- TODO: could be simplified, for now code has just been copied from ARRAY.make
  22.             if needed > 0 then
  23.                 if capacity < needed then
  24.                     storage := storage.calloc(needed);
  25.                     capacity := needed;
  26.                 else
  27.                     clear_all;
  28.                 end;
  29.             end;
  30.             
  31.             -- copy data
  32.             ptr := mem_cpy (storage.to_external, content_ptr, len)
  33.       end;
  34.  
  35. feature {NONE} -- Externals
  36.  
  37.     mem_cpy (dest, src: POINTER; c: INTEGER): POINTER is
  38.             -- dirty old memcpy stub, to do some low level C stuff in Eiffel
  39.         external
  40.             "C"
  41.         alias
  42.             "memcpy_wrap"
  43.         end
  44. end -- class CHARACTER_ARRAY
  45. --|-------------------------------------------------------------------------
  46. --| eXML, Eiffel XML Parser Toolkit
  47. --| Copyright (C) 1999  Andreas Leitner
  48. --| See the file forum.txt included in this package for licensing info.
  49. --|
  50. --| Comments, Questions, Additions to this library? please contact:
  51. --|
  52. --| Andreas Leitner
  53. --| Arndtgasse 1/3/5
  54. --| 8010 Graz
  55. --| Austria
  56. --| email: andreas.leitner@teleweb.at
  57. --| web: http://exml.dhs.org
  58. --|-------------------------------------------------------------------------