Chess 0.0.1
A library written in c
Loading...
Searching...
No Matches
file.h File Reference

Defines the chess file type and related utility functions for representing and manipulating chess files. More...

#include <chess/macros.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>

Go to the source code of this file.

Enumerations

enum  ChessFile : int8_t {
  CHESS_FILE_A = 0 ,
  CHESS_FILE_B = 1 ,
  CHESS_FILE_C = 2 ,
  CHESS_FILE_D = 3 ,
  CHESS_FILE_E = 4 ,
  CHESS_FILE_F = 5 ,
  CHESS_FILE_G = 6 ,
  CHESS_FILE_H = 7 ,
  CHESS_FILE_NONE = 8
}
 Represents the files (columns) on a chess board, from A to H. More...
 

Functions

void chess_file_debug (ChessFile file)
 Prints a debug representation of the given file.
 
bool chess_file_is_valid (ChessFile file)
 Checks if the given file is valid (A-H).
 
size_t chess_file_from_algebraic (ChessFile *file, const char *string)
 Parses a file from algebraic notation (e.g., "a", "b", ... "h").
 
size_t chess_file_to_algebraic (ChessFile file, char *string, size_t string_size)
 Converts a file to algebraic notation (e.g., "a", "b", ... "h").
 

Detailed Description

Defines the chess file type and related utility functions for representing and manipulating chess files.

Author
Tarek Saeed
Date
2025-06-14

Enumeration Type Documentation

◆ ChessFile

enum ChessFile : int8_t

Represents the files (columns) on a chess board, from A to H.

Enumerator
CHESS_FILE_A 

File A

CHESS_FILE_B 

File B

CHESS_FILE_C 

File C

CHESS_FILE_D 

File D

CHESS_FILE_E 

File E

CHESS_FILE_F 

File F

CHESS_FILE_G 

File G

CHESS_FILE_H 

File H

CHESS_FILE_NONE 

No file

Function Documentation

◆ chess_file_debug()

void chess_file_debug ( ChessFile  file)

Prints a debug representation of the given file.

Parameters
[in]fileThe file to print.

◆ chess_file_from_algebraic()

size_t chess_file_from_algebraic ( ChessFile file,
const char *  string 
)

Parses a file from algebraic notation (e.g., "a", "b", ... "h").

Parameters
[out]filePointer to store the parsed file.
[in]stringThe string containing the algebraic notation.
Returns
The number of characters read if successful, 0 otherwise.

◆ chess_file_is_valid()

bool chess_file_is_valid ( ChessFile  file)

Checks if the given file is valid (A-H).

Parameters
[in]fileThe file to check.
Returns
true if the file is valid, false otherwise.

◆ chess_file_to_algebraic()

size_t chess_file_to_algebraic ( ChessFile  file,
char *  string,
size_t  string_size 
)

Converts a file to algebraic notation (e.g., "a", "b", ... "h").

Parameters
[in]fileThe file to convert.
[out]stringThe buffer to store the algebraic notation.
[in]string_sizeThe size of the output buffer.
Returns
The number of characters written.