• Main Page
  • Related Pages
  • Modules
  • Data Structures
  • Files
  • File List
  • Globals

sst/elements/genericProc/programs/libcprops/str.h

Go to the documentation of this file.
00001 #ifndef _CP_STRING_H
00002 #define _CP_STRING_H
00003 
00004 /** @{ */
00005 /**
00006  * @file
00007  * cp_string - 'safe' string allowing binary content 
00008  */
00009 
00010 #include "common.h"
00011 
00012 __BEGIN_DECLS
00013 
00014 #include "config.h"
00015 
00016 /** cp_string definition */
00017 typedef CPROPS_DLL struct _cp_string
00018 {
00019         int size;    /**< size allocated   */
00020         int len;     /**< size used        */
00021         char *data;  /**< internal buffer  */
00022 } cp_string;
00023 
00024 /** allocate a new cp_string */
00025 CPROPS_DLL
00026 cp_string *cp_string_create(char *data, int len);
00027 /** allocate an empty cp_string with a given buffer size */
00028 CPROPS_DLL
00029 cp_string *cp_string_create_empty(int initial_size);
00030 /** deallocate a cp_string */
00031 CPROPS_DLL
00032 void cp_string_delete(cp_string *str);
00033 /* on windows, you can't just free memory allocated by code in a dll. If you
00034  * want to set up a string, then delete the string object wrapper and just use
00035  * the internal char *, you have to free the wrap with cp_string_drop_wrap() 
00036  * and free the char * with cp_string_drop_content.
00037  */
00038 CPROPS_DLL
00039 void cp_string_drop_wrap(cp_string *str);
00040 CPROPS_DLL 
00041 void cp_string_drop_content(char *content);
00042 
00043 /** synonym for cp_string_delete */
00044 CPROPS_DLL
00045 void cp_string_destroy(cp_string *str);
00046 /** sets string to 0 */
00047 CPROPS_DLL
00048 void cp_string_clear(cp_string *str);
00049 /** releases existing string and sets string to empty string */
00050 CPROPS_DLL
00051 void cp_string_reset(cp_string *str);
00052 /** copies the content of a null terminated c string */
00053 CPROPS_DLL
00054 cp_string *cp_string_cstrcpy(cp_string *str, char *cstr);
00055 /** copies the content of a cp_string */
00056 CPROPS_DLL
00057 cp_string *cp_string_cpy(cp_string *dst, cp_string *src);
00058 /** creates a copy of src string. internal buffer is duplicated. */
00059 CPROPS_DLL
00060 cp_string *cp_string_dup(cp_string *src);
00061 /** creates a cp_string with src as its content */
00062 CPROPS_DLL
00063 cp_string *cp_string_cstrdup(char *src);
00064 /** concatenate cp_strings */
00065 CPROPS_DLL
00066 cp_string *cp_string_cat(cp_string *str, cp_string *appendum);
00067 /** append data from a buffer */
00068 CPROPS_DLL
00069 cp_string *cp_string_cat_bin(cp_string *str, void *bin, int len);
00070 /** append data from a null terminated c string */
00071 CPROPS_DLL
00072 cp_string *cp_string_cstrcat(cp_string *str, char *cstr);
00073 /** append a character to a string */
00074 CPROPS_DLL
00075 cp_string *cp_string_append_char(cp_string *str, char ch);
00076 /** compare cp_strings */
00077 CPROPS_DLL
00078 int cp_string_cmp(cp_string *s1, cp_string *s2);
00079 /** return a pointer to the internal buffer */
00080 CPROPS_DLL
00081 char *cp_string_tocstr(cp_string *str);
00082 /** return the length of the internal buffer */
00083 CPROPS_DLL
00084 int cp_string_len(cp_string *s);
00085 /** return the internal buffer */
00086 CPROPS_DLL
00087 char *cp_string_data(cp_string *s);
00088 
00089 /** read len bytes from an open file descriptor (blocking) */
00090 CPROPS_DLL
00091 cp_string *cp_string_read(int fd, int len);
00092 /** write the content of a cp_string to a file descriptor (blocking) */
00093 CPROPS_DLL
00094 int cp_string_write(cp_string *str, int fd);
00095 /** read the contents of a file into a cp_string */
00096 CPROPS_DLL
00097 cp_string *cp_string_read_file(char *filename);
00098 /** write the contents of a cp_string to a file */
00099 CPROPS_DLL
00100 int cp_string_write_file(cp_string *str, char *filename);
00101 
00102 /** flip the contents of a cp_string */
00103 CPROPS_DLL
00104 void cp_string_flip(cp_string *str);
00105 /** remove all occurrences of letters from str */
00106 CPROPS_DLL
00107 cp_string *cp_string_filter(cp_string *str, char *letters);
00108 
00109 /** dump a cp_string to stdout */
00110 CPROPS_DLL
00111 void cp_string_dump(cp_string *str);
00112 
00113 __END_DECLS
00114 
00115 /** @} */
00116 
00117 #endif
00118 

Generated on Fri Oct 22 2010 11:02:23 for SST by  doxygen 1.7.1