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.

43 lines
1.4 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: Shared code for parsing / searching for characters in a string
  4. // using lookup tables
  5. //
  6. // $Workfile: $
  7. // $Date: $
  8. // $NoKeywords: $
  9. //===========================================================================//
  10. #ifndef CHARACTERSET_H
  11. #define CHARACTERSET_H
  12. #ifdef _WIN32
  13. #pragma once
  14. #endif
  15. struct characterset_t
  16. {
  17. char set[256];
  18. };
  19. // This is essentially a strpbrk() using a precalculated lookup table
  20. //-----------------------------------------------------------------------------
  21. // Purpose: builds a simple lookup table of a group of important characters
  22. // Input : *pSetBuffer - pointer to the buffer for the group
  23. // *pSetString - list of characters to flag
  24. //-----------------------------------------------------------------------------
  25. extern void CharacterSetBuild( characterset_t *pSetBuffer, const char *pSetString );
  26. //-----------------------------------------------------------------------------
  27. // Purpose:
  28. // Input : *pSetBuffer - pre-build group buffer
  29. // character - character to lookup
  30. // Output : int - 1 if the character was in the set
  31. //-----------------------------------------------------------------------------
  32. #define IN_CHARACTERSET( SetBuffer, character ) ((SetBuffer).set[ (unsigned char) (character) ])
  33. #endif // CHARACTERSET_H