Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
1.3 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //===========================================================================//
  7. #ifndef FILESYSTEM_HELPERS_H
  8. #define FILESYSTEM_HELPERS_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. struct characterset_t;
  13. // Don't call this directly. You should (as long as your destination is an array) be
  14. // able to call ParseFile, which is safer as it infers your array size for you.
  15. const char* ParseFileInternal( const char* pFileBytes, OUT_Z_CAP(nMaxTokenLen) char* pTokenOut, bool* pWasQuoted, characterset_t *pCharSet, size_t nMaxTokenLen );
  16. // Call until it returns NULL. Each time you call it, it will parse out a token.
  17. template <size_t count>
  18. const char* ParseFile( const char* pFileBytes, OUT_Z_ARRAY char (&pTokenOut)[count], bool* pWasQuoted, characterset_t *pCharSet = NULL, unsigned int nMaxTokenLen = (unsigned int)-1 )
  19. {
  20. (void*)nMaxTokenLen; // Avoid unreferenced variable warnings.
  21. return ParseFileInternal( pFileBytes, pTokenOut, pWasQuoted, pCharSet, count );
  22. }
  23. template <size_t count>
  24. char* ParseFile( char* pFileBytes, OUT_Z_ARRAY char (&pTokenOut)[count], bool* pWasQuoted ) // (same exact thing as the const version)
  25. {
  26. return const_cast<char*>( ParseFileInternal( pFileBytes, pTokenOut, pWasQuoted, NULL, count ) );
  27. }
  28. #endif // FILESYSTEM_HELPERS_H