+// This software is not affiliated with Valve Corporation
+// We are not affiliated, associated, authorized, endorsed by, or in any way officially
+// connected with Valve Corporation, or any of its subsidiaries or its affiliates.
+//
+// All trademarks are property of their respective owners
+
+// VDF aka Keyvalue text format parser / writer
+
#define vdf_foreach( NODE, STR, AS ) \
int __vdf_it_##AS = 0; \
vdf_node * AS;\
const char * AS;\
while( (AS = kv_iter( NODE, STR, &__kv_it_##AS )) )
-#include <stdio.h>
-#include <stdint.h>
-#include <string.h>
-#include <ctype.h>
// TYPES
// ==================================================================================================================
// INTERNAL API
// ==================================================================================================================
+#ifdef VALVE_IMPLEMENTATION
// Add keyvalue pair to node
void vdf_kv_append( vdf_node *p, const char *k, const char *v );
// Formatting
void vdf_out_indent( const int n, FILE *file );
+#endif
+
// IMPLEMENTATION
// ==================================================================================================================
u32 user1;
};
+#ifdef VALVE_IMPLEMENTATION
+
vdf_node *vdf_next( vdf_node *node, const char *name, int *it )
{
if( !node )
if( vdf_line_control( ctx ) )
{
- fprintf( stderr, "Unexpected end of line character (Line: %u)\n", ctx->lines );
+ log_error( "Unexpected end of line character (Line: %u)\n", ctx->lines );
return;
}
{
if( ctx->st.tokens[0] || !ctx->st.expect_decl )
{
- fprintf( stderr, "Unexpected token '{' (Line: %u)\n", ctx->lines );
+ log_error( "Unexpected token '{' (Line: %u)\n", ctx->lines );
ctx->errors ++;
}
{
if( !ctx->st.pnode->parent )
{
- fprintf( stderr, "Unexpected token '}' (Line: %u)\n", ctx->lines );
+ log_error( "Unexpected token '}' (Line: %u)\n", ctx->lines );
ctx->errors ++;
}
else
if( ctx->st.expect_decl )
{
- fprintf( stderr, "Unexpected token '%s' (Line: %u)\n", ctx->name, ctx->lines );
+ log_error( "Unexpected token '%s' (Line: %u)\n", ctx->name, ctx->lines );
ctx->errors ++;
}
}
if( !text_src )
{
- fprintf( stderr, "vdf open failed\n" );
return 0;
}
{
vdf_out( node, -1, 0, stdout );
}
+
+#endif