MFMv2.0.10
Movable Feast Machine Simulator 2.0.10
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ZStringByteSource.h
Go to the documentation of this file.
1 /* -*- mode:C++ -*-
2  ZStringByteSource.h Source bytes from a zero-terminated constant string
3  Copyright (C) 2014 The Regents of the University of New Mexico. All rights reserved.
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Lesser General Public
7  License as published by the Free Software Foundation; either
8  version 2.1 of the License, or (at your option) any later version.
9 
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this library; if not, write to the Free Software
17  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
18  USA
19 */
20 
28 #ifndef ZSTRINGBYTESOURCE_H
29 #define ZSTRINGBYTESOURCE_H
30 
31 #include "CharBufferByteSource.h"
32 #include <string.h> /* For strlen */
33 
34 namespace MFM
35 {
36 
41  {
42  private:
44 
51  static u32 Strlen(const char * ptr)
52  {
53  if (!ptr)
54  {
55  FAIL(NULL_POINTER);
56  }
57  return strlen(ptr);
58  }
59 
60  public:
68  ZStringByteSource(const char * input) :
69  Super(input, Strlen(input))
70  { }
71 
82  void Reset(const char * newString = 0)
83  {
84  if (newString != 0)
85  {
86  ChangeBuffer(newString, Strlen(newString));
87  }
88  else
89  {
90  Super::Reset();
91  }
92  }
93  };
94 }
95 
96 #endif /* ZSTRINGBYTESOURCE_H */
Definition: CharBufferByteSource.h:37
Definition: ZStringByteSource.h:40
void ChangeBuffer(const char *newBuffer, u32 bufferLength)
Definition: CharBufferByteSource.h:90
void Reset()
Definition: CharBufferByteSource.h:107
ZStringByteSource(const char *input)
Definition: ZStringByteSource.h:68
void Reset(const char *newString=0)
Definition: ZStringByteSource.h:82