ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
format.hpp
Go to the documentation of this file.
1#ifndef _format_hpp_INCLUDED
2#define _format_hpp_INCLUDED
3
4#include "global.h"
5
6#include <cstdarg>
7#include <cstdint>
8
10
11namespace CaDiCaL {
12
13// This class provides a 'printf' style formatting utility.
14// Only '%c', '%d', '%s' are supported at this point.
15// It is used to capture and save an error message.
16
17class Format {
18 char *buffer;
19 int64_t count, size;
20 void enlarge ();
21 void push_char (char);
22 void push_string (const char *);
23 void push_int (int);
24 void push_uint64 (uint64_t);
25 const char *add (const char *fmt, va_list &);
26
27public:
28 Format () : buffer (0), count (0), size (0) {}
30 if (buffer)
31 delete[] buffer;
32 }
33 const char *init (const char *fmt, ...) CADICAL_ATTRIBUTE_FORMAT (2, 3);
34 const char *append (const char *fmt, ...) CADICAL_ATTRIBUTE_FORMAT (2, 3);
35 operator const char * () const { return count ? buffer : 0; }
36};
37
38} // namespace CaDiCaL
39
41
42#endif
#define ABC_NAMESPACE_CXX_HEADER_START
#define ABC_NAMESPACE_CXX_HEADER_END
#define CADICAL_ATTRIBUTE_FORMAT(FORMAT_POSITION, VARIADIC_ARGUMENT_POSITION)
Definition cadical.hpp:1105
const char * init(const char *fmt,...) CADICAL_ATTRIBUTE_FORMAT(2
const char const char * append(const char *fmt,...) CADICAL_ATTRIBUTE_FORMAT(2
#define const
Definition zconf.h:196