2 /*******************************************************************************/
3 /* Copyright (C) 2008 Jonathan Moore Liles */
5 /* This program is free software; you can redistribute it and/or modify it */
6 /* under the terms of the GNU General Public License as published by the */
7 /* Free Software Foundation; either version 2 of the License, or (at your */
8 /* option) any later version. */
10 /* This program is distributed in the hope that it will be useful, but WITHOUT */
11 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
12 /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for */
15 /* You should have received a copy of the GNU General Public License along */
16 /* with This program; see the file COPYING. If not,write to the Free Software */
17 /* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
18 /*******************************************************************************/
33 Log_Entry ( const Log_Entry &rhs );
34 Log_Entry & operator= ( const Log_Entry &rhs );
36 static char ** parse_alist ( const char *s );
37 static bool log_diff ( char **sa1, char **sa2 );
42 Log_Entry ( char **sa );
43 Log_Entry ( const char *s );
52 #define ADD( type, format, exp ) \
53 void add ( const char *name, type v ) \
56 asprintf( &_sa[ _i ], "%s " format, name, (exp) ); \
57 strtok( _sa[ _i++ ], " " ); \
64 static bool diff ( Log_Entry *e1, Log_Entry *e2 );
66 int size ( void ) const;
68 void get ( int n, const char **name, const char **value ) const;
71 char *print ( void ) const;
73 /* #define ADD ( type, format, exp ) \ */
74 /* void add ( const char *name, type v ) \ */
76 /* char pat[ 256 ]; \ */
78 /* p.name = strdup( name ); \ */
79 /* snprintf( pat, sizeof( pat ), format, exp ); \ */
80 /* p.value = strdup( pat ); \ */
81 /* _sa.push( p ); \ */
85 ADD( nframes_t, "%lu", (unsigned long)v );
86 ADD( unsigned long, "%lu", v );
87 ADD( const char *, "\"%s\"", v ? Loggable::escape( v ) : "" );
88 ADD( Loggable * , "0x%X", v ? v->id() : 0 );
89 ADD( float, "%f", v );
90 ADD( double, "%f", v );