Thinking in C++ 2nd edition Volume 2 Standard Libraries & Advanced Topics revision 1 phần 10

Bằng cách sử dụng các phôi thay vì cú pháp (Newtype), bạn có thể dễ dàng tìm kiếm cho tất cả các phôi trong bất cứ chương trình. Để hỗ trợ mã hiện tại, hầu hết các trình biên dịch có nồng độ khác nhau của thế hệ lỗi / cảnh báo có thể được bật và tắt. | Without the line break of course. Here you see a little bit of the way that data is encoded to send to CGI. For one thing spaces are not allowed since spaces typically separate commandline arguments . Spaces are replaced by signs. In addition each field contains the field name which is determined by the form on the HTML page followed by an and the field data and terminated by a . At this point you might wonder about the and . What if those are used in the field as in John Marsha Smith This is encoded to I John 26 Marsha Smith That is the special character is turned into a followed by its ASCII value in hex. Fortunately the web browser automatically performs all encoding for you. The CGI parser There are many examples of CGI programs written using Standard C. One argument for doing this is that Standard C can be found virtually everywhere. However C has become quite ubiquitous especially in the form of the GNU C Compiler29 g that can be downloaded free from the Internet for virtually any platform and often comes pre-installed with operating systems such as Linux . As you will see this means that you can get the benefit of object-oriented programming in a CGI program. Since what we re concerned with when parsing the CGI information is the field name-value pairs one class CGIpair will be used to represent a single name-value pair and a second class CGImap will use CGIpair to parse each name-value pair that is submitted from the HTML form into keys and values that it will hold in a map of strings so you can easily fetch the value for each field at your leisure. One of the reasons for using C here is the convenience of the STL in particular the map class. Since map has the operator you have a nice syntax for extracting the data for each field. The map template will be used in the creation of CGImap which you ll see is a fairly short definition considering how powerful it is. The project will start with a reusable portion which consists of CGIpair and CGImap in a header

Không thể tạo bản xem trước, hãy bấm tải xuống
TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.