[boost-doc-zh] r416 committed - 翻译 tribool 库的 boostbook 文件

Revision: 416
Author: alai04
Date: Wed Jun 23 01:47:19 2010
Log: 翻译 tribool 库的 boostbook 文件
http://code.google.com/p/boost-doc-zh/source/detail?r=416

Added:
 /trunk/libs/logic/doc/Jamfile.v2
 /trunk/libs/logic/doc/tribool.boostbook
 /trunk/libs/logic/test/Jamfile.v2
Modified:
 /trunk/libs/logic/test/tribool_io_test.cpp
 /trunk/libs/logic/test/tribool_rename_test.cpp
 /trunk/libs/logic/test/tribool_test.cpp

=======================================
--- /dev/null
+++ /trunk/libs/logic/doc/Jamfile.v2    Wed Jun 23 01:47:19 2010
@@ -0,0 +1,15 @@
+project boost-sandbox/utility/doc ;
+import boostbook ;
+import doxygen ;
+
+doxygen reference : [ glob ../../../boost/logic/tribool.hpp ]
+                    [ glob ../../../boost/logic/tribool_fwd.hpp ]
+                    [ glob ../../../boost/logic/tribool_io.hpp ]
+                  ;
+boostbook tribool
+       :
+       tribool.boostbook
+       :
+ <format>pdf:<xsl:param>boost.url.prefix=http://www.boost.org/doc/libs/release/doc/html
+        <dependency>reference
+       ;
=======================================
--- /dev/null
+++ /trunk/libs/logic/doc/tribool.boostbook     Wed Jun 23 01:47:19 2010
@@ -0,0 +1,258 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN"
+  "http://www.boost.org/tools/boostbook/dtd/boostbook.dtd";>
+<library name="Tribool" dirname="logic" id="tribool"
+ last-revision="$Date: 2007/05/03 03:28:53 $" xmlns:xi="http://www.w3.org/2001/XInclude";>
+  <libraryinfo>
+    <author>
+      <firstname>Douglas</firstname>
+      <surname>Gregor</surname>
+      <email>dgregor -at- cs.indiana.edu</email>
+    </author>
+
+    <copyright>
+      <year>2002</year>
+      <year>2003</year>
+      <year>2004</year>
+      <holder>Douglas Gregor</holder>
+    </copyright>
+
+    <legalnotice>
+      <para>Use, modification and distribution is subject to the Boost
+    Software License, Version 1.0. (See accompanying file
+    <filename>LICENSE_1_0.txt</filename> or copy at <ulink
+ url="http://www.boost.org/LICENSE_1_0.txt";>http://www.boost.org/LICENSE_1_0.txt</ulink>)</para>
+    </legalnotice>
+
+    <librarypurpose>Three-state boolean type</librarypurpose>
+    <librarycategory name="category:misc"/>
+  </libraryinfo>
+
+  <title>Boost.Tribool</title>
+
+  <section id="tribool.introduction">
+    <title>Introduction 简介</title>
+
+    <para>The 3-state boolean library contains a single class,
+    <code><classname>boost::logic::tribool</classname></code>, along with
+    support functions and operator overloads that implement 3-state
+    boolean logic. <sbr/>
+ 三态布尔库内含一个 类:<code><classname>boost::logic::tribool</classname></code>,
+    以及相关的支持函数和实现三态布尔逻辑的操作符重载。</para>
+  </section>
+
+  <section id="tribool.tutorial">
+    <title>Tutorial 指南</title>
+
+    <using-namespace name="boost::logic"/>
+
+    <section>
+      <title>Basic usage 基本用法</title>
+    <para> The <code><classname>tribool</classname></code> class acts
+    like the built-in <code>bool</code> type, but for 3-state boolean
+    logic. The three states are <code>true</code>, <code>false</code>,
+    and <code><functionname>indeterminate</functionname></code>, where
+    the first two states are equivalent to those of the C++
+    <code>bool</code> type and the last state represents an unknown
+    boolean value (that may be <code>true</code> or
+    <code>false</code>, we don't know).<sbr/>
+ <code><classname>tribool</classname></code> 类的作用类似于内置的 <code>bool</code>类型,但它是用于三态布尔逻辑的。 + 所谓三态就是:<code>true</code>, <code>false</code>, 和 <code><functionname>indeterminate</functionname></code>, + 前两个等价于C++的<code>bool</code>类型,而最后一个则表示一种未知的布尔 值(即可能是 <code>true</code> 或 <code>false</code>,
+    我们不知道)。</para>
+
+    <para> The <code><classname>tribool</classname></code> class
+    supports conversion from <code>bool</code> values and literals
+    along with its own
+    <code><functionname>indeterminate</functionname></code>
+    keyword:<sbr/>
+ <code><classname>tribool</classname></code> 类支持从 <code>bool</code> 值或它自己的 + <code><functionname>indeterminate</functionname></code> 关键字转 换:</para>
+
+    <programlisting><classname>tribool</classname> b(true);
+b = false;
+b = <functionname>indeterminate</functionname>;
+<classname>tribool</classname> b2(b);</programlisting>
+
+    <para> <code><classname>tribool</classname></code> supports
+    conversions to <code>bool</code> for use in conditional
+    statements. The conversion to <code>bool</code> will be
+    <code>true</code> when the value of the
+    <code><classname>tribool</classname></code> is always true, and
+    <code>false</code> otherwise. Consequently, the following idiom
+    may be used to determine which of the three states a
+    <code><classname>tribool</classname></code> currently
+    holds:<sbr/>
+ <code><classname>tribool</classname></code> 可以在条件语句中转换为 <code>bool</code> 值。 + 如果 <code><classname>tribool</classname></code> 的值总为真,则转换得到 的 <code>bool</code> 为 <code>true</code>, + 否则为 <code>false</code>。因此,以下写法可用于判断一个 <code><classname>tribool</classname></code>
+    当前所持的值为三态中的哪一态:</para>
+
+<programlisting><classname>tribool</classname> b = some_operation();
+if (b) {
+  // b is true
+}
+else if (!b) {
+  // b is false
+}
+else {
+  // b is indeterminate
+}</programlisting>
+
+  <para> <code><classname>tribool</classname></code> supports the
+  3-state logic operators <code>!</code> (negation),
+  <code>&amp;&amp;</code> (AND), and <code>||</code> (OR), with
+  <code>bool</code> and <code><classname>tribool</classname></code>
+  values. For instance:<sbr/>
+ <code><classname>tribool</classname></code> 支持三态逻辑操作符 <code>!</code> (否), <code>&amp;&amp;</code> (与), + 和 <code>||</code> (或), 操作数可以是 <code>bool</code> 或 <code><classname>tribool</classname></code> 值。例如:</para>
+
+  <programlisting><classname>tribool</classname> x = some_op();
+<classname>tribool</classname> y = some_other_op();
+if (x &amp;&amp; y) {
+  // both x and y are true
+}
+else if (!(x &amp;&amp; y)) {
+  // either x or y is false
+}
+else {
+  // neither x nor y is false, but we don't know that both are true
+
+  if (x || y) {
+    // either x or y is true
+  }
+}</programlisting>
+
+  <para> Similarly, <code><classname>tribool</classname></code>
+  supports 3-state equality comparisons via the operators
+  <code>==</code> and <code>!=</code>. These operators differ from
+  "normal" equality operators in C++ because they return a
+  <code><classname>tribool</classname></code>, because potentially we
+  might not know the result of a comparison (try to compare
+  <code>true</code> and
+  <code><functionname>indeterminate</functionname></code>). For
+  instance:<sbr/>
+ 同样,<code><classname>tribool</classname></code> 支持三态的等值比较操作 符 <code>==</code> 和 <code>!=</code>。 + 这些操作符与C++中的"普通"等值比较操作不同,因为它们返回的是一个 <code><classname>tribool</classname></code>, + 由于我们可能不知道比较的结果(试想一下比较 <code>true</code> 和 <code><functionname>indeterminate</functionname></code>)。例如:</para>
+
+<programlisting><classname>tribool</classname> x(true);
+<classname>tribool</classname> y(<functionname>indeterminate</functionname>);
+
+assert(x == x); // okay, x == x returns true
+assert(x == true); // okay, can compare <classname>tribool</classname>s and bools</programlisting>
+
+ <para> The <code><functionname>indeterminate</functionname></code> keyword (representing the + <functionname>indeterminate</functionname>&nbsp;<code><classname>tribool</classname></code> value)
+  doubles as a function to check if the value of a
+  <code><classname>tribool</classname></code> is indeterminate,
+  e.g.,<sbr/>
+ <code><functionname>indeterminate</functionname></code> 关键字(表示一个 <functionname>indeterminate</functionname> + &nbsp;<code><classname>tribool</classname></code> 的值)也被用作一个函 数,用于检查一个 <code><classname>tribool</classname></code>
+  值是否为"不确定":</para>
+
+ <programlisting><classname>tribool</classname> x = try_to_do_something_tricky();
+if (<functionname>indeterminate</functionname>(x)) {
+  // value of x is indeterminate
+}
+else {
+  // report success or failure of x
+}</programlisting>
+</section>
+
+  <section>
+    <title>Renaming the indeterminate state 为"不确定"状态更名</title>
+  <para> Users may introduce additional keywords for the indeterminate
+  value in addition to the implementation-supplied
+  <code><functionname>indeterminate</functionname></code> using the
+  <code><macroname>BOOST_TRIBOOL_THIRD_STATE</macroname></code>
+  macro. For instance, the following macro instantiation (at the
+  global scope) will introduce the keyword <code>maybe</code> as a
+  synonym for <code><functionname>indeterminate</functionname></code>
+  (also residing in the <code>boost</code> namespace):<sbr/>
+ 除了本实现所提供的 <code><functionname>indeterminate</functionname></code> 以外,用户可以引入其 它的关键字来表示"不确定"值, + 方法是使用 <code><macroname>BOOST_TRIBOOL_THIRD_STATE</macroname></code> 宏。 + 例如,以下写法(须在全局范围)将引入一个关键字 <code>maybe</code> 作为 <code><functionname>indeterminate</functionname></code>
+  (同样位于 <code>boost</code> 命名空间)的同义词:</para>
+  <programlisting><macroname>BOOST_TRIBOOL_THIRD_STATE</macroname>(maybe)
+<classname>tribool</classname> x = maybe;
+if (maybe(x)) { /* ... */ }</programlisting>
+  </section>
+
+  <section>
+    <title><code>tribool</code> input/output 输入/输出</title>
+  <para><code><classname>tribool</classname></code> objects may be
+  read from and written to streams by including the
+  <headername>boost/logic/tribool_io.hpp</headername> header in a
+  manner very similar to <code>bool</code> values. When the
+  <code>boolalpha</code> flag is not set on the input/output stream,
+  the integral values 0, 1, and 2 correspond to <code>tribool</code>
+  values <code>false</code>, <code>true</code>, and
+  <code>indeterminate</code>, respectively. When
+  <code>boolalpha</code> is set on the stream, arbitrary strings can
+  be used to represent the three values, the default being "false",
+  "true", and "indeterminate". For instance:<sbr/>
+ <code><classname>tribool</classname></code> 对象可以从流中读入,也可以写 出到流,只需包含头文件 + <headername>boost/logic/tribool_io.hpp</headername>,输入/输出的风格类似 于 <code>bool</code> 值。 + 如果 <code>boolalpha</code> 标志未被设置在输入/输出流中,则整型值 0, 1, 和 2 分别对应于 <code>tribool</code> 值
+  <code>false</code>, <code>true</code>, 和 <code>indeterminate</code>。
+ 如果 <code>boolalpha</code> 被设置,则可以为这三个值设定任意的字符串来表 示,缺省为 "false", "true", 和 "indeterminate"。例如:</para>
+<programlisting><classname>tribool</classname> x;
+cin &gt;&gt; x; // Type "0", "1", or "2" to get false, true, or indeterminate +cout &lt;&lt; boolalpha &lt;&lt; x; // Produces "false", "true", or "indeterminate"</programlisting>
+
+  <para><code><classname>tribool</classname></code> input and output
+  is sensitive to the stream's current locale. The strings associated
+  with false and true values are contained in the standard
+  <code><classname>std::numpunct</classname></code> facet, and the
+  string naming the indeterminate type is contained in the
+  <code><classname>indeterminate_name</classname></code> facet. To
+  replace the name of the indeterminate state, you need to imbue your
+  stream with a local containing a
+  <code><classname>indeterminate_name</classname></code> facet, e.g.:<sbr/>
+ <code><classname>tribool</classname></code> 的输入/输出与流的当前locale相 关。 + false和true值所对应的字符串包含于标准的 <code><classname>std::numpunct</classname></code> 中, + 而 indeterminate 对应的字符串则包含于 <code><classname>indeterminate_name</classname></code> facet中。 + 要替换 indeterminate 状态的字符串,你需要将一个local注入你所使用的流,该 local需包含一个
+  <code><classname>indeterminate_name</classname></code> facet,如:</para>
+
+  <programlisting><macroname>BOOST_TRIBOOL_THIRD_STATE</macroname>(maybe)
+locale global;
+locale test_locale(global, new <classname>indeterminate_name</classname>&lt;char&gt;("maybe"));
+cout.imbue(test_locale);
+<classname>tribool</classname> x(maybe);
+cout &lt;&lt; boolalpha &lt;&lt; x &lt;&lt; endl; // Prints "maybe"</programlisting>
+
+  <para>If you C++ standard library implementation does not support
+  locales, <code>tribool</code> input/output will still work, but you
+  will be unable to customize the strings printed/parsed when
+  <code>boolalpha</code> is set.<sbr/>
+ 如果你的C++标准库实现不支持 locales, <code>tribool</code> 的输入/输出也可 以工作, + 但是你就不能定制在设置 <code>boolalpha</code> 时所打印或解释的字符串了。 </para>
+  </section>
+
+  </section>
+
+  <xi:include href="reference.xml"/>
+
+  <testsuite id="tribool.tests">
+    <run-test filename="tribool_test.cpp">
+      <purpose><para>Test all features of the
+      <code><classname>boost::logic::tribool</classname></code>
+      class.<sbr/>
+ 测试 <code><classname>boost::logic::tribool</classname></code> 类的所 有特性。</para></purpose>
+    </run-test>
+
+    <run-test filename="tribool_rename_test.cpp">
+      <purpose><para>Test the use of the
+      <code><macroname>BOOST_TRIBOOL_THIRD_STATE</macroname></code>
+      macro.<sbr/>
+ 测试 <code><macroname>BOOST_TRIBOOL_THIRD_STATE</macroname></code> 宏 的使用。</para></purpose>
+    </run-test>
+
+    <run-test filename="tribool_io_test.cpp">
+      <purpose><para>Test tribool input/output.<sbr/>
+      测试 tribool 输入/输出。</para></purpose>
+    </run-test>
+  </testsuite>
+</library>
=======================================
--- /dev/null
+++ /trunk/libs/logic/test/Jamfile.v2   Wed Jun 23 01:47:19 2010
@@ -0,0 +1,17 @@
+# Tribool library
+
+# Copyright (C) 2002-2003 Douglas Gregor
+
+# Use, modification and distribution is subject to the Boost Software License,
+# Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+# http://www.boost.org/LICENSE_1_0.txt)
+
+# For more information, see http://www.boost.org/
+
+  test-suite logic  :
+    [ run tribool_test.cpp ]
+    [ run tribool_rename_test.cpp ]
+    [ run tribool_io_test.cpp ]
+   ;
+
+

Other related posts:

  • » [boost-doc-zh] r416 committed - 翻译 tribool 库的 boostbook 文件 - boost-doc-zh