nlohmann/json中所有异常类型说明_json_throw(type_error::create(316, "invalid utf-8 -程序员宅基地

技术标签: json  

https://github.com/nlohmann/json/blob/develop/include/nlohmann/detail/exceptions.hpp
这是异常类头文件,当然了在nlohmann/json.hpp中也包含了这些异常类

nlohmannh/josn中的异常类继承了C++的标准异常std::exception ,该异常是所有标准 C++ 异常的父类,标准异常都在头文件< exception > 中,文末附上exception.hpp头文件的全部代码

先看一个用例省略了部分代码,在try中解析文件内容获取到的结果,储存到json对象中,然后使用dump()函数序列化,当这些字符不是UTF-8时,dump()函数抛出异常此时我们对获取到的文件内容进行转换,转换为UTF-8继续运行

 try
 {
    
  	json tmp;
  	//......省略
    return tmp.dump();
 }
 catch(nlohmann::detail::exception& e)
 {
    
 	LOG_ERROR("json throw an error:%s, try to fix", e.what());
    string strRet = "{\"result\":0}";
    if (e.id == 316)
    {
    
    	string strContent = gbk_to_utf8(text);
        return FilterText(strContent, false);
    }
    return strRet;
 }

接着来看看官网给出的异常说明 type_error , ID:316

json.exception.type_error.316 | invalid UTF-8 byte at index 10: 0x7E | The @ref dump function only works with UTF-8 encoded strings; that is, if you assign a `std::string` to a JSON value, make sure it is UTF-8 encoded. |

翻译:dump函数仅适用于UTF-8编码的字符串;也就是说,如果为JSON值分配“std::string”,请确保它是UTF-8编码的

事实上nlohmann/json这个库只支持UTF-8编码

梳理一下dump()函数抛出异常的过程:
首先找到json.hpp中的dump函数,
string_t dump(const int indent = -1, const char indent_char = ’ ', const bool ensure_ascii = false, const error_handler_t error_handler = error_handler_t::strict) const

在这个dump()函数中调用了类serializer中的dump()方法,代码如下:
serializer s(detail::output_adapter<char, string_t>(result), indent_char, error_handler);
s.dump();
而serializer类中的dump()方法多处调用了dump_escaped(*val.m_value.string, ensure_ascii);
接着在dump_escaped函数中调用了JSON_THROW(type_error::create(316, "invalid UTF-8 byte at index " + std::to_string(i) + “: 0x” + sn));
这里跟一下宏定义
#define JSON_THROW(exception) throw exception
结合文末的exception.hpp中的type_error异常类声明,一目了然

更多丰富的异常处理认真研读exception.hpp以及json.hpp即可

以下为exceptions.hpp头文件

 1 #pragma once
    2 
    3 #include <exception> // exception
    4 #include <stdexcept> // runtime_error
    5 #include <string> // to_string
    6 
    7 #include <nlohmann/detail/input/position_t.hpp>
    8 
    9 namespace nlohmann
   10 {
    
   11 namespace detail
   12 {
    
   13 
   14 // exceptions //
   15 
   16 
   17 /*!
   18 @brief general exception of the @ref basic_json class
   19 
   20 This class is an extension of `std::exception` objects with a member @a id for
   21 exception ids. It is used as the base class for all exceptions thrown by the
   22 @ref basic_json class. This class can hence be used as "wildcard" to catch
   23 exceptions.
   24 
   25 Subclasses:
   26 - @ref parse_error for exceptions indicating a parse error
   27 - @ref invalid_iterator for exceptions indicating errors with iterators
   28 - @ref type_error for exceptions indicating executing a member function with
   29                   a wrong type
   30 - @ref out_of_range for exceptions indicating access out of the defined range
   31 - @ref other_error for exceptions indicating other library errors
   32 
   33 @internal
   34 @note To have nothrow-copy-constructible exceptions, we internally use
   35       `std::runtime_error` which can cope with arbitrary-length error messages.
   36       Intermediate strings are built with static functions and then passed to
   37       the actual constructor.
   38 @endinternal
   39 
   40 @liveexample{The following code shows how arbitrary library exceptions can be
   41 caught.,exception}
   42 
   43 @since version 3.0.0
   44 */
   45 class exception : public std::exception
   46 {
    
   47   public:
   48     /// returns the explanatory string
   49     const char* what() const noexcept override
   50     {
    
   51         return m.what();
   52     }
   53 
   54     /// the id of the exception
   55     const int id;
   56 
   57   protected:
   58     exception(int id_, const char* what_arg) : id(id_), m(what_arg) {
    }
   59 
   60     static std::string name(const std::string& ename, int id_)
   61     {
    
   62         return "[json.exception." + ename + "." + std::to_string(id_) + "] ";
   63     }
   64 
   65   private:
   66     /// an exception object as storage for error messages
   67     std::runtime_error m;
   68 };
   69 
   70 /*!
   71 @brief exception indicating a parse error
   72 
   73 This exception is thrown by the library when a parse error occurs. Parse errors
   74 can occur during the deserialization of JSON text, CBOR, MessagePack, as well
   75 as when using JSON Patch.
   76 
   77 Member @a byte holds the byte index of the last read character in the input
   78 file.
   79 
   80 Exceptions have ids 1xx.
   81 
   82 name / id                      | example message | description
   83 ------------------------------ | --------------- | -------------------------
   84 json.exception.parse_error.101 | parse error at 2: unexpected end of input; expected string literal | This error indicates a syntax error while deserializing a JSON text. The error message describes that an unexpected token (character) was encountered, and the member @a byte indicates the error position.
   85 json.exception.parse_error.102 | parse error at 14: missing or wrong low surrogate | JSON uses the `\uxxxx` format to describe Unicode characters. Code points above above 0xFFFF are split into two `\uxxxx` entries ("surrogate pairs"). This error indicates that the surrogate pair is incomplete or contains an invalid code point.
   86 json.exception.parse_error.103 | parse error: code points above 0x10FFFF are invalid | Unicode supports code points up to 0x10FFFF. Code points above 0x10FFFF are invalid.
   87 json.exception.parse_error.104 | parse error: JSON patch must be an array of objects | [RFC 6902](https://tools.ietf.org/html/rfc6902) requires a JSON Patch document to be a JSON document that represents an array of objects.
   88 json.exception.parse_error.105 | parse error: operation must have string member 'op' | An operation of a JSON Patch document must contain exactly one "op" member, whose value indicates the operation to perform. Its value must be one of "add", "remove", "replace", "move", "copy", or "test"; other values are errors.
   89 json.exception.parse_error.106 | parse error: array index '01' must not begin with '0' | An array index in a JSON Pointer ([RFC 6901](https://tools.ietf.org/html/rfc6901)) may be `0` or any number without a leading `0`.
   90 json.exception.parse_error.107 | parse error: JSON pointer must be empty or begin with '/' - was: 'foo' | A JSON Pointer must be a Unicode string containing a sequence of zero or more reference tokens, each prefixed by a `/` character.
   91 json.exception.parse_error.108 | parse error: escape character '~' must be followed with '0' or '1' | In a JSON Pointer, only `~0` and `~1` are valid escape sequences.
   92 json.exception.parse_error.109 | parse error: array index 'one' is not a number | A JSON Pointer array index must be a number.
   93 json.exception.parse_error.110 | parse error at 1: cannot read 2 bytes from vector | When parsing CBOR or MessagePack, the byte vector ends before the complete value has been read.
   94 json.exception.parse_error.112 | parse error at 1: error reading CBOR; last byte: 0xF8 | Not all types of CBOR or MessagePack are supported. This exception occurs if an unsupported byte was read.
   95 json.exception.parse_error.113 | parse error at 2: expected a CBOR string; last byte: 0x98 | While parsing a map key, a value that is not a string has been read.
   96 json.exception.parse_error.114 | parse error: Unsupported BSON record type 0x0F | The parsing of the corresponding BSON record type is not implemented (yet).
   97 
   98 @note For an input with n bytes, 1 is the index of the first character and n+1
   99       is the index of the terminating null byte or the end of file. This also
  100       holds true when reading a byte vector (CBOR or MessagePack).
  101 
  102 @liveexample{The following code shows how a `parse_error` exception can be
  103 caught.,parse_error}
  104 
  105 @sa - @ref exception for the base class of the library exceptions
  106 @sa - @ref invalid_iterator for exceptions indicating errors with iterators
  107 @sa - @ref type_error for exceptions indicating executing a member function with
  108                     a wrong type
  109 @sa - @ref out_of_range for exceptions indicating access out of the defined range
  110 @sa - @ref other_error for exceptions indicating other library errors
  111 
  112 @since version 3.0.0
  113 */
  114 class parse_error : public exception
  115 {
    
  116   public:
  117     /*!
  118     @brief create a parse error exception
  119     @param[in] id_       the id of the exception
  120     @param[in] pos       the position where the error occurred (or with
  121                          chars_read_total=0 if the position cannot be
  122                          determined)
  123     @param[in] what_arg  the explanatory string
  124     @return parse_error object
  125     */
  126     static parse_error create(int id_, const position_t& pos, const std::string& what_arg)
  127     {
    
  128         std::string w = exception::name("parse_error", id_) + "parse error" +
  129                         position_string(pos) + ": " + what_arg;
  130         return parse_error(id_, pos.chars_read_total, w.c_str());
  131     }
  132 
  133     static parse_error create(int id_, std::size_t byte_, const std::string& what_arg)
  134     {
    
  135         std::string w = exception::name("parse_error", id_) + "parse error" +
  136                         (byte_ != 0 ? (" at byte " + std::to_string(byte_)) : "") +
  137                         ": " + what_arg;
  138         return parse_error(id_, byte_, w.c_str());
  139     }
  140 
  141     /*!
  142     @brief byte index of the parse error
  143 
  144     The byte index of the last read character in the input file.
  145 
  146     @note For an input with n bytes, 1 is the index of the first character and
  147           n+1 is the index of the terminating null byte or the end of file.
  148           This also holds true when reading a byte vector (CBOR or MessagePack).
  149     */
  150     const std::size_t byte;
  151 
  152   private:
  153     parse_error(int id_, std::size_t byte_, const char* what_arg)
  154         : exception(id_, what_arg), byte(byte_) {
    }
  155 
  156     static std::string position_string(const position_t& pos)
  157     {
    
  158         return " at line " + std::to_string(pos.lines_read + 1) +
  159                ", column " + std::to_string(pos.chars_read_current_line);
  160     }
  161 };
  162 
  163 /*!
  164 @brief exception indicating errors with iterators
  165 
  166 This exception is thrown if iterators passed to a library function do not match
  167 the expected semantics.
  168 
  169 Exceptions have ids 2xx.
  170 
  171 name / id                           | example message | description
  172 ----------------------------------- | --------------- | -------------------------
  173 json.exception.invalid_iterator.201 | iterators are not compatible | The iterators passed to constructor @ref basic_json(InputIT first, InputIT last) are not compatible, meaning they do not belong to the same container. Therefore, the range (@a first, @a last) is invalid.
  174 json.exception.invalid_iterator.202 | iterator does not fit current value | In an erase or insert function, the passed iterator @a pos does not belong to the JSON value for which the function was called. It hence does not define a valid position for the deletion/insertion.
  175 json.exception.invalid_iterator.203 | iterators do not fit current value | Either iterator passed to function @ref erase(IteratorType first, IteratorType last) does not belong to the JSON value from which values shall be erased. It hence does not define a valid range to delete values from.
  176 json.exception.invalid_iterator.204 | iterators out of range | When an iterator range for a primitive type (number, boolean, or string) is passed to a constructor or an erase function, this range has to be exactly (@ref begin(), @ref end()), because this is the only way the single stored value is expressed. All other ranges are invalid.
  177 json.exception.invalid_iterator.205 | iterator out of range | When an iterator for a primitive type (number, boolean, or string) is passed to an erase function, the iterator has to be the @ref begin() iterator, because it is the only way to address the stored value. All other iterators are invalid.
  178 json.exception.invalid_iterator.206 | cannot construct with iterators from null | The iterators passed to constructor @ref basic_json(InputIT first, InputIT last) belong to a JSON null value and hence to not define a valid range.
  179 json.exception.invalid_iterator.207 | cannot use key() for non-object iterators | The key() member function can only be used on iterators belonging to a JSON object, because other types do not have a concept of a key.
  180 json.exception.invalid_iterator.208 | cannot use operator[] for object iterators | The operator[] to specify a concrete offset cannot be used on iterators belonging to a JSON object, because JSON objects are unordered.
  181 json.exception.invalid_iterator.209 | cannot use offsets with object iterators | The offset operators (+, -, +=, -=) cannot be used on iterators belonging to a JSON object, because JSON objects are unordered.
  182 json.exception.invalid_iterator.210 | iterators do not fit | The iterator range passed to the insert function are not compatible, meaning they do not belong to the same container. Therefore, the range (@a first, @a last) is invalid.
  183 json.exception.invalid_iterator.211 | passed iterators may not belong to container | The iterator range passed to the insert function must not be a subrange of the container to insert to.
  184 json.exception.invalid_iterator.212 | cannot compare iterators of different containers | When two iterators are compared, they must belong to the same container.
  185 json.exception.invalid_iterator.213 | cannot compare order of object iterators | The order of object iterators cannot be compared, because JSON objects are unordered.
  186 json.exception.invalid_iterator.214 | cannot get value | Cannot get value for iterator: Either the iterator belongs to a null value or it is an iterator to a primitive type (number, boolean, or string), but the iterator is different to @ref begin().
  187 
  188 @liveexample{The following code shows how an `invalid_iterator` exception can be
  189 caught.,invalid_iterator}
  190 
  191 @sa - @ref exception for the base class of the library exceptions
  192 @sa - @ref parse_error for exceptions indicating a parse error
  193 @sa - @ref type_error for exceptions indicating executing a member function with
  194                     a wrong type
  195 @sa - @ref out_of_range for exceptions indicating access out of the defined range
  196 @sa - @ref other_error for exceptions indicating other library errors
  197 
  198 @since version 3.0.0
  199 */
  200 class invalid_iterator : public exception
  201 {
    
  202   public:
  203     static invalid_iterator create(int id_, const std::string& what_arg)
  204     {
    
  205         std::string w = exception::name("invalid_iterator", id_) + what_arg;
  206         return invalid_iterator(id_, w.c_str());
  207     }
  208 
  209   private:
  210     invalid_iterator(int id_, const char* what_arg)
  211         : exception(id_, what_arg) {
    }
  212 };
  213 
  214 /*!
  215 @brief exception indicating executing a member function with a wrong type
  216 
  217 This exception is thrown in case of a type error; that is, a library function is
  218 executed on a JSON value whose type does not match the expected semantics.
  219 
  220 Exceptions have ids 3xx.
  221 
  222 name / id                     | example message | description
  223 ----------------------------- | --------------- | -------------------------
  224 json.exception.type_error.301 | cannot create object from initializer list | To create an object from an initializer list, the initializer list must consist only of a list of pairs whose first element is a string. When this constraint is violated, an array is created instead.
  225 json.exception.type_error.302 | type must be object, but is array | During implicit or explicit value conversion, the JSON type must be compatible to the target type. For instance, a JSON string can only be converted into string types, but not into numbers or boolean types.
  226 json.exception.type_error.303 | incompatible ReferenceType for get_ref, actual type is object | To retrieve a reference to a value stored in a @ref basic_json object with @ref get_ref, the type of the reference must match the value type. For instance, for a JSON array, the @a ReferenceType must be @ref array_t &.
  227 json.exception.type_error.304 | cannot use at() with string | The @ref at() member functions can only be executed for certain JSON types.
  228 json.exception.type_error.305 | cannot use operator[] with string | The @ref operator[] member functions can only be executed for certain JSON types.
  229 json.exception.type_error.306 | cannot use value() with string | The @ref value() member functions can only be executed for certain JSON types.
  230 json.exception.type_error.307 | cannot use erase() with string | The @ref erase() member functions can only be executed for certain JSON types.
  231 json.exception.type_error.308 | cannot use push_back() with string | The @ref push_back() and @ref operator+= member functions can only be executed for certain JSON types.
  232 json.exception.type_error.309 | cannot use insert() with | The @ref insert() member functions can only be executed for certain JSON types.
  233 json.exception.type_error.310 | cannot use swap() with number | The @ref swap() member functions can only be executed for certain JSON types.
  234 json.exception.type_error.311 | cannot use emplace_back() with string | The @ref emplace_back() member function can only be executed for certain JSON types.
  235 json.exception.type_error.312 | cannot use update() with string | The @ref update() member functions can only be executed for certain JSON types.
  236 json.exception.type_error.313 | invalid value to unflatten | The @ref unflatten function converts an object whose keys are JSON Pointers back into an arbitrary nested JSON value. The JSON Pointers must not overlap, because then the resulting value would not be well defined.
  237 json.exception.type_error.314 | only objects can be unflattened | The @ref unflatten function only works for an object whose keys are JSON Pointers.
  238 json.exception.type_error.315 | values in object must be primitive | The @ref unflatten function only works for an object whose keys are JSON Pointers and whose values are primitive.
  239 json.exception.type_error.316 | invalid UTF-8 byte at index 10: 0x7E | The @ref dump function only works with UTF-8 encoded strings; that is, if you assign a `std::string` to a JSON value, make sure it is UTF-8 encoded. |
  240 json.exception.type_error.317 | JSON value cannot be serialized to requested format | The dynamic type of the object cannot be represented in the requested serialization format (e.g. a raw `true` or `null` JSON object cannot be serialized to BSON) |
  241 
  242 @liveexample{The following code shows how a `type_error` exception can be
  243 caught.,type_error}
  244 
  245 @sa - @ref exception for the base class of the library exceptions
  246 @sa - @ref parse_error for exceptions indicating a parse error
  247 @sa - @ref invalid_iterator for exceptions indicating errors with iterators
  248 @sa - @ref out_of_range for exceptions indicating access out of the defined range
  249 @sa - @ref other_error for exceptions indicating other library errors
  250 
  251 @since version 3.0.0
  252 */
  253 class type_error : public exception
  254 {
    
  255   public:
  256     static type_error create(int id_, const std::string& what_arg)
  257     {
    
  258         std::string w = exception::name("type_error", id_) + what_arg;
  259         return type_error(id_, w.c_str());
  260     }
  261 
  262   private:
  263     type_error(int id_, const char* what_arg) : exception(id_, what_arg) {
    }
  264 };
  265 
  266 /*!
  267 @brief exception indicating access out of the defined range
  268 
  269 This exception is thrown in case a library function is called on an input
  270 parameter that exceeds the expected range, for instance in case of array
  271 indices or nonexisting object keys.
  272 
  273 Exceptions have ids 4xx.
  274 
  275 name / id                       | example message | description
  276 ------------------------------- | --------------- | -------------------------
  277 json.exception.out_of_range.401 | array index 3 is out of range | The provided array index @a i is larger than @a size-1.
  278 json.exception.out_of_range.402 | array index '-' (3) is out of range | The special array index `-` in a JSON Pointer never describes a valid element of the array, but the index past the end. That is, it can only be used to add elements at this position, but not to read it.
  279 json.exception.out_of_range.403 | key 'foo' not found | The provided key was not found in the JSON object.
  280 json.exception.out_of_range.404 | unresolved reference token 'foo' | A reference token in a JSON Pointer could not be resolved.
  281 json.exception.out_of_range.405 | JSON pointer has no parent | The JSON Patch operations 'remove' and 'add' can not be applied to the root element of the JSON value.
  282 json.exception.out_of_range.406 | number overflow parsing '10E1000' | A parsed number could not be stored as without changing it to NaN or INF.
  283 json.exception.out_of_range.407 | number overflow serializing '9223372036854775808' | UBJSON and BSON only support integer numbers up to 9223372036854775807. |
  284 json.exception.out_of_range.408 | excessive array size: 8658170730974374167 | The size (following `#`) of an UBJSON array or object exceeds the maximal capacity. |
  285 json.exception.out_of_range.409 | BSON key cannot contain code point U+0000 (at byte 2) | Key identifiers to be serialized to BSON cannot contain code point U+0000, since the key is stored as zero-terminated c-string |
  286 
  287 @liveexample{The following code shows how an `out_of_range` exception can be
  288 caught.,out_of_range}
  289 
  290 @sa - @ref exception for the base class of the library exceptions
  291 @sa - @ref parse_error for exceptions indicating a parse error
  292 @sa - @ref invalid_iterator for exceptions indicating errors with iterators
  293 @sa - @ref type_error for exceptions indicating executing a member function with
  294                     a wrong type
  295 @sa - @ref other_error for exceptions indicating other library errors
  296 
  297 @since version 3.0.0
  298 */
  299 class out_of_range : public exception
  300 {
    
  301   public:
  302     static out_of_range create(int id_, const std::string& what_arg)
  303     {
    
  304         std::string w = exception::name("out_of_range", id_) + what_arg;
  305         return out_of_range(id_, w.c_str());
  306     }
  307 
  308   private:
  309     out_of_range(int id_, const char* what_arg) : exception(id_, what_arg) {
    }
  310 };
  311 
  312 /*!
  313 @brief exception indicating other library errors
  314 
  315 This exception is thrown in case of errors that cannot be classified with the
  316 other exception types.
  317 
  318 Exceptions have ids 5xx.
  319 
  320 name / id                      | example message | description
  321 ------------------------------ | --------------- | -------------------------
  322 json.exception.other_error.501 | unsuccessful: {"op":"test","path":"/baz", "value":"bar"} | A JSON Patch operation 'test' failed. The unsuccessful operation is also printed.
  323 
  324 @sa - @ref exception for the base class of the library exceptions
  325 @sa - @ref parse_error for exceptions indicating a parse error
  326 @sa - @ref invalid_iterator for exceptions indicating errors with iterators
  327 @sa - @ref type_error for exceptions indicating executing a member function with
  328                     a wrong type
  329 @sa - @ref out_of_range for exceptions indicating access out of the defined range
  330 
  331 @liveexample{The following code shows how an `other_error` exception can be
  332 caught.,other_error}
  333 
  334 @since version 3.0.0
  335 */
  336 class other_error : public exception
  337 {
    
  338   public:
  339     static other_error create(int id_, const std::string& what_arg)
  340     {
    
  341         std::string w = exception::name("other_error", id_) + what_arg;
  342         return other_error(id_, w.c_str());
  343     }
  344 
  345   private:
  346     other_error(int id_, const char* what_arg) : exception(id_, what_arg) {
    }
  347 };
  348 }  // namespace detail
  349 }  // namespace nlohmann
版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/qq_42896627/article/details/108255869

智能推荐

服务器设置虚拟内存有什么好处,高频率内存有哪些优势?虚拟内存是什么-程序员宅基地

文章浏览阅读601次。为增进大家对内存的认识,本文将为大家介绍高频率内存的优势。此外,小编还将对虚拟内存加以探讨。我们每天都在同内存打交道,但大家对内存真的了解吗?上篇文章中,我们对服务器内存以及服务器内存技术有所介绍,为增进大家对内存的认识,本文将为大家介绍高频率内存的优势。此外,小编还将对虚拟内存加以探讨。如果你对内存及其相关知识具有兴趣,不妨继续往下阅读哦。一、高频率内存优势由于决定内存性能的核心因素有内存容量、..._服务器内存频率高有什么好处

微信小程序使用echarts真机调试报错:HTMLCanvasView is not defined_html canvas is not defined-程序员宅基地

文章浏览阅读3.6k次,点赞4次,收藏8次。报错内容:解决办法:给组件传入force-use-old-canvas="true"就可以在真机调试里展示了。重点:发布线上时,一定要将这句去掉,现在只是不支持真机调试,线上是可以使用的。重点:发布线上时,一定要将这句去掉,现在只是不支持真机调试,线上是可以使用的。重点:发布线上时,一定要将这句去掉,现在只是不支持真机调试,线上是可以使用的。<view style="width:..._html canvas is not defined

计算机基础知识 常见简答,第一章 计算机基础知识(多选和简答)及答案-程序员宅基地

文章浏览阅读457次。计算机第一章计算机基础知识多项选择题(有两个或两个以上正确答案)1、下列说法中,正确的是________。A、一个汉字用1个字节表示 B、在微机中,使用最普遍的字符编码是ASCII码C、高级语言程序可以编译为目标程序 D、ASCII码的最高位用作奇偶校验位2、文件型(外壳型)计算机病毒主要感染扩展名为________。A、COM B、BAT C、EXE D、DOC3、..._达成某一任务的指令的会合称为语言

[SceneKit专题]25-如何制作一个像Can-Knockdown的游戏-程序员宅基地

文章浏览阅读232次。说明SceneKit系列文章目录更多iOS相关知识查看github上WeekWeekUpProject本教程将包含以下内容:在SceneKit编辑器中建立基本的3D场景.编程加载并呈现3D场景.建立仿真物理,如何应用力.通过触摸与3D场景中的物体交互.设计并实现基本的碰撞检测.开始开始前,先下载初始项目starter project打开项目,简单查看一下里面都有些..._can knockdown1下载

Unity Shader的结构_unity的扩展sprites的shader-程序员宅基地

文章浏览阅读1.3k次。材质和Unity Shader在unity中,需要配合使用材质Material和Unity Shader才能达到需要的效果流程创建一个材质→创建一个Unity Shader,并把它赋给上一步中创建的材质→把材质赋给要渲染的对象→在材质面板中调整Unity Shader的属性,以得到满意的效果Unity中的材质Unity中的材质需要配合一个GameObject的Mesh或者Particle Systen组件来工作,它决定了我们的游戏对象看起来是什么样子的Unity中的Shader为了和前面通用的_unity的扩展sprites的shader

spring cloud 的断路器(Hystrix) 依赖添加注意点_hystrix最新依赖-程序员宅基地

文章浏览阅读3.6k次。最新的Hystrix 依赖都是隶属于netfix下,这样@HystrixCommand 和@EnableHystrixDashboard 才能使用&lt;dependency&gt; &lt;groupId&gt;org.springframework.cloud&lt;/groupId&gt; &lt;artifactId&gt;spring-cloud-starter-netf..._hystrix最新依赖

随便推点

Qt之文本编码转换_qt 将txt文件转换成字符串-程序员宅基地

文章浏览阅读844次。一、QTextCodecQTextCodec类提供了文本编码转换功能。指定字符集对文本进行转换。1.Qt程序中所有要显示到界面上的字符串最好都是用tr()函数;代码如下(示例):QTextCodec::setCoderForTr(QTextCodec::codecForName("UTF-8"));QLabel label;label.setText(QObject::tr("你好,世界!"));2.对于不是要显示到界面上的字符串中如果包含了中文,可以使用QString()进行编码转换。代_qt 将txt文件转换成字符串

在idea上使用git建立连接gitee上的仓库_the breanch to pull from should be selected-程序员宅基地

文章浏览阅读2k次。error: failed to push some refs to 'https://gitee.com/liyue25/test.git'To https://gitee.com/liyue25/test.githint: Updates were rejected because the remote contains work that you dohint: not have locally. This is usually caused by another repository push_the breanch to pull from should be selected

day11-函数作业_写一个自己的rjust函数,创建一个字符串的长度是指定长度,原字符串在新字符串中右-程序员宅基地

文章浏览阅读94次。写一个自己的rjust函数,创建一个字符串的长度是指定长度,原字符串在新字符串中右对齐,剩下的部分用指定的字符填充。写一个自己的index函数,统计指定列表中指定元素的所有下标,如果列表中没有指定元素返回-1。写一个自己的replace函数,将指定字符串中指定的旧字符串转换成指定的新字符串。编写一个函数,提取指定字符串中所有的字母,然后拼接在一起产生一个新的字符串。写一个自己的endswith函数,判断一个字符串是否已指定的字符串结束。写一个自己的upper函数,将一个字符串中所有的小写字母变成大写字母。._写一个自己的rjust函数,创建一个字符串的长度是指定长度,原字符串在新字符串中右

spring自定义全局异常_18jzz大全-程序员宅基地

文章浏览阅读1.3k次。spring自定义全局异常背景学习目标案列背景在springmvc的controller中程序员经常要封装错误对象返回错误,前端显示错误文案。通过spring的异常处理器,来进行自定义异常处理学习目标学习全局异常拦截器处理controller所有的异常的返回封装定义枚举异常码,设计自定义异常案列创建枚举异常码,定义系统异常情况/** * @author tianjz */..._18jzz大全

[py]你真的了解多核处理器吗? 了解多线程-程序员宅基地

文章浏览阅读95次。越来越多的人搞爬虫,设计到多线程爬取, 还有一些机器学习的一些模块也需要这玩意, 感觉自己不会逼格不高. 抽时间赶紧玩一玩这东西, 希望提高对软件的认知和归属感,不要太傻.cpu内部架构参考你知道CPU是如何工作的?-视频CPU核心越多越好?你的CPU可能正在养老!你真的了解多核处理器吗?1.双核≠双性能多核不一定会使你的手机或电脑速度更快,但它将提高你的PC的整体性能,这是一个...

XBee模块实现QGC与PX4飞控的组网通信连接_xbee实现多机控制-程序员宅基地

文章浏览阅读2k次,点赞5次,收藏18次。本篇博客介绍如何利用XBee模块实现QGC地面站与飞控的通信_xbee实现多机控制

推荐文章

热门文章

相关标签