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++ ], " " ); \
60 void add_raw ( const char *name, const char *v )
63 asprintf( &_sa[ _i ], "%s %s", name, v );
64 strtok( _sa[ _i++ ], " " );
71 static bool diff ( Log_Entry *e1, Log_Entry *e2 );
73 int size ( void ) const;
75 void get ( int n, const char **name, const char **value ) const;
78 char *print ( void ) const;
80 /* #define ADD ( type, format, exp ) \ */
81 /* void add ( const char *name, type v ) \ */
83 /* char pat[ 256 ]; \ */
85 /* p.name = strdup( name ); \ */
86 /* snprintf( pat, sizeof( pat ), format, exp ); \ */
87 /* p.value = strdup( pat ); \ */
88 /* _sa.push( p ); \ */
92 ADD( nframes_t, "%lu", (unsigned long)v );
93 ADD( unsigned long, "%lu", v );
94 ADD( const char *, "\"%s\"", v ? Loggable::escape( v ) : "" );
95 ADD( Loggable * , "0x%X", v ? v->id() : 0 );
96 ADD( float, "%f", v );
97 ADD( double, "%f", v );