1
Fork 0
This repository has been archived on 2021-10-24. You can view files and clone it, but cannot push or open issues or pull requests.
UOC_PP20211_PR/UOCContacts/include/contact.h
2021-10-24 17:44:40 +02:00

88 lines
2.2 KiB
C
Executable file

#ifndef __CONTACT_H__
#define __CONTACT_H__
#include "csv.h"
#include "date.h"
// Maximum length of an identity document
#define MAX_PERSON_DOCUMENT_LEN 15
/*typedef struct _tDate {
int day;
int month;
int year;
} tDate;*/
/*typedef struct _tTime {
int hour;
int minutes;
} tTime;*/
/*typedef struct _tDateTime {
tDate date;
tTime time;
} tDateTime;*/
// Parse a tDateTime from string information
void dateTime_parse(tDateTime* dateTime, const char* date, const char* time);
// Compare two tDateTime structures and return true if they contain the same value or false otherwise.
bool dateTime_cmp(tDateTime dateTime1, tDateTime dateTime2);
// Ex 1: Define data types here...
///////////////////////////
// #define MAX_POSITIONS 100
typedef struct _tCoordinate {
float latitude;
float longitude;
} tCoordinate;
typedef struct _tTimePosition {
tCoordinate coordinate;
tDateTime timestamp;
char person[MAX_PERSON_DOCUMENT_LEN];
} tTimePosition;
typedef struct _tGeolocationData {
tTimePosition* elems;
int count;
} tGeolocationData;
//////////////////////////////////
// Ex 2: Define your methods here ....
////////////////////////////////////////
// Initialize the geopositon data
void geoData_init(tGeolocationData* data);
// Parse input from CSVEntry
void contact_parse(tTimePosition* data, tCSVEntry entry);
// Add a new position
void geoData_add(tGeolocationData* data, tTimePosition position);
// Remove the data from a person in a certain time moment
void geoData_del(tGeolocationData* data, const char* document, tDateTime time);
// Print the geoposition data
void geoData_print(tGeolocationData data);
// [AUX METHOD] Return the position of a geoposition entry with provided information. -1 if it does not exist
int geoData_find(tGeolocationData data, const char* document, tDateTime time);
// [AUX METHOD] Copy the data from the source to destination
void timePos_cpy(tTimePosition* destination, tTimePosition source);
////////////////////////////////////////////
// PAC2
// Clear tGeopositionData structure
void geoData_free(tGeolocationData* geoData);
////////////////////////////////////////////
#endif