Line data Source code
1 : /* File: io_file_format.c; Copyright and License: see below */
2 :
3 : #include "io_file_format.h"
4 : #include "u8/u8_trace.h"
5 : #include "utf8stringbuf/utf8stringbuf.h"
6 : #include <assert.h>
7 :
8 0 : void io_file_format_to_string( io_file_format_t format_set, utf8stringbuf_t out_fileformat )
9 : {
10 0 : U8_TRACE_BEGIN();
11 :
12 0 : int count = 0;
13 0 : utf8stringbuf_clear( &out_fileformat );
14 :
15 0 : if ( ( format_set & IO_FILE_FORMAT_PDF ) != 0 )
16 : {
17 : /*utf8stringbuf_append_str( &out_fileformat, (count==0)?("pdf"):(", pdf") );*/
18 0 : utf8stringbuf_append_str( &out_fileformat, "pdf" );
19 0 : count ++;
20 : }
21 :
22 0 : if ( ( format_set & IO_FILE_FORMAT_PNG ) != 0 )
23 : {
24 0 : utf8stringbuf_append_str( &out_fileformat, (count==0)?("png"):(", png") );
25 0 : count ++;
26 : }
27 :
28 0 : if ( ( format_set & IO_FILE_FORMAT_PS ) != 0 )
29 : {
30 0 : utf8stringbuf_append_str( &out_fileformat, (count==0)?("ps"):(", ps") );
31 0 : count ++;
32 : }
33 :
34 0 : if ( ( format_set & IO_FILE_FORMAT_SVG ) != 0 )
35 : {
36 0 : utf8stringbuf_append_str( &out_fileformat, (count==0)?("svg"):(", svg") );
37 0 : count ++;
38 : }
39 :
40 0 : if ( ( format_set & IO_FILE_FORMAT_TXT ) != 0 )
41 : {
42 0 : utf8stringbuf_append_str( &out_fileformat, (count==0)?("txt"):(", txt") );
43 0 : count ++;
44 : }
45 :
46 0 : if ( ( format_set & IO_FILE_FORMAT_DOCBOOK ) != 0 )
47 : {
48 0 : utf8stringbuf_append_str( &out_fileformat, (count==0)?("docbook"):(", docbook") );
49 0 : count ++;
50 : }
51 :
52 0 : if ( ( format_set & IO_FILE_FORMAT_HTML ) != 0 )
53 : {
54 0 : utf8stringbuf_append_str( &out_fileformat, (count==0)?("html"):(", html") );
55 0 : count ++;
56 : }
57 :
58 0 : if ( ( format_set & IO_FILE_FORMAT_CSS ) != 0 )
59 : {
60 0 : utf8stringbuf_append_str( &out_fileformat, (count==0)?("css"):(", css") );
61 0 : count ++;
62 : }
63 :
64 0 : if ( ( format_set & IO_FILE_FORMAT_JSON ) != 0 )
65 : {
66 0 : utf8stringbuf_append_str( &out_fileformat, (count==0)?("json"):(", json") );
67 0 : count ++;
68 : }
69 :
70 0 : if ( ( format_set & IO_FILE_FORMAT_SCHEMA ) != 0 )
71 : {
72 0 : utf8stringbuf_append_str( &out_fileformat, (count==0)?("schema"):(", schema") );
73 0 : count ++;
74 : }
75 :
76 0 : if ( ( format_set & IO_FILE_FORMAT_XMI2 ) != 0 )
77 : {
78 0 : utf8stringbuf_append_str( &out_fileformat, (count==0)?("xmi"):(", xmi") );
79 0 : count ++;
80 : }
81 :
82 0 : if ( count == 0 )
83 : {
84 0 : utf8stringbuf_copy_str( &out_fileformat, "none" );
85 : }
86 :
87 0 : U8_TRACE_END();
88 0 : }
89 :
90 :
91 : /*
92 : Copyright 2019-2025 Andreas Warnke
93 :
94 : Licensed under the Apache License, Version 2.0 (the "License");
95 : you may not use this file except in compliance with the License.
96 : You may obtain a copy of the License at
97 :
98 : http://www.apache.org/licenses/LICENSE-2.0
99 :
100 : Unless required by applicable law or agreed to in writing, software
101 : distributed under the License is distributed on an "AS IS" BASIS,
102 : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
103 : See the License for the specific language governing permissions and
104 : limitations under the License.
105 : */
|