Hippy项目源码分析(三)

Hippy项目源码分析(三),第1张

Hippy项目源码分析(三)

2021SC@SDUSC

首篇文章已说明我的分工:Core全部内容

目录

  includecorebasethread_id.h

 includecorebaseuri_loader.h

  includecorebasethread_id.h
#pragma once

#include 
#include 

namespace hippy {
namespace base {

class ThreadId {
 public:
  constexpr ThreadId() noexcept = default;
  ~ThreadId();

  bool operator==(const ThreadId& other) const { return id_ == other.id_; }
  bool operator!=(const ThreadId& other) const { return id_ != other.id_; }

  void InitId(pthread_t id);
  static ThreadId GetCurrent();

 private:
  pthread_t id_ = kInvalidId;
  static pthread_t kInvalidId;
};

}  // namespace base
}  // namespace hippy

线程ID

 includecorebaseuri_loader.h
#pragma once

#include 
#include 
#include 

#include "base/unicode_string_view.h"

namespace hippy {
namespace base {

class UriLoader {
 public:
  using unicode_string_view = tdf::base::unicode_string_view;
  using u8string = unicode_string_view::u8string;

  UriLoader() {}
  virtual ~UriLoader() {}

  virtual bool RequestUntrustedContent(const unicode_string_view& uri,
                                       std::function cb) = 0;

  virtual bool RequestUntrustedContent(
      const unicode_string_view& uri,
      u8string& content) = 0;
};
}  // namespace base
}  // namespace hippy

 URI:统一资源标志符(Uniform Resource Identifier)  URL是可以直接 *** 作的,但是URI并不行

URI组件

该类是不可变类(Instances of this class are immutable),提供了用于从其组成部分或通过解析其字符串形式创建 URI 实例的构造方法、用于访问实例的各个不同组成部分的方法,以及用于对 URI 实例进行规范化、解析和相对化的方法。

在java的uri类中,将URI字符串分为绝对RUI和相对URI,或者不透明URI(opaque uri)和分层URI(hierarchical uri)。其中,不透明 URI 为绝对 URI,且不透明的URI无法解析,例如:mailto:[email protected] 、news:comp.lang.java、urn:isbn:096139210x,而分层URI即可以为绝对URI,也可以是相对URI,例如http://java.sun.com/j2se/1.3/ 是绝对URI,而../../../demo/jfc/SwingSet2/src/SwingSet2.java是相对URI。

分层URI
其结构为:[ scheme :][ // authority][ path][ ? query][ # fragment]
scheme与fragment部分是授权组成部分,可以基于服务,也可以基于注册表,常见的是基于服务,格式为:[ user-info @] host[ : port]
在给定实例中,任何特殊组成部分都或者为未定义的,或者为已定义的,并且有不同的值。未定义的字符串组成部分由 null 表示,未定义的整数组成部分由 -1 表示。
 

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5671682.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-16
下一篇 2022-12-16

发表评论

登录后才能评论

评论列表(0条)

保存