Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F121789668
Book.cpp
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sun, Jul 13, 22:20
Size
1 KB
Mime Type
text/x-c
Expires
Tue, Jul 15, 22:20 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
27366733
Attached To
R7040 TinyXML2 application examples
Book.cpp
View Options
/*
* Book.cpp
*
* Created on: Jun 26, 2018
* Author: vachoux
*/
#include "Book.h"
#include "xml_utils.h"
#include <iostream>
using
namespace
std
;
using
namespace
tinyxml2
;
using
namespace
tinyxml2_utils
;
Book
::
Book
(
XMLElement
*
p_book
)
:
id_
(
get_attr_val
(
p_book
,
"id"
)),
category_
(
get_attr_val
(
p_book
,
"category"
)),
author_
(
get_elem_val
(
p_book
,
"author"
)),
title_
(
get_elem_val
(
p_book
,
"title"
)),
lang_
(
get_attr_val
(
get_elem
(
p_book
,
"title"
),
"lang"
)),
year_
(
get_elem_int
(
p_book
,
"year"
)),
stock_
(
get_attr_int
(
p_book
,
"stock"
)),
price_
(
get_elem_dbl
(
p_book
,
"price"
)),
currency_
(
get_attr_val
(
get_elem
(
p_book
,
"price"
),
"currency"
,
false
,
"chf"
)),
discount_
(
get_attr_yesno
(
get_elem
(
p_book
,
"price"
),
"discount"
,
false
,
"no"
)),
margin_
(
get_elem_dbl
(
p_book
,
"margin"
,
false
,
25.0
))
{
string
str
=
get_elem_val
(
p_book
,
"bestseller"
,
false
,
"no"
);
bestseller_
=
(
str
==
"yes"
)
?
true
:
false
;
}
void
Book
::
print
()
{
cout
<<
"### Book"
<<
endl
<<
" ID : "
<<
id_
<<
endl
<<
" Category : "
<<
category_
<<
endl
<<
" Author : "
<<
author_
<<
endl
<<
" Title : "
<<
title_
<<
endl
<<
" Language : "
<<
lang_
<<
endl
<<
" Year : "
<<
year_
<<
endl
<<
" Stock : "
<<
stock_
<<
endl
<<
" Price : "
<<
price_
<<
" "
<<
currency_
<<
endl
<<
" Discount : "
<<
(
discount_
?
"yes"
:
"no"
)
<<
endl
<<
" Margin : "
<<
margin_
<<
endl
<<
" Bestseller : "
<<
(
bestseller_
?
"yes"
:
"no"
)
<<
endl
;
}
Event Timeline
Log In to Comment