property.h
2.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/***************************************************************************
* Universidade Federal da Paraíba *
* Copyright (C) 2013 by Laboratório de Aplicações de Vídeo Digital *
* *
* Centro de Informática - UFPB - Campus I *
* João Pessoa - PB - Brasil *
* *
* Author: Leonardo de Araújo Domingues (leonardo.araujo@lavid.ufpb.br) *
* Date: Mon Jun 1 19:29:50 BRT 2015 *
* *
**************************************************************************/
#ifndef PROPERTYHANDLER_H
#define PROPERTYHANDLER_H
#include <stdio.h>
#include <stdlib.h>
#include <map>
#include <string>
#include <string.h>
#include <lavidlib/io/File.h>
#include <lavidlib/io/FileIO.h>
#include <lavidlib/io/BufferedReader.h>
#include <lavidlib/io/IOException.h>
#include <lavidlib/io/EOFException.h>
#include <lavidlib/base/RuntimeException.h>
using namespace lavidlib;
class PropertyHandler {
public:
enum HandlerMode {
READ,
WRITE
};
PropertyHandler(char* _filename, PropertyHandler::HandlerMode _handler_mode);
virtual ~PropertyHandler();
int attr_exists(char* _attr);
const char* get_attibute_value(char* _attr);
void set_attribute_value(char* _attr_p, char* _value_p);
void update_properties();
int remove_attribute(char* _attr_p);
private:
std::string filename;
File* file_p;
FileIO* file_io_p;
BufferedReader* buff_reader_p;
HandlerMode handler_mode;
std::map<std::string, std::string> * map_ppty_p;
int check_file_extension(char* _filename);
void format_line_str(std::string* _line_str);
int load_properties();
void init_write_mode();
std::string get_key(std::string _ppty_line);
std::string get_value(std::string _ppty_line);
int write_properties_on_file(std::string _key, std::string _value, FILE* _file_output);
};
#endif /* PROPERTYHANDLER_H */