| 1938 | // This is necessary because this character might have been overwritten by a terminating 0 |
| 1939 | template<int Flags> |
| 1940 | Ch parse_and_append_data(xml_node<Ch> *node, Ch *&text, Ch *contents_start) |
| 1941 | { |
| 1942 | // Backup to contents start if whitespace trimming is disabled |
| 1943 | if (!(Flags & parse_trim_whitespace)) |
| 1944 | text = contents_start; |
| 1945 | |
| 1946 | // Skip until end of data |
| 1947 | Ch *value = text, *end; |
| 1948 | if (Flags & parse_normalize_whitespace) |
| 1949 | end = skip_and_expand_character_refs<text_pred, text_pure_with_ws_pred, Flags>(text); |
| 1950 | else |
| 1951 | end = skip_and_expand_character_refs<text_pred, text_pure_no_ws_pred, Flags>(text); |
| 1952 | |
| 1953 | // Trim trailing whitespace if flag is set; leading was already trimmed by whitespace skip after > |
| 1954 | if (Flags & parse_trim_whitespace) |
| 1955 | { |
| 1956 | if (Flags & parse_normalize_whitespace) |
| 1957 | { |
| 1958 | // Whitespace is already condensed to single space characters by skipping function, so just trim 1 char off the end |
| 1959 | if (*(end - 1) == Ch(' ')) |
| 1960 | --end; |
| 1961 | } |
| 1962 | else |
| 1963 | { |
| 1964 | // Backup until non-whitespace character is found |
| 1965 | while (whitespace_pred::test(*(end - 1))) |
| 1966 | --end; |
| 1967 | } |
| 1968 | } |
| 1969 | |
| 1970 | // If characters are still left between end and value (this test is only necessary if normalization is enabled) |
| 1971 | // Create new data node |
| 1972 | if (!(Flags & parse_no_data_nodes)) |
| 1973 | { |
| 1974 | xml_node<Ch> *data = this->allocate_node(node_data); |
| 1975 | data->value(value, end - value); |
| 1976 | node->append_node(data); |
| 1977 | } |
| 1978 | |
| 1979 | // Add data to parent node if no data exists yet |
| 1980 | if (!(Flags & parse_no_element_values)) |
| 1981 | if (*node->value() == Ch('\0')) |
| 1982 | node->value(value, end - value); |
| 1983 | |
| 1984 | // Place zero terminator after value |
| 1985 | if (!(Flags & parse_no_string_terminators)) |
| 1986 | { |
| 1987 | Ch ch = *text; |
| 1988 | *end = Ch('\0'); |
| 1989 | return ch; // Return character that ends data; this is required because zero terminator overwritten it |
| 1990 | } |
| 1991 | |
| 1992 | // Return character that ends data |
| 1993 | return *text; |
| 1994 | } |
| 1995 | |
| 1996 | // Parse CDATA |
| 1997 | template<int Flags> |
nothing calls this directly
no test coverage detected