source: observatorio/simulacion/DB/strQuery.C

simulacion
Last change on this file was 209ac10, checked in by Alejandro <amujica@…>, 10 years ago

Cambio de rama

  • Property mode set to 100644
File size: 4.4 KB
Line 
1/*
2  Copyright (C) 2012
3  Alejandro Mujica (amujica@cenditel.gob.ve)
4  Erwin Paredes (eparedes@cenditel.gob.ve)
5  José Ruiz (jruiz@cenditel.gob.ve)
6  Rodolfo Rangel (rrangel@cenditel.gob.ve)
7  Julie Vera (jvera@cenditel.gob.ve)
8 
9  CENDITEL Fundación Centro Nacional de Desarrollo e Investigación en
10  Tecnologías Libres
11 
12  Este programa es software libre; Usted puede usarlo bajo los términos de la
13  licencia de software GPL versión 2.0 de la Free Software Foundation.
14 
15  Este programa se distribuye con la esperanza de que sea útil, pero SIN
16  NINGUNA GARANTÍA; tampoco las implícitas garantías de MERCANTILIDAD o
17  ADECUACIÓN A UN PROPÓSITO PARTICULAR.
18  Consulte la licencia GPL para más detalles. Usted debe recibir una copia
19  de la GPL junto con este programa; si no, escriba a la Free Software
20  Foundation Inc. 51 Franklin Street,5 Piso, Boston, MA 02110-1301, USA.
21*/
22
23/*
24  Autor:             Alejandro J. Mujica
25  Fecha de creación: 25/07/2013
26  Este archivo contiene la implementación de la clase StrQuery.
27*/
28
29# include <strQuery.H>
30
31StrQuery::StrQuery()
32    : select(), from(), where(), orderBy(), orderByOption() {
33
34    // Empty
35}
36 
37StrQuery::StrQuery(const StrQuery & strQuery)
38    : select(strQuery.select), from(strQuery.from), where(strQuery.where),
39      orderBy(strQuery.orderBy), orderByOption(strQuery.orderByOption) {
40
41    // Empty
42}
43 
44StrQuery::StrQuery(StrQuery && strQuery)
45    : select(), from(), where(), orderBy(), orderByOption() {
46
47    std::swap(select, strQuery.select);
48    std::swap(from, strQuery.from);
49    std::swap(where, strQuery.where);
50    std::swap(orderBy, strQuery.orderBy);
51    std::swap(orderByOption, strQuery.orderByOption);
52}
53
54void StrQuery::clear() {
55
56    select.clear();
57    from.clear();
58    where.clear();
59    orderBy.clear();
60    orderByOption.clear();
61}
62
63const std::string & StrQuery::getSelect() const {
64    return select;
65}
66
67void StrQuery::setSelect(const std::string & select) {
68    this->select = select;
69}
70
71void StrQuery::setSelect(std::string && select) {
72    this->select = std::move(select);
73}
74
75const std::string & StrQuery::getFrom() const {
76    return from;
77}
78
79void StrQuery::setFrom(const std::string & from) {
80    this->from = from;
81}
82
83void StrQuery::setFrom(std::string && from) {
84    this->from = std::move(from);
85}
86
87const std::string & StrQuery::getWhere() const {
88    return where;
89}
90
91void StrQuery::setWhere(const std::string & where) {
92    this->where = where;
93}
94
95void StrQuery::setWhere(std::string && where) {
96    this->where = std::move(where);
97}
98
99const std::string & StrQuery::getOrderBy() const {
100    return orderBy;
101}
102
103void StrQuery::setOrderBy(const std::string & orderBy) {
104    this->orderBy = orderBy;
105}
106
107void StrQuery::setOrderBy(std::string && orderBy) {
108    this->orderBy = std::move(orderBy);
109}
110
111const std::string & StrQuery::getOrderByOption() const {
112    return orderByOption;
113}
114
115void StrQuery::setOrderByOption(const std::string & orderByOption) {
116    this->orderByOption = orderByOption;
117}
118
119void StrQuery::setOrderByOption(std::string && orderByOption) {
120    this->orderByOption = std::move(orderByOption);
121}
122
123StrQuery & StrQuery::addSelect(const std::string & select) {
124
125    this->select.append(this->select.empty() ? "SELECT " : ", ");
126    this->select.append(select);
127
128    return *this;
129}
130
131StrQuery & StrQuery::addFrom(const std::string & from) {
132
133    this->from.append(this->from.empty() ? "FROM " : ", ");
134    this->from.append(from);
135
136    return *this;
137}
138
139StrQuery & StrQuery::addWhere(const std::string & where,
140                              const std::string & connector) {
141
142    this->where.append(this->where.empty() ? "WHERE " : " " + connector + " ");
143    this->where.append(where);
144
145    return *this;
146}
147
148StrQuery & StrQuery::addOrderBy(const std::string & orderBy) {
149
150    this->orderBy.append(this->orderBy.empty() ? "ORDER BY " : ", ");
151    this->orderBy.append(orderBy);
152
153    return *this;
154}
155
156StrQuery & StrQuery::operator = (const StrQuery & strQuery) {
157
158    if (&strQuery == this)
159        return *this;
160
161    select = strQuery.select;
162    from = strQuery.from;
163    where = strQuery.where;
164    orderBy = strQuery.orderBy;
165    orderByOption = strQuery.orderByOption;
166
167    return *this;
168}
169 
170StrQuery & StrQuery::operator = (StrQuery && strQuery) {
171
172    std::swap(select, strQuery.select);
173    std::swap(from, strQuery.from);
174    std::swap(where, strQuery.where);
175    std::swap(orderBy, strQuery.orderBy);
176    std::swap(orderByOption, strQuery.orderByOption);
177
178    return *this;
179}
180
Note: See TracBrowser for help on using the repository browser.