-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
137 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
program api | ||
use attribute_value_pair_m | ||
use student_collection_m | ||
use student_json_m | ||
use student_xml_m | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
module attribute_value_pair_m | ||
implicit none | ||
private | ||
|
||
type, public :: attribute_value_pair_t | ||
character(len=80) :: the_attribute | ||
character(len=80) :: the_value | ||
end type attribute_value_pair_t | ||
|
||
contains | ||
|
||
end module attribute_value_pair_m |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
module http_request_m | ||
use attribute_value_pair_m | ||
use string_utils | ||
use url_helper | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,68 @@ | ||
module object_parser_m | ||
use attribute_value_pair_m | ||
|
||
implicit none | ||
private | ||
|
||
type, public :: object_parser_t | ||
private | ||
character(len=4096), public :: raw_data_m | ||
integer, public :: object_depth_m = 0 | ||
logical, public :: parsing_attribute_value_pair_m = .false. | ||
logical, public :: parsing_attribute_m = .false. | ||
logical, public :: parsing_value_m = .false. | ||
logical, public :: error_m = .false. | ||
character(len=4096), public :: error_string_m = '' | ||
type(attribute_value_pair_t), public, dimension(:), pointer :: & | ||
attribute_value_pairs_m | ||
|
||
contains | ||
procedure, public, pass(this) :: parse, & | ||
process_object, & | ||
process_attribute_value_pair, & | ||
process_error | ||
process_error, & | ||
add_attribute_value_pair | ||
|
||
end type object_parser_t | ||
|
||
contains | ||
subroutine parse(this) | ||
subroutine parse(this, raw_data) | ||
class(object_parser_t), intent(inout) :: this | ||
character(len=*), intent(in) :: raw_data | ||
|
||
this%error_m = .false. | ||
this%error_string_m = '' | ||
this%raw_data_m = raw_data | ||
end subroutine parse | ||
|
||
subroutine process_object(this) | ||
subroutine process_error(this, error_str) | ||
class(object_parser_t), intent(inout) :: this | ||
end subroutine process_object | ||
character(len=*), intent(in) :: error_str | ||
|
||
subroutine process_attribute_value_pair(this) | ||
class(object_parser_t), intent(inout) :: this | ||
end subroutine process_attribute_value_pair | ||
this%error_m = .true. | ||
this%error_string_m = error_str | ||
end subroutine process_error | ||
|
||
subroutine process_error(this) | ||
subroutine add_attribute_value_pair(this) | ||
class(object_parser_t), intent(inout) :: this | ||
end subroutine process_error | ||
|
||
type(attribute_value_pair_t), pointer, dimension(:) :: temp_array | ||
integer :: the_size | ||
|
||
if (.not. associated(this%attribute_value_pairs_m)) then | ||
! adding first one | ||
allocate(this%attribute_value_pairs_m(1)) | ||
this%attribute_value_pairs_m(1)%the_attribute = '' | ||
this%attribute_value_pairs_m(1)%the_value = '' | ||
else | ||
! adding second or subsequent on | ||
the_size = size(this%attribute_value_pairs_m) | ||
allocate(temp_array(the_size+1)) | ||
temp_array = this%attribute_value_pairs_m | ||
deallocate(this%attribute_value_pairs_m) | ||
this%attribute_value_pairs_m = temp_array | ||
|
||
this%attribute_value_pairs_m(the_size+1)%the_attribute = '' | ||
this%attribute_value_pairs_m(the_size+1)%the_value = '' | ||
end if | ||
end subroutine add_attribute_value_pair | ||
|
||
end module object_parser_m |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters