dclib-parser.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /***************************************************************************
  2. * *
  3. * _____ ____ *
  4. * | __ \ / __ \ _ _ _____ *
  5. * | | \ \ / / \_\ | | | | _ \ *
  6. * | | \ \| | | | | | |_| | *
  7. * | | | || | | | | | ___/ *
  8. * | | / /| | __ | | | | _ \ *
  9. * | |__/ / \ \__/ / | |___| | |_| | *
  10. * |_____/ \____/ |_____|_|_____/ *
  11. * *
  12. * Wiimms source code library *
  13. * *
  14. ***************************************************************************
  15. * *
  16. * Copyright (c) 2012-2022 by Dirk Clemens <wiimm@wiimm.de> *
  17. * *
  18. ***************************************************************************
  19. * *
  20. * This library is free software; you can redistribute it and/or modify *
  21. * it under the terms of the GNU General Public License as published by *
  22. * the Free Software Foundation; either version 2 of the License, or *
  23. * (at your option) any later version. *
  24. * *
  25. * This library is distributed in the hope that it will be useful, *
  26. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  27. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  28. * GNU General Public License for more details. *
  29. * *
  30. * See file gpl-2.0.txt or http://www.gnu.org/licenses/gpl-2.0.txt *
  31. * *
  32. ***************************************************************************/
  33. #ifndef DCLIB_PARSER_H
  34. #define DCLIB_PARSER_H 1
  35. #include "dclib-types.h"
  36. //
  37. ///////////////////////////////////////////////////////////////////////////////
  38. /////////////// ScanText_t ///////////////
  39. ///////////////////////////////////////////////////////////////////////////////
  40. // [[ScanText_t]]
  41. typedef struct ScanText_t
  42. {
  43. //-- base data
  44. ccp data; // begin of text
  45. uint data_size; // total size of text
  46. ccp fname; // NULL or filename for messages
  47. bool fname_alloced; // true: call FreeString(fname)
  48. //-- options
  49. bool ignore_comments; // true: ignore lines with leading '#'
  50. int detect_sections; // >0: detect lines of format '[...]'
  51. //-- current statee
  52. ccp ptr; // current text position
  53. ccp eot; // end of text
  54. ccp line; // current line
  55. ccp eol; // end of current line
  56. bool is_eot; // end of text reached
  57. bool is_section; // new section reached
  58. bool is_term; // := is_eot || is_section
  59. }
  60. ScanText_t;
  61. ///////////////////////////////////////////////////////////////////////////////
  62. void SetupScanText ( ScanText_t *st, cvp data, uint data_size );
  63. void ResetScanText ( ScanText_t *st );
  64. void SetFilenameScanText( ScanText_t *st, ccp fname, CopyMode_t cm );
  65. void RewindScanText ( ScanText_t *st );
  66. bool NextLineScanText ( ScanText_t *st );
  67. //
  68. ///////////////////////////////////////////////////////////////////////////////
  69. /////////////// E N D ///////////////
  70. ///////////////////////////////////////////////////////////////////////////////
  71. #endif // DCLIB_PARSER_H