TORCS  1.3.9
The Open Racing Car Simulator
string_utils.h
Go to the documentation of this file.
1 // Copyright (C) 2004 Johnny Mariethoz (Johnny.Mariethoz@idiap.ch)
2 // and Samy Bengio (bengio@idiap.ch)
3 // and Ronan Collobert (collober@iro.umontreal.ca)
4 // and Christos Dimitrakakis (dimitrak@idiap.ch)
5 //
6 // This file is based on code from Torch. Release II.
7 /***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 
16 #ifndef STRING_UTILS_INC
17 #define STRING_UTILS_INC
18 
19 #include <stdio.h>
20 #include <stdlib.h>
21 #include <learning/learn_debug.h>
22 
35 typedef struct StringBuffer_ {
36  char* c;
37  char* string;
38  unsigned int length;
39 } StringBuffer;
40 
42 extern StringBuffer* NewStringBuffer (int length);
43 
45 extern void FreeStringBuffer (StringBuffer** s);
46 
47 extern StringBuffer* SetStringBufferLength (StringBuffer* s, unsigned int l);
48 
52 extern char *strBaseName(char *filename);
53 
57 extern char *strRemoveSuffix(char *filename, char c='.');
58 
63 extern char *strConcat(int n, ...);
64 
66 extern void message(const char* msg, ...);
68 extern StringBuffer* read_string (FILE* f, StringBuffer* s);
70 extern char* string_copy (char* c);
72 
73 
74 
75 #endif
char * strRemoveSuffix(char *filename, char c='.')
Returns a fresh copy of the name of a file without suffix.
char * string
This is the string.
Definition: string_utils.h:37
void FreeStringBuffer(StringBuffer **s)
Given a pointer to a stringbuffer pointer, free it and clear it.
StringBuffer * NewStringBuffer(int length)
Make a new stringbuffer.
char * strBaseName(char *filename)
Returns the name of a file without leading pathname.
struct StringBuffer_ StringBuffer
The StringBuffer structure stores buffers of strings.
StringBuffer * read_string(FILE *f, StringBuffer *s)
Reads a string dynamically.
Scalar length(const Quaternion &q)
Definition: Quaternion.h:193
unsigned int length
This is the buffer length.
Definition: string_utils.h:38
char * string_copy(char *c)
copies a string
char * c
This is the buffer.
Definition: string_utils.h:36
char * strConcat(int n,...)
Returns the concatenation n strings.
void message(const char *msg,...)
Prints a message.
The StringBuffer structure stores buffers of strings.
Definition: string_utils.h:35
StringBuffer * SetStringBufferLength(StringBuffer *s, unsigned int l)