summaryrefslogtreecommitdiffstats
path: root/src/misc/vec
diff options
context:
space:
mode:
Diffstat (limited to 'src/misc/vec')
-rw-r--r--src/misc/vec/vecStr.h41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/misc/vec/vecStr.h b/src/misc/vec/vecStr.h
index 63be43d5..04cd5da8 100644
--- a/src/misc/vec/vecStr.h
+++ b/src/misc/vec/vecStr.h
@@ -283,6 +283,10 @@ static inline char * Vec_StrArray( Vec_Str_t * p )
{
return p->pArray;
}
+static inline char * Vec_StrLimit( Vec_Str_t * p )
+{
+ return p->pArray + p->nSize;
+}
/**Function*************************************************************
@@ -299,6 +303,10 @@ static inline int Vec_StrSize( Vec_Str_t * p )
{
return p->nSize;
}
+static inline void Vec_StrSetSize( Vec_Str_t * p, int nSize )
+{
+ p->nSize = nSize;
+}
/**Function*************************************************************
@@ -668,6 +676,39 @@ static inline void Vec_StrPrintStr( Vec_Str_t * p, const char * pStr )
Vec_StrPush( p, pStr[i] );
}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+#ifdef WIN32
+#define vsnprintf _vsnprintf
+#endif
+
+static inline char * Vec_StrPrintF( Vec_Str_t * p, const char * format, ... )
+{
+ int nAdded, nSize = 1000;
+ va_list args; va_start( args, format );
+ Vec_StrGrow( p, Vec_StrSize(p) + nSize );
+ nAdded = vsnprintf( Vec_StrLimit(p), nSize, format, args );
+ if ( nAdded > nSize )
+ {
+ Vec_StrGrow( p, Vec_StrSize(p) + nAdded + nSize );
+ nSize = vsnprintf( Vec_StrLimit(p), nAdded, format, args );
+ assert( nSize == nAdded );
+ }
+ p->nSize += nAdded;
+ va_end( args );
+ return Vec_StrLimit(p) - nAdded;
+}
+
/**Function*************************************************************
Synopsis [Appends the string to the char vector.]