tstring.h

来自「Software Development in C: A Practical A」· C头文件 代码 · 共 115 行

H
115
字号
//---------------------------------------------------------
/*
File name:	Tstring.h
Comments:	This file contains the definitions needed to 
			use the text_string type.
*/
//---------------------------------------------------------

#ifndef TSTRING_H
#define TSTRING_H




//---------------------------------------------------------
// Include Files

#include <stdio.h>
#include "InstList.h"

// End Include Files
//---------------------------------------------------------




//---------------------------------------------------------
// Enumerated types

typedef enum 
{
	TSE_NO_ERROR = 0,
	TSE_CANT_ALLOCATE_STRING,
	TSE_STRING_DOES_NOT_EXIST,
	TSE_CANT_READ_STRING
} text_string_error;

// End enumerated types
//---------------------------------------------------------




//---------------------------------------------------------
// Type definitions

typedef instance_identifier text_string;

// End type definitions
//---------------------------------------------------------




//---------------------------------------------------------
// Macros

#define TextStringIsValid(tString) (tString >= 0)

// End Macros
//---------------------------------------------------------




//---------------------------------------------------------
// Prototypes

text_string TextStringCreate(text_string_error *errorStatus);

text_string_error TextStringSetFromCharArray(
						text_string destinationString,
					    const char * const charArray);

text_string_error TextStringSetFromTextString(
						text_string destinationString,
					    text_string sourceString);

text_string_error TextStringSetCharacter(
							text_string theString,
							char theCharacter,
							int characterIndex);

char TextStringGetCharacter(text_string sourceString,
 						    int characterIndex);

text_string_error TextStringAppendCharacter(
						text_string destinationString,
						char theCharacter);

int TextStringPrintString(text_string sourceString);

int TextStringScanString(text_string destinationString);

text_string_error TextStringFGetString(
					text_string theString,FILE *inputFile);

text_string_error TextStringFPutString(
					text_string theString,FILE *outputFile);

int TextStringGetLength(text_string sourceString);

text_string_error TextStringCopyAsCharArray(
					text_string sourceString,
					char **destinationArray);

void TextStringFree(text_string theString);

// End prototypes
//---------------------------------------------------------

#endif

// End Tstring.h
//---------------------------------------------------------

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?