gtool5 Fortran 90/95 ライブラリ 1.0.0-rc5
English
Loading...
Searching...
No Matches
dc_string::split Interface Reference

Public Member Functions

subroutine split_cc (str, carray, sep, limit)

Detailed Description

Definition at line 170 of file dc_string.f90.

Member Function/Subroutine Documentation

◆ split_cc()

subroutine dc_string::split::split_cc ( character(*), intent(in) str,
character(*), dimension(:), pointer carray,
character(*), intent(in) sep,
integer, intent(in), optional limit )

文字列を区切り文字で分割

str で与えられた文字列を文字列 sep で分解し、 ポインタ配列 carray に返します。 carray は必ず空状態にして与えてください。 割り付け状態の場合にはエラーを返します。 limit に正の数を与えた場合、最大 limit 個のフィールドに分割します。 負の数や 0 の場合は省略した場合と同じになります。 str の末尾の空白は除去されます。 sep に空文字を代入する場合、空白文字で分割されます。

Parameters
[in]str分割する文字列
[out]carray結果のポインタ配列
[in]sep区切り文字列
[in]limit最大フィールド数(省略可能)

Definition at line 1509 of file dc_string.f90.

1510 use dc_types, only: string
1511 implicit none
1512 character(*), intent(in):: str
1513 character(*), pointer:: carray(:) !(out)
1514 character(*), intent(in):: sep
1515 integer, intent(in), optional:: limit
1516 integer :: num, cur, i, limitnum
1517 character(STRING) :: substr
1518 logical :: end_flag
1519 continue
1520 if (present(limit)) then
1521 if (limit > 0) then
1522 limitnum = limit
1523 else
1524 limitnum = 0
1525 end if
1526 else
1527 limitnum = 0
1528 end if
1529 if (len(trim(sep)) == 0) then
1530 num = 1
1531 substr = str
1532 ! 重複して無駄だが carray を allocate するため, 何分割するか
1533 ! 調べ, num に格納する.
1534 do
1535 cur = index(trim(substr), ' ')
1536 if (cur == 0) exit
1537 num = num + 1
1538 substr = adjustl(substr(cur + len(sep) :len(substr)))
1539 end do
1540 if (limitnum /= 0 .and. num > limitnum) num = limitnum
1541 allocate(carray(num))
1542 substr = str
1543 end_flag = .false.
1544 do i = 1, num
1545 cur = index(trim(substr), ' ')
1546 if (cur == 0 .or. i == num) end_flag = .true.
1547 if (end_flag) then
1548 carray(i) = substr
1549 exit
1550 else
1551 carray(i) = substr(1:cur - 1)
1552 end if
1553 substr = adjustl(substr(cur + len(sep) :len(substr)))
1554 end do
1555 else
1556 num = 1
1557 substr = str
1558 ! 重複して無駄だが carray を allocate するため, 何分割するか
1559 ! 調べ, num に格納する.
1560 do
1561 cur = index(substr, trim(sep))
1562 if (cur == 0) exit
1563 num = num + 1
1564 substr = substr(cur + len(sep) :len(substr))
1565 end do
1566 if (limitnum /= 0 .and. num > limitnum) num = limitnum
1567 allocate(carray(num))
1568 substr = str
1569 end_flag = .false.
1570 do i = 1, num
1571 cur = index(substr, trim(sep))
1572 if (cur == 0 .or. i == num) end_flag = .true.
1573 if (end_flag) then
1574 carray(i) = substr
1575 exit
1576 else
1577 carray(i) = substr(1:cur - 1)
1578 end if
1579 substr = substr(cur + len(sep) :len(substr))
1580 end do
1581 end if
1582 return
種別型パラメタを提供します。
Definition dc_types.f90:55
integer, parameter, public string
文字列を保持する 文字型変数の種別型パラメタ
Definition dc_types.f90:137

References dc_types::string.


The documentation for this interface was generated from the following file: